mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-07 20:04:32 +02:00
Create events for post_remote and post_remote_end hook
This commit is contained in:
parent
abe35732d8
commit
9aeb68231d
6 changed files with 22 additions and 3 deletions
|
@ -46,6 +46,8 @@ final class HookEventBridge
|
||||||
ArrayFilterEvent::POST_LOCAL_START => 'post_local_start',
|
ArrayFilterEvent::POST_LOCAL_START => 'post_local_start',
|
||||||
ArrayFilterEvent::POST_LOCAL => 'post_local',
|
ArrayFilterEvent::POST_LOCAL => 'post_local',
|
||||||
ArrayFilterEvent::POST_LOCAL_END => 'post_local_end',
|
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::PHOTO_UPLOAD_FORM => 'photo_upload_form',
|
||||||
ArrayFilterEvent::NETWORK_TO_NAME => 'network_to_name',
|
ArrayFilterEvent::NETWORK_TO_NAME => 'network_to_name',
|
||||||
ArrayFilterEvent::CONVERSATION_START => 'conversation_start',
|
ArrayFilterEvent::CONVERSATION_START => 'conversation_start',
|
||||||
|
@ -102,6 +104,8 @@ final class HookEventBridge
|
||||||
ArrayFilterEvent::POST_LOCAL_START => 'onArrayFilterEvent',
|
ArrayFilterEvent::POST_LOCAL_START => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::POST_LOCAL => 'onArrayFilterEvent',
|
ArrayFilterEvent::POST_LOCAL => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::POST_LOCAL_END => 'onArrayFilterEvent',
|
ArrayFilterEvent::POST_LOCAL_END => 'onArrayFilterEvent',
|
||||||
|
ArrayFilterEvent::INSERT_POST_REMOTE => 'onArrayFilterEvent',
|
||||||
|
ArrayFilterEvent::INSERT_POST_REMOTE_END => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::PHOTO_UPLOAD_FORM => 'onArrayFilterEvent',
|
ArrayFilterEvent::PHOTO_UPLOAD_FORM => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::NETWORK_TO_NAME => 'onArrayFilterEvent',
|
ArrayFilterEvent::NETWORK_TO_NAME => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::CONVERSATION_START => 'onArrayFilterEvent',
|
ArrayFilterEvent::CONVERSATION_START => 'onArrayFilterEvent',
|
||||||
|
|
|
@ -30,6 +30,10 @@ final class ArrayFilterEvent extends Event
|
||||||
|
|
||||||
public const POST_LOCAL_END = 'friendica.data.post_local_end';
|
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 PHOTO_UPLOAD_FORM = 'friendica.data.photo_upload_form';
|
||||||
|
|
||||||
public const NETWORK_TO_NAME = 'friendica.data.network_to_name';
|
public const NETWORK_TO_NAME = 'friendica.data.network_to_name';
|
||||||
|
|
|
@ -9,7 +9,6 @@ namespace Friendica\Model;
|
||||||
|
|
||||||
use Friendica\Content\Feature;
|
use Friendica\Content\Feature;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Hook;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
|
|
@ -855,7 +855,9 @@ class Item
|
||||||
unset($_SESSION['uid']);
|
unset($_SESSION['uid']);
|
||||||
}
|
}
|
||||||
} elseif (!$notify) {
|
} elseif (!$notify) {
|
||||||
Hook::callAll('post_remote', $item);
|
$item = $eventDispatcher->dispatch(
|
||||||
|
new ArrayFilterEvent(ArrayFilterEvent::INSERT_POST_REMOTE, $item)
|
||||||
|
)->getArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($item['cancel'])) {
|
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']);
|
DI::contentItem()->copyPermissions($posted_item['thr-parent-id'], $posted_item['uri-id'], $posted_item['parent-uri-id']);
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
if ($posted_item['gravity'] === self::GRAVITY_PARENT) {
|
||||||
|
|
|
@ -35,6 +35,8 @@ class HookEventBridgeTest extends TestCase
|
||||||
ArrayFilterEvent::POST_LOCAL_START => 'onArrayFilterEvent',
|
ArrayFilterEvent::POST_LOCAL_START => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::POST_LOCAL => 'onArrayFilterEvent',
|
ArrayFilterEvent::POST_LOCAL => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::POST_LOCAL_END => 'onArrayFilterEvent',
|
ArrayFilterEvent::POST_LOCAL_END => 'onArrayFilterEvent',
|
||||||
|
ArrayFilterEvent::INSERT_POST_REMOTE => 'onArrayFilterEvent',
|
||||||
|
ArrayFilterEvent::INSERT_POST_REMOTE_END => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::PHOTO_UPLOAD_FORM => 'onArrayFilterEvent',
|
ArrayFilterEvent::PHOTO_UPLOAD_FORM => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::NETWORK_TO_NAME => 'onArrayFilterEvent',
|
ArrayFilterEvent::NETWORK_TO_NAME => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::CONVERSATION_START => 'onArrayFilterEvent',
|
ArrayFilterEvent::CONVERSATION_START => 'onArrayFilterEvent',
|
||||||
|
@ -314,6 +316,8 @@ class HookEventBridgeTest extends TestCase
|
||||||
[ArrayFilterEvent::POST_LOCAL_START, 'post_local_start'],
|
[ArrayFilterEvent::POST_LOCAL_START, 'post_local_start'],
|
||||||
[ArrayFilterEvent::POST_LOCAL, 'post_local'],
|
[ArrayFilterEvent::POST_LOCAL, 'post_local'],
|
||||||
[ArrayFilterEvent::POST_LOCAL_END, 'post_local_end'],
|
[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::PHOTO_UPLOAD_FORM, 'photo_upload_form'],
|
||||||
[ArrayFilterEvent::NETWORK_TO_NAME, 'network_to_name'],
|
[ArrayFilterEvent::NETWORK_TO_NAME, 'network_to_name'],
|
||||||
[ArrayFilterEvent::CONVERSATION_START, 'conversation_start'],
|
[ArrayFilterEvent::CONVERSATION_START, 'conversation_start'],
|
||||||
|
|
|
@ -32,6 +32,8 @@ class ArrayFilterEventTest extends TestCase
|
||||||
[ArrayFilterEvent::POST_LOCAL_START, 'friendica.data.post_local_start'],
|
[ArrayFilterEvent::POST_LOCAL_START, 'friendica.data.post_local_start'],
|
||||||
[ArrayFilterEvent::POST_LOCAL, 'friendica.data.post_local'],
|
[ArrayFilterEvent::POST_LOCAL, 'friendica.data.post_local'],
|
||||||
[ArrayFilterEvent::POST_LOCAL_END, 'friendica.data.post_local_end'],
|
[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::PHOTO_UPLOAD_FORM, 'friendica.data.photo_upload_form'],
|
||||||
[ArrayFilterEvent::NETWORK_TO_NAME, 'friendica.data.network_to_name'],
|
[ArrayFilterEvent::NETWORK_TO_NAME, 'friendica.data.network_to_name'],
|
||||||
[ArrayFilterEvent::CONVERSATION_START, 'friendica.data.conversation_start'],
|
[ArrayFilterEvent::CONVERSATION_START, 'friendica.data.conversation_start'],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue