[PLUGINS][Favourite][RepeatNote][DeleteNote][WebMonetization] Make use of 'activitypub_handler' more readable
This commit is contained in:
parent
9a9eed1457
commit
0ce5eba355
@ -200,6 +200,7 @@ class DeleteNote extends NoteHandlerPlugin
|
|||||||
{
|
{
|
||||||
if ($type_activity->get('type') !== 'Delete'
|
if ($type_activity->get('type') !== 'Delete'
|
||||||
|| !($type_object instanceof Note)) {
|
|| !($type_object instanceof Note)) {
|
||||||
|
// Don't care about AbstractObject because we only want to delete objects we already have
|
||||||
return Event::next;
|
return Event::next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,6 +280,7 @@ class Favourite extends NoteHandlerPlugin
|
|||||||
if (!\in_array($type_activity->get('type'), ['Like', 'Undo'])) {
|
if (!\in_array($type_activity->get('type'), ['Like', 'Undo'])) {
|
||||||
return Event::next;
|
return Event::next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type_activity->get('type') === 'Like') { // Favourite
|
if ($type_activity->get('type') === 'Like') { // Favourite
|
||||||
if ($type_object instanceof \ActivityPhp\Type\AbstractObject) {
|
if ($type_object instanceof \ActivityPhp\Type\AbstractObject) {
|
||||||
if ($type_object->get('type') === 'Note' || $type_object->get('type') === 'ChatMessage' || $type_object->get('type') === 'Page') {
|
if ($type_object->get('type') === 'Note' || $type_object->get('type') === 'ChatMessage' || $type_object->get('type') === 'Page') {
|
||||||
@ -293,7 +294,9 @@ class Favourite extends NoteHandlerPlugin
|
|||||||
} else {
|
} else {
|
||||||
return Event::next;
|
return Event::next;
|
||||||
}
|
}
|
||||||
} elseif ($type_object instanceof \ActivityPhp\Type\AbstractObject) {
|
$activity = self::favourNote($note_id, $actor->getId(), source: 'ActivityPub');
|
||||||
|
} elseif ($type_activity->get('type') === 'Undo') {
|
||||||
|
if ($type_object instanceof \ActivityPhp\Type\AbstractObject) {
|
||||||
$ap_prev_favourite_act = \Plugin\ActivityPub\Util\Model\Activity::fromJson($type_object);
|
$ap_prev_favourite_act = \Plugin\ActivityPub\Util\Model\Activity::fromJson($type_object);
|
||||||
$prev_favourite_act = $ap_prev_favourite_act->getActivity();
|
$prev_favourite_act = $ap_prev_favourite_act->getActivity();
|
||||||
if ($prev_favourite_act->getVerb() === 'favourite' && $prev_favourite_act->getObjectType() === 'note') {
|
if ($prev_favourite_act->getVerb() === 'favourite' && $prev_favourite_act->getObjectType() === 'note') {
|
||||||
@ -310,12 +313,11 @@ class Favourite extends NoteHandlerPlugin
|
|||||||
} else {
|
} else {
|
||||||
return Event::next;
|
return Event::next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type_activity->get('type') === 'Like') {
|
|
||||||
$activity = self::favourNote($note_id, $actor->getId(), source: 'ActivityPub');
|
|
||||||
} else {
|
|
||||||
$activity = self::unfavourNote($note_id, $actor->getId(), source: 'ActivityPub');
|
$activity = self::unfavourNote($note_id, $actor->getId(), source: 'ActivityPub');
|
||||||
|
} else {
|
||||||
|
return Event::next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\is_null($activity)) {
|
if (!\is_null($activity)) {
|
||||||
// Store ActivityPub Activity
|
// Store ActivityPub Activity
|
||||||
$ap_act = \Plugin\ActivityPub\Entity\ActivitypubActivity::create([
|
$ap_act = \Plugin\ActivityPub\Entity\ActivitypubActivity::create([
|
||||||
|
@ -376,7 +376,8 @@ class RepeatNote extends NoteHandlerPlugin
|
|||||||
} else {
|
} else {
|
||||||
return Event::next;
|
return Event::next;
|
||||||
}
|
}
|
||||||
} else { // Undo Repeat
|
$activity = self::repeatNote($note ?? Note::getById($note_id), $actor->getId(), source: 'ActivityPub');
|
||||||
|
} elseif ($type_activity->get('type') === 'Undo') { // Undo Repeat
|
||||||
if ($type_object instanceof \ActivityPhp\Type\AbstractObject) {
|
if ($type_object instanceof \ActivityPhp\Type\AbstractObject) {
|
||||||
$ap_prev_repeat_act = \Plugin\ActivityPub\Util\Model\Activity::fromJson($type_object);
|
$ap_prev_repeat_act = \Plugin\ActivityPub\Util\Model\Activity::fromJson($type_object);
|
||||||
$prev_repeat_act = $ap_prev_repeat_act->getActivity();
|
$prev_repeat_act = $ap_prev_repeat_act->getActivity();
|
||||||
@ -394,13 +395,11 @@ class RepeatNote extends NoteHandlerPlugin
|
|||||||
} else {
|
} else {
|
||||||
return Event::next;
|
return Event::next;
|
||||||
}
|
}
|
||||||
|
$activity = self::unrepeatNote($note_id, $actor->getId(), source: 'ActivityPub');
|
||||||
|
} else {
|
||||||
|
return Event::next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type_activity->get('type') === 'Announce') {
|
|
||||||
$activity = self::repeatNote($note ?? Note::getById($note_id), $actor->getId(), source: 'ActivityPub');
|
|
||||||
} else {
|
|
||||||
$activity = self::unrepeatNote($note_id, $actor->getId(), source: 'ActivityPub');
|
|
||||||
}
|
|
||||||
if (!\is_null($activity)) {
|
if (!\is_null($activity)) {
|
||||||
// Store ActivityPub Activity
|
// Store ActivityPub Activity
|
||||||
$ap_act = \Plugin\ActivityPub\Entity\ActivitypubActivity::create([
|
$ap_act = \Plugin\ActivityPub\Entity\ActivitypubActivity::create([
|
||||||
|
@ -258,7 +258,7 @@ class WebMonetization extends Plugin
|
|||||||
$wallet = DB::findOneBy(Wallet::class, ['actor_id' => $actor->getId()], return_null: true);
|
$wallet = DB::findOneBy(Wallet::class, ['actor_id' => $actor->getId()], return_null: true);
|
||||||
|
|
||||||
if (!\is_null($address = $wallet?->getAddress())) {
|
if (!\is_null($address = $wallet?->getAddress())) {
|
||||||
$type->set('gs:webmonetizationWallet', $address);
|
$type->set('webmonetizationWallet', $address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Event::next;
|
return Event::next;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user