Commit 8ca66b59 authored by lain's avatar lain
Browse files

ActivityPub: Add conversation id.

parent 912ca56e
......@@ -104,6 +104,7 @@ def prepare_outgoing(%{"type" => "Create", "object" => %{"type" => "Note"} = obj
|> add_mention_tags
|> add_attributed_to
|> prepare_attachments
|> set_conversation
data = data
|> Map.put("object", object)
......@@ -139,6 +140,10 @@ def add_mention_tags(object) 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"]
......
......@@ -120,13 +120,14 @@ test "it turns mentions into tags" 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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment