]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Merge pull request #10787 from fabrixxm/issue/10767
[friendica.git] / src / Model / Contact.php
index b59e7c2b50949345922b2824a2198315f3eb267c..1375a8b3ef234b170b5d998f760b13d0876bef56 100644 (file)
@@ -627,9 +627,9 @@ class Contact
                        'nick'        => $user['nickname'],
                        'pubkey'      => $user['pubkey'],
                        'prvkey'      => $user['prvkey'],
-                       'photo'       => DI::baseUrl() . '/photo/profile/' . $user['uid'] . '.jpg',
-                       'thumb'       => DI::baseUrl() . '/photo/avatar/'  . $user['uid'] . '.jpg',
-                       'micro'       => DI::baseUrl() . '/photo/micro/'   . $user['uid'] . '.jpg',
+                       'photo'       => User::getAvatarUrlForId($user['uid']),
+                       'thumb'       => User::getAvatarUrlForId($user['uid'], Proxy::SIZE_THUMB),
+                       'micro'       => User::getAvatarUrlForId($user['uid'], Proxy::SIZE_MICRO),
                        'blocked'     => 0,
                        'pending'     => 0,
                        'url'         => DI::baseUrl() . '/profile/' . $user['nickname'],
@@ -742,7 +742,7 @@ class Contact
                        $fields['micro'] = self::getDefaultAvatar($fields, Proxy::SIZE_MICRO);
                }
 
-               $fields['avatar'] = DI::baseUrl() . '/photo/profile/' .$uid . '.' . $file_suffix;
+               $fields['avatar'] = User::getAvatarUrlForId($uid);
                $fields['forum'] = $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
                $fields['prv'] = $user['page-flags'] == User::PAGE_FLAGS_PRVGROUP;
                $fields['unsearchable'] = !$profile['net-publish'];
@@ -768,8 +768,11 @@ class Contact
                        DBA::update('contact', $fields, ['uid' => 0, 'nurl' => $self['nurl']]);
 
                        // Update the profile
-                       $fields = ['photo' => DI::baseUrl() . '/photo/profile/' .$uid . '.' . $file_suffix,
-                               'thumb' => DI::baseUrl() . '/photo/avatar/' . $uid .'.' . $file_suffix];
+                       $fields = [
+                               'photo' => User::getAvatarUrlForId($uid),
+                               'thumb' => User::getAvatarUrlForId($uid, Proxy::SIZE_THUMB)
+                       ];
+
                        DBA::update('profile', $fields, ['uid' => $uid]);
                }
 
@@ -842,6 +845,12 @@ class Contact
                        if ($dissolve) {
                                ActivityPub\Transmitter::sendContactReject($contact['url'], $contact['hub-verify'], $user['uid']);
                        }
+               } else {
+                       $hook_data = [
+                               'contact' => $contact,
+                               'dissolve' => $dissolve,
+                       ];
+                       Hook::callAll('unfollow', $hook_data);
                }
        }
 
@@ -1411,11 +1420,11 @@ class Contact
                if ($thread_mode) {
                        $items = Post::toArray(Post::selectForUser(local_user(), ['uri-id', 'gravity', 'parent-uri-id', 'thr-parent-id', 'author-id'], $condition, $params));
 
-                       $o .= conversation($a, $items, 'contacts', $update, false, 'commented', local_user());
+                       $o .= DI::conversation()->create($items, 'contacts', $update, false, 'commented', local_user());
                } else {
                        $items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params));
 
-                       $o .= conversation($a, $items, 'contact-posts', $update);
+                       $o .= DI::conversation()->create($items, 'contact-posts', $update);
                }
 
                if (!$update) {
@@ -2102,7 +2111,7 @@ 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' => $contact['uid'], 'old' => $contact['url'], 'new' => $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;
                }
@@ -2355,7 +2364,7 @@ class Contact
                        $probed = false;
                        $ret = $arr['contact'];
                } else {
-                       $probed = true;                 
+                       $probed = true;
                        $ret = Probe::uri($url, $network, $uid);
                }
 
@@ -2757,12 +2766,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, 'callstack' => System::callstack()]);
                }
        }