]> git.mxchange.org Git - friendica.git/commitdiff
Add new hook to support unfollow contacts on non-native networks
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 23 Sep 2021 02:56:34 +0000 (22:56 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 25 Sep 2021 20:15:06 +0000 (16:15 -0400)
doc/Addons.md
doc/de/Addons.md
mod/unfollow.php
src/Model/Contact.php

index 4a32dc09f430c9a96c477e21412ae6a2869cd454..72adb0372b6c132de1904963a335a744777f0a9e 100644 (file)
@@ -479,6 +479,23 @@ Hook data:
 - **uid** (input): the user to return the contact data for (can be empty for public contacts).
 - **result** (output): Set by the hook function to indicate a successful detection.
 
+### follow
+
+Called before adding a new contact for a user to handle non-native network remote contact (like Twitter).
+
+Hook data:
+
+- **url** (input): URL of the remote contact.
+- **contact** (output): should be filled with the contact (with uid = user creating the contact) array if follow was successful.
+
+### unfollow
+
+Called when unfollowing a remote contact on a non-native network (like Twitter)
+
+Hook data:
+- **contact** (input): the remote contact (uid = local unfollowing user id) array.
+- **dissolve** (input): whether to stop sharing with the remote contact as well.
+
 ## Complete list of hook callbacks
 
 Here is a complete list of all hook callbacks with file locations (as of 24-Sep-2018). Please see the source for details of any hooks not documented above.
@@ -648,6 +665,7 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
 
     Hook::callAll('contact_photo_menu', $args);
     Hook::callAll('follow', $arr);
+    Hook::callAll('unfollow', $hook_data);
 
 ### src/Model/Profile.php
 
index 276f5ed1b69713ebcd5b7d1c5a6a5b65f575277a..fe27354822c7d0a5ea14ef38cfa2cf6cdceb0110 100644 (file)
@@ -356,6 +356,7 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap
 
     Hook::callAll('contact_photo_menu', $args);
     Hook::callAll('follow', $arr);
+    Hook::callAll('unfollow', $hook_data);
 
 ### src/Model/Profile.php
 
index de1cb6cf7cdb05dd02a69c2bbc6447c59295f42b..6ee45b17d8adfe18932f19931d5c63bc35be6425 100644 (file)
@@ -144,7 +144,7 @@ function unfollow_process(string $url)
                Contact::terminateFriendship($owner, $contact, $dissolve);
        }
 
-       // Sharing-only contacts get deleted as there no relationship any more
+       // Sharing-only contacts get deleted as there no relationship anymore
        if ($dissolve) {
                Contact::remove($contact['id']);
                $return_path = $base_return_path;
index 54fae63b64802024c89905dad9d32242c427ea32..e5aa430089dd54401873674b2fc6dcfcbd67af12 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);
                }
        }