]> 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 f4cd20a8567b70a75f1093efa14cf597acc88653..1375a8b3ef234b170b5d998f760b13d0876bef56 100644 (file)
@@ -845,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);
                }
        }
 
@@ -1414,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) {
@@ -2760,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()]);
                }
        }