]> git.mxchange.org Git - friendica.git/commitdiff
New hook "support_probe"
authorMichael <heluecht@pirati.ca>
Thu, 27 Apr 2023 05:24:47 +0000 (05:24 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 27 Apr 2023 05:24:47 +0000 (05:24 +0000)
doc/Addons.md
doc/de/Addons.md
src/Core/Protocol.php
src/Module/Contact/Profile.php

index 5a80a9558595f704030867297a58d6e2123f7b71..567e5b27563c273502c505ea29eae05a82901595 100644 (file)
@@ -638,6 +638,14 @@ Hook data:
 - **uid** (input): the user id to revoke the block for.
 - **result** (output): a boolean value indicating wether the operation was successful or not.
 
+### support_probe
+
+Called to assert whether a connector addon provides probing capabilities.
+
+Hook data:
+- **protocol** (input): shorthand for the protocol. List of values is available in `src/Core/Protocol.php`.
+- **result** (output): should be true if the connector provides follow capabilities, left alone otherwise.
+
 ### storage_instance
 
 Called when a custom storage is used (e.g. webdav_storage)
@@ -907,6 +915,7 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
     Hook::callAll('revoke_follow', $hook_data);
     Hook::callAll('block', $hook_data);
     Hook::callAll('unblock', $hook_data);
+    Hook::callAll('support_probe', $hook_data);
 
 ### src/Core/Logger/Factory.php
 
index 73f2aeb45efb7e92530436a50e35507698dec9a1..0caf3f25453d7814c86836317856bc765bddff48 100644 (file)
@@ -397,6 +397,7 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap
     Hook::callAll('revoke_follow', $hook_data);
     Hook::callAll('block', $hook_data);
     Hook::callAll('unblock', $hook_data);
+    Hook::callAll('support_probe', $hook_data);
 
 ### src/Core/Logger/Factory.php
 
index 9c5aad83d43eedc2bba60a04ebd810abc17ddd0b..9890b8f285fdeaa94662039ff8226370f55fbf53 100644 (file)
@@ -305,4 +305,26 @@ class Protocol
 
                return $hook_data['result'];
        }
+
+       /**
+        * Returns whether the provided protocol supports probing for contacts
+        *
+        * @param $protocol
+        * @return bool
+        * @throws HTTPException\InternalServerErrorException
+        */
+       public static function supportsProbe($protocol): bool
+       {
+               if (in_array($protocol, self::NATIVE_SUPPORT)) {
+                       return true;
+               }
+
+               $hook_data = [
+                       'protocol' => $protocol,
+                       'result' => null
+               ];
+               Hook::callAll('support_probe', $hook_data);
+
+               return $hook_data['result'] === true;
+       }
 }
index 34d02ac228750fb250bc94aafed2df325d6312ba..d80405e235b76b8c33904ad83e8d3813ec7e8672 100644 (file)
@@ -463,7 +463,7 @@ class Profile extends BaseModule
                        ];
                }
 
-               if (in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
+               if (Protocol::supportsProbe($contact['network'])) {
                        $contact_actions['updateprofile'] = [
                                'label' => $this->t('Refetch contact data'),
                                'url'   => 'contact/' . $contact['id'] . '/updateprofile?t=' . $formSecurityToken,