mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-23 15:05:45 +00:00
ActivityPub: Add conversation id.
This commit is contained in:
parent
912ca56e59
commit
8ca66b5961
|
@ -104,6 +104,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
|> add_mention_tags
|
|> add_mention_tags
|
||||||
|> add_attributed_to
|
|> add_attributed_to
|
||||||
|> prepare_attachments
|
|> prepare_attachments
|
||||||
|
|> set_conversation
|
||||||
|
|
||||||
data = data
|
data = data
|
||||||
|> Map.put("object", object)
|
|> Map.put("object", object)
|
||||||
|
@ -139,6 +140,10 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
|> Map.put("tag", tags ++ mentions)
|
|> Map.put("tag", tags ++ mentions)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_conversation(object) do
|
||||||
|
Map.put(object, "conversation", object["context"])
|
||||||
|
end
|
||||||
|
|
||||||
def add_attributed_to(object) do
|
def add_attributed_to(object) do
|
||||||
attributedTo = object["attributedTo"] || object["actor"]
|
attributedTo = object["attributedTo"] || object["actor"]
|
||||||
|
|
||||||
|
|
|
@ -120,13 +120,14 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
assert Enum.member?(object["tag"], expected_mention)
|
assert Enum.member?(object["tag"], expected_mention)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it adds the json-ld context" do
|
test "it adds the json-ld context and the conversation property" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
|
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||||
|
|
||||||
assert modified["@context"] == "https://www.w3.org/ns/activitystreams"
|
assert modified["@context"] == "https://www.w3.org/ns/activitystreams"
|
||||||
|
assert modified["object"]["conversation"] == modified["context"]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it sets the 'attributedTo' property to the actor of the object if it doesn't have one" do
|
test "it sets the 'attributedTo' property to the actor of the object if it doesn't have one" do
|
||||||
|
|
Loading…
Reference in a new issue