diff --git a/src/Core/Hooks/HookEventBridge.php b/src/Core/Hooks/HookEventBridge.php index bc2262df55..356dfe7e9c 100644 --- a/src/Core/Hooks/HookEventBridge.php +++ b/src/Core/Hooks/HookEventBridge.php @@ -59,6 +59,7 @@ final class HookEventBridge ArrayFilterEvent::ITEM_TAGGED => 'tagged', ArrayFilterEvent::DISPLAY_ITEM => 'display_item', ArrayFilterEvent::CACHE_ITEM => 'put_item_in_cache', + ArrayFilterEvent::CHECK_ITEM_NOTIFICATION => 'check_item_notification', ArrayFilterEvent::DETECT_LANGUAGES => 'detect_languages', ArrayFilterEvent::RENDER_LOCATION => 'render_location', ArrayFilterEvent::ITEM_PHOTO_MENU => 'item_photo_menu', @@ -130,6 +131,7 @@ final class HookEventBridge ArrayFilterEvent::ITEM_TAGGED => 'onArrayFilterEvent', ArrayFilterEvent::DISPLAY_ITEM => 'onArrayFilterEvent', ArrayFilterEvent::CACHE_ITEM => 'onArrayFilterEvent', + ArrayFilterEvent::CHECK_ITEM_NOTIFICATION => 'onArrayFilterEvent', ArrayFilterEvent::DETECT_LANGUAGES => 'onArrayFilterEvent', ArrayFilterEvent::RENDER_LOCATION => 'onArrayFilterEvent', ArrayFilterEvent::ITEM_PHOTO_MENU => 'onArrayFilterEvent', diff --git a/src/Event/ArrayFilterEvent.php b/src/Event/ArrayFilterEvent.php index 02a516bf61..0313520060 100644 --- a/src/Event/ArrayFilterEvent.php +++ b/src/Event/ArrayFilterEvent.php @@ -68,6 +68,8 @@ final class ArrayFilterEvent extends Event public const CACHE_ITEM = 'friendica.data.cache_item'; + public const CHECK_ITEM_NOTIFICATION = 'friendica.data.check_item_notification'; + public const DETECT_LANGUAGES = 'friendica.data.detect_languages'; public const RENDER_LOCATION = 'friendica.data.render_location'; diff --git a/src/Model/Post/UserNotification.php b/src/Model/Post/UserNotification.php index 95c578f486..d212b07b2f 100644 --- a/src/Model/Post/UserNotification.php +++ b/src/Model/Post/UserNotification.php @@ -9,10 +9,10 @@ namespace Friendica\Model\Post; use BadMethodCallException; use Exception; -use Friendica\Core\Hook; use Friendica\Database\Database; use Friendica\Database\DBA; use Friendica\DI; +use Friendica\Event\ArrayFilterEvent; use Friendica\Model\Contact; use Friendica\Model\Item; use Friendica\Model\Post; @@ -396,7 +396,12 @@ class UserNotification $profiles = [$owner['nurl']]; $notification_data = ['uid' => $uid, 'profiles' => []]; - Hook::callAll('check_item_notification', $notification_data); + + $eventDispatcher = DI::eventDispatcher(); + + $notification_data = $eventDispatcher->dispatch( + new ArrayFilterEvent(ArrayFilterEvent::CHECK_ITEM_NOTIFICATION, $notification_data), + )->getArray(); // Normalize the connector profiles foreach ($notification_data['profiles'] as $profile) { diff --git a/tests/Unit/Core/Hooks/HookEventBridgeTest.php b/tests/Unit/Core/Hooks/HookEventBridgeTest.php index d47ea1cbf7..f00e803ba1 100644 --- a/tests/Unit/Core/Hooks/HookEventBridgeTest.php +++ b/tests/Unit/Core/Hooks/HookEventBridgeTest.php @@ -48,6 +48,7 @@ class HookEventBridgeTest extends TestCase ArrayFilterEvent::ITEM_TAGGED => 'onArrayFilterEvent', ArrayFilterEvent::DISPLAY_ITEM => 'onArrayFilterEvent', ArrayFilterEvent::CACHE_ITEM => 'onArrayFilterEvent', + ArrayFilterEvent::CHECK_ITEM_NOTIFICATION => 'onArrayFilterEvent', ArrayFilterEvent::DETECT_LANGUAGES => 'onArrayFilterEvent', ArrayFilterEvent::RENDER_LOCATION => 'onArrayFilterEvent', ArrayFilterEvent::ITEM_PHOTO_MENU => 'onArrayFilterEvent', @@ -460,6 +461,7 @@ class HookEventBridgeTest extends TestCase [ArrayFilterEvent::ITEM_TAGGED, 'tagged'], [ArrayFilterEvent::DISPLAY_ITEM, 'display_item'], [ArrayFilterEvent::CACHE_ITEM, 'put_item_in_cache'], + [ArrayFilterEvent::CHECK_ITEM_NOTIFICATION, 'check_item_notification'], [ArrayFilterEvent::DETECT_LANGUAGES, 'detect_languages'], [ArrayFilterEvent::RENDER_LOCATION, 'render_location'], [ArrayFilterEvent::ITEM_PHOTO_MENU, 'item_photo_menu'], diff --git a/tests/Unit/Event/ArrayFilterEventTest.php b/tests/Unit/Event/ArrayFilterEventTest.php index 5bc71084c3..91d611a33b 100644 --- a/tests/Unit/Event/ArrayFilterEventTest.php +++ b/tests/Unit/Event/ArrayFilterEventTest.php @@ -45,6 +45,7 @@ class ArrayFilterEventTest extends TestCase [ArrayFilterEvent::ITEM_TAGGED, 'friendica.data.item_tagged'], [ArrayFilterEvent::DISPLAY_ITEM, 'friendica.data.display_item'], [ArrayFilterEvent::CACHE_ITEM, 'friendica.data.cache_item'], + [ArrayFilterEvent::CHECK_ITEM_NOTIFICATION, 'friendica.data.check_item_notification'], [ArrayFilterEvent::DETECT_LANGUAGES, 'friendica.data.detect_languages'], [ArrayFilterEvent::RENDER_LOCATION, 'friendica.data.render_location'], [ArrayFilterEvent::ITEM_PHOTO_MENU, 'friendica.data.item_photo_menu'],