diff --git a/src/Core/Hooks/HookEventBridge.php b/src/Core/Hooks/HookEventBridge.php index 1567b3e20a..18a2754e33 100644 --- a/src/Core/Hooks/HookEventBridge.php +++ b/src/Core/Hooks/HookEventBridge.php @@ -46,6 +46,8 @@ final class HookEventBridge ArrayFilterEvent::POST_LOCAL_START => 'post_local_start', ArrayFilterEvent::POST_LOCAL => 'post_local', ArrayFilterEvent::POST_LOCAL_END => 'post_local_end', + ArrayFilterEvent::INSERT_POST_REMOTE => 'post_remote', + ArrayFilterEvent::INSERT_POST_REMOTE_END => 'post_remote_end', ArrayFilterEvent::PHOTO_UPLOAD_FORM => 'photo_upload_form', ArrayFilterEvent::NETWORK_TO_NAME => 'network_to_name', ArrayFilterEvent::CONVERSATION_START => 'conversation_start', @@ -102,6 +104,8 @@ final class HookEventBridge ArrayFilterEvent::POST_LOCAL_START => 'onArrayFilterEvent', ArrayFilterEvent::POST_LOCAL => 'onArrayFilterEvent', ArrayFilterEvent::POST_LOCAL_END => 'onArrayFilterEvent', + ArrayFilterEvent::INSERT_POST_REMOTE => 'onArrayFilterEvent', + ArrayFilterEvent::INSERT_POST_REMOTE_END => 'onArrayFilterEvent', ArrayFilterEvent::PHOTO_UPLOAD_FORM => 'onArrayFilterEvent', ArrayFilterEvent::NETWORK_TO_NAME => 'onArrayFilterEvent', ArrayFilterEvent::CONVERSATION_START => 'onArrayFilterEvent', diff --git a/src/Event/ArrayFilterEvent.php b/src/Event/ArrayFilterEvent.php index b3be9f70fa..0ab06525bd 100644 --- a/src/Event/ArrayFilterEvent.php +++ b/src/Event/ArrayFilterEvent.php @@ -30,6 +30,10 @@ final class ArrayFilterEvent extends Event public const POST_LOCAL_END = 'friendica.data.post_local_end'; + public const INSERT_POST_REMOTE = 'friendica.data.insert_post_remote'; + + public const INSERT_POST_REMOTE_END = 'friendica.data.insert_post_remote_end'; + public const PHOTO_UPLOAD_FORM = 'friendica.data.photo_upload_form'; public const NETWORK_TO_NAME = 'friendica.data.network_to_name'; diff --git a/src/Model/Event.php b/src/Model/Event.php index debeb74d45..125692dfe1 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -9,7 +9,6 @@ namespace Friendica\Model; use Friendica\Content\Feature; use Friendica\Content\Text\BBCode; -use Friendica\Core\Hook; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; diff --git a/src/Model/Item.php b/src/Model/Item.php index 31f8a8e22e..99ebba8cae 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -855,7 +855,9 @@ class Item unset($_SESSION['uid']); } } elseif (!$notify) { - Hook::callAll('post_remote', $item); + $item = $eventDispatcher->dispatch( + new ArrayFilterEvent(ArrayFilterEvent::INSERT_POST_REMOTE, $item) + )->getArray(); } if (!empty($item['cancel'])) { @@ -1112,7 +1114,11 @@ class Item DI::contentItem()->copyPermissions($posted_item['thr-parent-id'], $posted_item['uri-id'], $posted_item['parent-uri-id']); } } else { - Hook::callAll('post_remote_end', $posted_item); + $eventDispatcher = DI::eventDispatcher(); + + $posted_item = $eventDispatcher->dispatch( + new ArrayFilterEvent(ArrayFilterEvent::INSERT_POST_REMOTE_END, $posted_item) + )->getArray(); } if ($posted_item['gravity'] === self::GRAVITY_PARENT) { diff --git a/tests/Unit/Core/Hooks/HookEventBridgeTest.php b/tests/Unit/Core/Hooks/HookEventBridgeTest.php index 1852248ebb..69c49f3513 100644 --- a/tests/Unit/Core/Hooks/HookEventBridgeTest.php +++ b/tests/Unit/Core/Hooks/HookEventBridgeTest.php @@ -35,6 +35,8 @@ class HookEventBridgeTest extends TestCase ArrayFilterEvent::POST_LOCAL_START => 'onArrayFilterEvent', ArrayFilterEvent::POST_LOCAL => 'onArrayFilterEvent', ArrayFilterEvent::POST_LOCAL_END => 'onArrayFilterEvent', + ArrayFilterEvent::INSERT_POST_REMOTE => 'onArrayFilterEvent', + ArrayFilterEvent::INSERT_POST_REMOTE_END => 'onArrayFilterEvent', ArrayFilterEvent::PHOTO_UPLOAD_FORM => 'onArrayFilterEvent', ArrayFilterEvent::NETWORK_TO_NAME => 'onArrayFilterEvent', ArrayFilterEvent::CONVERSATION_START => 'onArrayFilterEvent', @@ -314,6 +316,8 @@ class HookEventBridgeTest extends TestCase [ArrayFilterEvent::POST_LOCAL_START, 'post_local_start'], [ArrayFilterEvent::POST_LOCAL, 'post_local'], [ArrayFilterEvent::POST_LOCAL_END, 'post_local_end'], + [ArrayFilterEvent::INSERT_POST_REMOTE, 'post_remote'], + [ArrayFilterEvent::INSERT_POST_REMOTE_END, 'post_remote_end'], [ArrayFilterEvent::PHOTO_UPLOAD_FORM, 'photo_upload_form'], [ArrayFilterEvent::NETWORK_TO_NAME, 'network_to_name'], [ArrayFilterEvent::CONVERSATION_START, 'conversation_start'], diff --git a/tests/Unit/Event/ArrayFilterEventTest.php b/tests/Unit/Event/ArrayFilterEventTest.php index 0e4467c1ed..193ccc77d8 100644 --- a/tests/Unit/Event/ArrayFilterEventTest.php +++ b/tests/Unit/Event/ArrayFilterEventTest.php @@ -32,6 +32,8 @@ class ArrayFilterEventTest extends TestCase [ArrayFilterEvent::POST_LOCAL_START, 'friendica.data.post_local_start'], [ArrayFilterEvent::POST_LOCAL, 'friendica.data.post_local'], [ArrayFilterEvent::POST_LOCAL_END, 'friendica.data.post_local_end'], + [ArrayFilterEvent::INSERT_POST_REMOTE, 'friendica.data.insert_post_remote'], + [ArrayFilterEvent::INSERT_POST_REMOTE_END, 'friendica.data.insert_post_remote_end'], [ArrayFilterEvent::PHOTO_UPLOAD_FORM, 'friendica.data.photo_upload_form'], [ArrayFilterEvent::NETWORK_TO_NAME, 'friendica.data.network_to_name'], [ArrayFilterEvent::CONVERSATION_START, 'friendica.data.conversation_start'],