[PLUGIN][ActivityPub][Notification] Fix some issues with targetting
This commit is contained in:
parent
e63c310d70
commit
56b8710b26
@ -143,9 +143,9 @@ class ActivityPub extends Plugin
|
|||||||
);
|
);
|
||||||
|
|
||||||
DB::flush();
|
DB::flush();
|
||||||
if ($ap_act->getToNotifyTargets() !== []) {
|
if (($att_targets = $ap_act->getAttentionTargets()) !== []) {
|
||||||
if (Event::handle('ActivityPubNewNotification', [$actor, $ap_act->getActivity(), $ap_act->getAttentionTargets(), _m('{actor_id} triggered a notification via ActivityPub.', ['{actor_id}' => $actor->getId()])]) === Event::next) {
|
if (Event::handle('ActivityPubNewNotification', [$actor, ($act = $ap_act->getActivity()), $att_targets, _m('{actor_id} triggered a notification via ActivityPub.', ['{actor_id}' => $actor->getId()])]) === Event::next) {
|
||||||
Event::handle('NewNotification', [$actor, $ap_act->getActivity(), $ap_act->getAttentionTargets(), _m('{actor_id} triggered a notification via ActivityPub.', ['{nickname}' => $actor->getId()])]);
|
Event::handle('NewNotification', [$actor, $act, $att_targets, _m('{actor_id} triggered a notification via ActivityPub.', ['{nickname}' => $actor->getId()])]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +115,16 @@ class ActivitypubObject extends Entity
|
|||||||
return DB::findOneBy($this->getObjectType(), ['id' => $this->getObjectId()]);
|
return DB::findOneBy($this->getObjectType(), ['id' => $this->getObjectId()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAttentionTargetIds(): array
|
||||||
|
{
|
||||||
|
return $this->getObject()->getAttentionTargetIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttentionTargets(): array
|
||||||
|
{
|
||||||
|
return $this->getObject()->getAttentionTargets();
|
||||||
|
}
|
||||||
|
|
||||||
public static function schemaDef(): array
|
public static function schemaDef(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -78,7 +78,7 @@ class Favourite extends FeedController
|
|||||||
if ($form_add_to_favourite->isSubmitted()) {
|
if ($form_add_to_favourite->isSubmitted()) {
|
||||||
if (!\is_null($activity = \Plugin\Favourite\Favourite::favourNote(note_id: $id, actor_id: $actor_id))) {
|
if (!\is_null($activity = \Plugin\Favourite\Favourite::favourNote(note_id: $id, actor_id: $actor_id))) {
|
||||||
DB::flush();
|
DB::flush();
|
||||||
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $activity, [], _m('{actor_id} favoured note {note_id}.', ['{actor_id}' => $actor->getId(), '{note_id}' => $activity->getObjectId()])]);
|
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $activity, $activity->getAttentionTargets(), _m('{actor_id} favoured note {note_id}.', ['{actor_id}' => $actor->getId(), '{note_id}' => $activity->getObjectId()])]);
|
||||||
} else {
|
} else {
|
||||||
throw new ClientException(_m('Note already favoured!'));
|
throw new ClientException(_m('Note already favoured!'));
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ class Favourite extends FeedController
|
|||||||
if ($form_remove_favourite->isSubmitted()) {
|
if ($form_remove_favourite->isSubmitted()) {
|
||||||
if (!\is_null($activity = \Plugin\Favourite\Favourite::unfavourNote(note_id: $id, actor_id: $actor_id))) {
|
if (!\is_null($activity = \Plugin\Favourite\Favourite::unfavourNote(note_id: $id, actor_id: $actor_id))) {
|
||||||
DB::flush();
|
DB::flush();
|
||||||
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $activity, [], _m('{actor_id} unfavoured note {note_id}.', ['{actor_id}' => $actor->getId(), '{note_id}' => $activity->getObjectId()])]);
|
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $activity, $activity->getAttentionTargets(), _m('{actor_id} unfavoured note {note_id}.', ['{actor_id}' => $actor->getId(), '{note_id}' => $activity->getObjectId()])]);
|
||||||
} else {
|
} else {
|
||||||
throw new ClientException(_m('Note already unfavoured!'));
|
throw new ClientException(_m('Note already unfavoured!'));
|
||||||
}
|
}
|
||||||
|
@ -110,11 +110,11 @@ class NoteFavourite extends Entity
|
|||||||
self::cacheKeys($note)['favourites-actors'],
|
self::cacheKeys($note)['favourites-actors'],
|
||||||
fn () => DB::dql(
|
fn () => DB::dql(
|
||||||
<<<'EOF'
|
<<<'EOF'
|
||||||
select a from actor a
|
SELECT a FROM actor AS a
|
||||||
inner join note_favourite nf
|
INNER JOIN note_favourite AS nf
|
||||||
with a.id = nf.actor_id
|
WITH a.id = nf.actor_id
|
||||||
where nf.note_id = :note_id
|
WHERE nf.note_id = :note_id
|
||||||
order by nf.created DESC
|
ORDER BY nf.created DESC
|
||||||
EOF,
|
EOF,
|
||||||
['note_id' => $note->getId()],
|
['note_id' => $note->getId()],
|
||||||
),
|
),
|
||||||
|
@ -75,7 +75,7 @@ class Repeat extends Controller
|
|||||||
if ($form_add_to_repeat->isSubmitted()) {
|
if ($form_add_to_repeat->isSubmitted()) {
|
||||||
$repeat_activity = \Plugin\RepeatNote\RepeatNote::repeatNote(note: $note, actor_id: $actor_id);
|
$repeat_activity = \Plugin\RepeatNote\RepeatNote::repeatNote(note: $note, actor_id: $actor_id);
|
||||||
DB::flush();
|
DB::flush();
|
||||||
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $repeat_activity, [], _m('{actor_id} repeated note {note_id}.', ['{actor_id}' => $actor->getId(), '{note_id}' => $repeat_activity->getObjectId()])]);
|
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $repeat_activity, $repeat_activity->getAttentionTargets(), _m('{actor_id} repeated note {note_id}.', ['{actor_id}' => $actor->getId(), '{note_id}' => $repeat_activity->getObjectId()])]);
|
||||||
|
|
||||||
// Redirect user to where they came from
|
// Redirect user to where they came from
|
||||||
// Prevent open redirect
|
// Prevent open redirect
|
||||||
@ -132,7 +132,7 @@ class Repeat extends Controller
|
|||||||
if ($form_remove_repeat->isSubmitted()) {
|
if ($form_remove_repeat->isSubmitted()) {
|
||||||
if (!\is_null($undo_repeat_activity = \Plugin\RepeatNote\RepeatNote::unrepeatNote(note_id: $note_id, actor_id: $actor_id))) {
|
if (!\is_null($undo_repeat_activity = \Plugin\RepeatNote\RepeatNote::unrepeatNote(note_id: $note_id, actor_id: $actor_id))) {
|
||||||
DB::flush();
|
DB::flush();
|
||||||
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $undo_repeat_activity, [], _m('{actor_id} unrepeated note {note_id}.', ['{actor_id}' => $actor->getId(), '{note_id}' => $note_id])]);
|
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $undo_repeat_activity, $undo_repeat_activity->getAttentionTargets(), _m('{actor_id} unrepeated note {note_id}.', ['{actor_id}' => $actor->getId(), '{note_id}' => $note_id])]);
|
||||||
} else {
|
} else {
|
||||||
throw new ClientException(_m('Note wasn\'t repeated!'));
|
throw new ClientException(_m('Note wasn\'t repeated!'));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user