[ActivityPub][QUEUES] Handle Create (AS1 POST) verb properly

Fixes a bug introduced in e504d13120
This commit is contained in:
t3nma 2020-08-03 18:21:47 +01:00 committed by Diogo Peralta Cordeiro
parent caac2cea44
commit 119783f80e

View File

@ -73,6 +73,11 @@ class ActivityPubQueueHandler extends QueueHandler
$notice->getAttentionProfiles()
);
// Handling a Create?
if (ActivityUtils::compareVerbs($notice->verb, [ActivityVerb::POST])) {
return $this->handle_create($profile, $notice, $other);
}
// Handling a Like?
if (ActivityUtils::compareVerbs($notice->verb, [ActivityVerb::FAVORITE])) {
return $this->onEndFavorNotice($profile, $notice, $other);
@ -88,21 +93,13 @@ class ActivityPubQueueHandler extends QueueHandler
return $this->onStartDeleteOwnNotice($profile, $notice, $other);
}
// Handling a reply?
if ($notice->reply_to) {
return $this->handle_reply($profile, $notice, $other);
}
// Handling an Announce?
if ($notice->isRepeat()) {
return $this->handle_announce($profile, $notice, $other);
}
return true;
}
private function handle_reply($profile, $notice, $other)
private function handle_create($profile, $notice, $other)
{
// Handling a reply?
if ($notice->reply_to) {
try {
$parent_notice = $notice->getParent();
@ -123,17 +120,15 @@ class ActivityPubQueueHandler extends QueueHandler
// This is not a reply to something (has no parent)
} catch (NoResultException $e) {
// Parent author's profile not found! Complain louder?
common_log(LOG_ERR, "Parent notice's author not found: ".$e->getMessage());
common_log(
LOG_ERR,
"Parent notice's author not found: " . $e->getMessage()
);
}
}
// That was it
$postman = new Activitypub_postman($profile, $other);
$postman->create_note($notice);
return true;
}
private function handle_announce($profile, $notice, $other)
{
// Handling an Announce?
if ($notice->isRepeat()) {
$repeated_notice = Notice::getKV('id', $notice->repeat_of);
if ($repeated_notice instanceof Notice) {
$other = array_merge(
@ -144,7 +139,9 @@ class ActivityPubQueueHandler extends QueueHandler
);
try {
$other[] = Activitypub_profile::from_profile($repeated_notice->getProfile());
$other[] = Activitypub_profile::from_profile(
$repeated_notice->getProfile()
);
} catch (Exception $e) {
// Local user can be ignored
}
@ -158,6 +155,12 @@ class ActivityPubQueueHandler extends QueueHandler
return true;
}
// That was it
$postman = new Activitypub_postman($profile, $other);
$postman->create_note($notice);
return true;
}
/**
* Notify remote users when their notices get favourited.
*