From 300c4e3d04a7b0ac2b26047c4152713536d4ab37 Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Thu, 27 Aug 2020 02:14:47 +0100 Subject: [PATCH] [ActivityPub] Revert moving Disfavor to Queues It seems this kind of notice isn't queued? --- plugins/ActivityPub/ActivityPubPlugin.php | 59 +++++++++++++++++++ .../lib/activitypubqueuehandler.php | 47 --------------- 2 files changed, 59 insertions(+), 47 deletions(-) diff --git a/plugins/ActivityPub/ActivityPubPlugin.php b/plugins/ActivityPub/ActivityPubPlugin.php index 2939a3a0c3..5744e55bfe 100644 --- a/plugins/ActivityPub/ActivityPubPlugin.php +++ b/plugins/ActivityPub/ActivityPubPlugin.php @@ -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 + */ + 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 * diff --git a/plugins/ActivityPub/lib/activitypubqueuehandler.php b/plugins/ActivityPub/lib/activitypubqueuehandler.php index d0d3ff3945..54074f9f1e 100644 --- a/plugins/ActivityPub/lib/activitypubqueuehandler.php +++ b/plugins/ActivityPub/lib/activitypubqueuehandler.php @@ -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 - */ - 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 *