From dfc5918c2c66798044fc3eea27494a0863af02a3 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Mon, 28 Mar 2022 21:19:34 +0100 Subject: [PATCH] [PLUGIN][ActivityPub] Federate out Service information in Activities --- plugins/ActivityPub/Util/HTTPSignature.php | 3 ++- plugins/ActivityPub/Util/Model/Activity.php | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/ActivityPub/Util/HTTPSignature.php b/plugins/ActivityPub/Util/HTTPSignature.php index 271c548458..c89a52e7c8 100644 --- a/plugins/ActivityPub/Util/HTTPSignature.php +++ b/plugins/ActivityPub/Util/HTTPSignature.php @@ -30,6 +30,7 @@ namespace Plugin\ActivityPub\Util; use App\Entity\Actor; use DateTime; use Exception; +use Plugin\ActivityPub\ActivityPub; use Plugin\ActivityPub\Entity\ActivitypubRsa; class HTTPSignature @@ -91,7 +92,7 @@ class HTTPSignature 'Date' => $date->format('D, d M Y H:i:s \G\M\T'), 'Host' => parse_url($url, \PHP_URL_HOST), 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams", application/activity+json, application/json', - 'User-Agent' => 'GNU social ActivityPub Plugin - ' . GNUSOCIAL_ENGINE_URL, + 'User-Agent' => 'GNU social ActivityPub Plugin - v' . ActivityPub::version() . ' - ' . GNUSOCIAL_ENGINE_URL, 'Content-Type' => 'application/activity+json', ]; diff --git a/plugins/ActivityPub/Util/Model/Activity.php b/plugins/ActivityPub/Util/Model/Activity.php index 05b6d47f15..0600d7f35b 100644 --- a/plugins/ActivityPub/Util/Model/Activity.php +++ b/plugins/ActivityPub/Util/Model/Activity.php @@ -175,8 +175,12 @@ class Activity extends Model } $attr = [ - 'type' => $gs_verb_to_activity_streams_two_verb, - '@context' => ActivityPub::$activity_streams_two_context, + 'type' => $gs_verb_to_activity_streams_two_verb, + '@context' => ActivityPub::$activity_streams_two_context, + 'instrument' => Type::create('Service', [ + 'name' => 'GNU social ActivityPub Plugin - v' . ActivityPub::version(), + 'url' => GNUSOCIAL_ENGINE_URL, + ]), 'id' => Router::url('activity_view', ['id' => $object->getId()], Router::ABSOLUTE_URL), 'published' => $object->getCreated()->format(DateTimeInterface::RFC3339), 'actor' => $object->getActor()->getUri(Router::ABSOLUTE_URL),