]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Add feedback :-)
[friendica.git] / src / Model / Contact.php
index 53f696444d31bd3724cdc6e51dc3cb7cd1c4e086..7f72b38d61aa14484fab852a846b0f61ac5bd647 100644 (file)
@@ -1929,11 +1929,6 @@ class Contact
         */
        private static function updateContact(int $id, int $uid, string $old_url, string $new_url, array $fields)
        {
-               if (Strings::normaliseLink($new_url) != Strings::normaliseLink($old_url)) {
-                       Logger::notice('New URL differs from old URL', ['old' => $old_url, 'new' => $new_url]);
-                       return;
-               }
-
                if (!DBA::update('contact', $fields, ['id' => $id])) {
                        Logger::info('Couldn\'t update contact.', ['id' => $id, 'fields' => $fields]);
                        return;
@@ -2106,6 +2101,12 @@ class Contact
 
                $updated = DateTimeFormat::utcNow();
 
+               if (Strings::normaliseLink($contact['url']) != Strings::normaliseLink($ret['url'])) {
+                       Logger::notice('New URL differs from old URL', ['id' => $id, 'uid' => $uid, 'old' => $contact['url'], 'new' => $ret['url']]);
+                       self::updateContact($id, $uid, $contact['url'], $ret['url'], ['failed' => true, 'last-update' => $updated, 'failure_update' => $updated]);
+                       return false;
+               }
+
                // We must not try to update relay contacts via probe. They are no real contacts.
                // We check after the probing to be able to correct falsely detected contact types.
                if (($contact['contact-type'] == self::TYPE_RELAY) &&
@@ -2756,12 +2757,14 @@ class Contact
                return null;
        }
 
-       public static function removeFollower($importer, $contact)
+       public static function removeFollower(array $contact)
        {
-               if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::SHARING)) {
+               if (in_array($contact['rel'] ?? [], [self::FRIEND, self::SHARING])) {
                        DBA::update('contact', ['rel' => self::SHARING], ['id' => $contact['id']]);
-               } else {
+               } elseif (!empty($contact['id'])) {
                        self::remove($contact['id']);
+               } else {
+                       DI::logger()->info('Couldn\'t remove follower because of invalid contact array', ['contact' => $contact]);
                }
        }