[ActivityPub] Revert moving Disfavor to Queues

It seems this kind of notice isn't queued?
This commit is contained in:
Diogo Cordeiro 2020-08-27 02:14:47 +01:00 committed by Diogo Peralta Cordeiro
parent 5f35d9633d
commit 300c4e3d04
2 changed files with 59 additions and 47 deletions

View File

@ -849,6 +849,65 @@ class ActivityPubPlugin extends Plugin
return true;
}
/**
* Notify remote users when their notices get de-favourited.
*
* @param Profile $profile of local user doing the de-faving
* @param Notice $notice Notice being favored
* @return bool return value
* @throws HTTP_Request2_Exception
* @throws InvalidUrlException
* @author Diogo Cordeiro <diogo@fc.up.pt>
*/
public function onEndDisfavorNotice(Profile $profile, Notice $notice)
{
// Only distribute local users' favor actions, remote users
// will have already distributed theirs.
if (!$profile->isLocal()) {
return true;
}
$other = [];
try {
$other[] = Activitypub_profile::from_profile($notice->getProfile());
} catch (Exception $e) {
// Local user can be ignored
}
$other = array_merge($other,
Activitypub_profile::from_profile_collection(
$notice->getAttentionProfiles()
));
if ($notice->reply_to) {
try {
$parent_notice = $notice->getParent();
try {
$other[] = Activitypub_profile::from_profile($parent_notice->getProfile());
} catch (Exception $e) {
// Local user can be ignored
}
$other = array_merge($other,
Activitypub_profile::from_profile_collection(
$parent_notice->getAttentionProfiles()
));
} catch (NoParentNoticeException $e) {
// 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());
}
}
$postman = new Activitypub_postman($profile, $other);
$postman->undo_like($notice);
return true;
}
/**
* Notify remote followers when a user gets deleted
*

View File

@ -83,11 +83,6 @@ class ActivityPubQueueHandler extends QueueHandler
return $this->onEndFavorNotice($profile, $notice, $other);
}
// Handling a Undo Like?
if (ActivityUtils::compareVerbs($notice->verb, [ActivityVerb::UNFAVORITE])) {
return $this->onEndDisfavorNotice($profile, $notice, $other);
}
// Handling a Delete Note?
if (ActivityUtils::compareVerbs($notice->verb, [ActivityVerb::DELETE])) {
return $this->onStartDeleteOwnNotice($profile, $notice, $other);
@ -204,48 +199,6 @@ class ActivityPubQueueHandler extends QueueHandler
return true;
}
/**
* Notify remote users when their notices get de-favourited.
*
* @param Profile $profile of local user doing the de-faving
* @param Notice $notice Notice being favored
* @return bool return value
* @throws HTTP_Request2_Exception
* @throws InvalidUrlException
* @author Diogo Cordeiro <diogo@fc.up.pt>
*/
public function onEndDisfavorNotice(Profile $profile, Notice $notice, $other)
{
if ($notice->reply_to) {
try {
$parent_notice = $notice->getParent();
try {
$other[] = Activitypub_profile::from_profile($parent_notice->getProfile());
} catch (Exception $e) {
// Local user can be ignored
}
$other = array_merge(
$other,
Activitypub_profile::from_profile_collection(
$parent_notice->getAttentionProfiles()
)
);
} catch (NoParentNoticeException $e) {
// 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());
}
}
$postman = new Activitypub_postman($profile, $other);
$postman->undo_like($notice);
return true;
}
/**
* Notify remote users when their notices get deleted
*