From: lain Date: Sun, 18 Feb 2018 12:58:52 +0000 (+0100) Subject: ActivityPub: Add conversation id. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=8ca66b596120024b5141ce68c7614e762358c2a1;p=akkoma ActivityPub: Add conversation id. --- diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 3781b212a..17cd3b1c2 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -104,6 +104,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do |> add_mention_tags |> add_attributed_to |> prepare_attachments + |> set_conversation data = data |> Map.put("object", object) @@ -139,6 +140,10 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do |> Map.put("tag", tags ++ mentions) end + def set_conversation(object) do + Map.put(object, "conversation", object["context"]) + end + def add_attributed_to(object) do attributedTo = object["attributedTo"] || object["actor"] diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index e2db615eb..ec608a86a 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -120,13 +120,14 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do assert Enum.member?(object["tag"], expected_mention) end - test "it adds the json-ld context" do + test "it adds the json-ld context and the conversation property" do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "hey"}) {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data) assert modified["@context"] == "https://www.w3.org/ns/activitystreams" + assert modified["object"]["conversation"] == modified["context"] end test "it sets the 'attributedTo' property to the actor of the object if it doesn't have one" do