Create event for check_item_notification hook

This commit is contained in:
Art4 2025-03-24 12:28:22 +00:00
parent 76c3eeb96e
commit f0273a618c
5 changed files with 14 additions and 2 deletions

View file

@ -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',

View file

@ -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';

View file

@ -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) {

View file

@ -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'],

View file

@ -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'],