From 970d86472e2f742349d8b9cc088bcc7c138f3ec6 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 27 Apr 2023 05:24:47 +0000 Subject: [PATCH] New hook "support_probe" --- doc/Addons.md | 9 +++++++++ doc/de/Addons.md | 1 + src/Core/Protocol.php | 22 ++++++++++++++++++++++ src/Module/Contact/Profile.php | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/doc/Addons.md b/doc/Addons.md index 5a80a95585..567e5b2756 100644 --- a/doc/Addons.md +++ b/doc/Addons.md @@ -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 diff --git a/doc/de/Addons.md b/doc/de/Addons.md index 73f2aeb45e..0caf3f2545 100644 --- a/doc/de/Addons.md +++ b/doc/de/Addons.md @@ -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 diff --git a/src/Core/Protocol.php b/src/Core/Protocol.php index 9c5aad83d4..9890b8f285 100644 --- a/src/Core/Protocol.php +++ b/src/Core/Protocol.php @@ -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; + } } diff --git a/src/Module/Contact/Profile.php b/src/Module/Contact/Profile.php index 34d02ac228..d80405e235 100644 --- a/src/Module/Contact/Profile.php +++ b/src/Module/Contact/Profile.php @@ -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, -- 2.39.5