diff --git a/src/Core/Hooks/HookEventBridge.php b/src/Core/Hooks/HookEventBridge.php index 2f1e51a297..6b652cf4f0 100644 --- a/src/Core/Hooks/HookEventBridge.php +++ b/src/Core/Hooks/HookEventBridge.php @@ -62,6 +62,7 @@ final class HookEventBridge ArrayFilterEvent::PROTOCOL_SUPPORTS_FOLLOW => 'support_follow', ArrayFilterEvent::PROTOCOL_SUPPORTS_REVOKE_FOLLOW => 'support_revoke_follow', ArrayFilterEvent::PROTOCOL_SUPPORTS_PROBE => 'support_probe', + ArrayFilterEvent::UNFOLLOW => 'unfollow', HtmlFilterEvent::HEAD => 'head', HtmlFilterEvent::FOOTER => 'footer', HtmlFilterEvent::PAGE_HEADER => 'page_header', @@ -104,6 +105,7 @@ final class HookEventBridge ArrayFilterEvent::PROTOCOL_SUPPORTS_FOLLOW => 'onArrayFilterEvent', ArrayFilterEvent::PROTOCOL_SUPPORTS_REVOKE_FOLLOW => 'onArrayFilterEvent', ArrayFilterEvent::PROTOCOL_SUPPORTS_PROBE => 'onArrayFilterEvent', + ArrayFilterEvent::UNFOLLOW => 'onArrayFilterEvent', HtmlFilterEvent::HEAD => 'onHtmlFilterEvent', HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent', HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent', diff --git a/src/Core/Protocol.php b/src/Core/Protocol.php index 1e5b7e7f21..61427d1017 100644 --- a/src/Core/Protocol.php +++ b/src/Core/Protocol.php @@ -183,7 +183,12 @@ class Protocol 'uid' => $owner['uid'], 'result' => null, ]; - Hook::callAll('unfollow', $hook_data); + + $eventDispatcher = DI::eventDispatcher(); + + $hook_data = $eventDispatcher->dispatch( + new ArrayFilterEvent(ArrayFilterEvent::PROTOCOL_SUPPORTS_FOLLOW, $hook_data), + )->getArray(); return $hook_data['result']; } diff --git a/src/Event/ArrayFilterEvent.php b/src/Event/ArrayFilterEvent.php index d21c6f8d78..9664071714 100644 --- a/src/Event/ArrayFilterEvent.php +++ b/src/Event/ArrayFilterEvent.php @@ -62,6 +62,8 @@ final class ArrayFilterEvent extends Event public const PROTOCOL_SUPPORTS_PROBE = 'friendica.data.protocol_supports_probe'; + public const UNFOLLOW = 'friendica.data.unfollow'; + private array $array; public function __construct(string $name, array $array) diff --git a/tests/Unit/Core/Hooks/HookEventBridgeTest.php b/tests/Unit/Core/Hooks/HookEventBridgeTest.php index cdd3e0d61b..93d62965c3 100644 --- a/tests/Unit/Core/Hooks/HookEventBridgeTest.php +++ b/tests/Unit/Core/Hooks/HookEventBridgeTest.php @@ -51,6 +51,7 @@ class HookEventBridgeTest extends TestCase ArrayFilterEvent::PROTOCOL_SUPPORTS_FOLLOW => 'onArrayFilterEvent', ArrayFilterEvent::PROTOCOL_SUPPORTS_REVOKE_FOLLOW => 'onArrayFilterEvent', ArrayFilterEvent::PROTOCOL_SUPPORTS_PROBE => 'onArrayFilterEvent', + ArrayFilterEvent::UNFOLLOW => 'onArrayFilterEvent', HtmlFilterEvent::HEAD => 'onHtmlFilterEvent', HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent', HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent', @@ -278,6 +279,7 @@ class HookEventBridgeTest extends TestCase [ArrayFilterEvent::PROTOCOL_SUPPORTS_FOLLOW, 'support_follow'], [ArrayFilterEvent::PROTOCOL_SUPPORTS_REVOKE_FOLLOW, 'support_revoke_follow'], [ArrayFilterEvent::PROTOCOL_SUPPORTS_PROBE, 'support_probe'], + [ArrayFilterEvent::UNFOLLOW, 'unfollow'], ]; }