関数「create_notice」の中で、引数の「$object」がすでに DB にある場合、処理を中断します。
plugins/ActivityPub/lib/models/Activitypub_notice.php
diff --git a/plugins/ActivityPub/lib/models/Activitypub_notice.php b/plugins/ActivityPub/lib/models/Activitypub_notice.php index 14b4c3eae2..e66d263c23 100644 --- a/plugins/ActivityPub/lib/models/Activitypub_notice.php +++ b/plugins/ActivityPub/lib/models/Activitypub_notice.php @@ -150,6 +150,12 @@ class Activitypub_notice $url = isset($object['url']) ? $object['url'] : $id; // string $content = $object['content']; // string + // Avoid duplication + if (is_numeric($id) && Notice::getByID((int)$id)) { + common_debug('create_notice: not found $id' . $id); + return null; + } + // possible keys: ['inReplyTo', 'latitude', 'longitude'] $settings = []; if (isset($object['inReplyTo'])) {
関数「like_to_array」の中のメソッド「getParent」の呼び出しに条件をつけました。修正前は「いいね解除」に「getParent」を呼び出すと、処理が終了する様でした。
plugins/ActivityPub/lib/models/Activitypub_like.php
diff --git a/plugins/ActivityPub/lib/models/Activitypub_like.php b/plugins/ActivityPub/lib/models/Activitypub_like.php index 147025b29c..f8fb929d51 100644 --- a/plugins/ActivityPub/lib/models/Activitypub_like.php +++ b/plugins/ActivityPub/lib/models/Activitypub_like.php @@ -46,12 +46,18 @@ class Activitypub_like */ public static function like_to_array(string $actor, Notice $notice): array { + if ($notice->hasParent() && Notice::getByID($notice->reply_to)) { + $object = Activitypub_notice::getUri($notice->getParent()); + } else { + // When unlike. + $object = Activitypub_notice::getUri($notice); + } $res = [ '@context' => 'https://www.w3.org/ns/activitystreams', 'id' => Activitypub_notice::getUri($notice), 'type' => 'Like', 'actor' => $actor, - 'object' => Activitypub_notice::getUri($notice->getParent()), + 'object' => $object, ]; return $res; }
関数「handle_undo_like」内で「grab_notice_from_url」に渡す URL を変更しました。
plugins/ActivityPub/lib/inbox_handler.php
diff --git a/plugins/ActivityPub/lib/inbox_handler.php b/plugins/ActivityPub/lib/inbox_handler.php index bbc28c6aad..2e6048d332 100644 --- a/plugins/ActivityPub/lib/inbox_handler.php +++ b/plugins/ActivityPub/lib/inbox_handler.php @@ -391,7 +391,9 @@ class Activitypub_inbox_handler */ private function handle_undo_like() { - $notice = ActivityPubPlugin::grab_notice_from_url($this->activity['id']); + $object = $this->activity['object']; + $notice_url = $object['object']; + $notice = ActivityPubPlugin::grab_notice_from_url($notice_url); Fave::removeEntry($this->actor, $notice); }