From 6b6ab592ab18f8db68431e74a4ec4c785d394756 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 19 Feb 2018 10:39:03 +0100 Subject: [PATCH] AP: Fix incoming conversations. --- lib/pleroma/web/activity_pub/transmogrifier.ex | 9 ++++++++- test/web/activity_pub/transmogrifier_test.exs | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 076bd2ea8..075250aa5 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -14,6 +14,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do object |> Map.put("actor", object["attributedTo"]) |> fix_attachments + |> fix_context + end + + def fix_context(object) do + object + |> Map.put("context", object["conversation"]) end def fix_attachments(object) do @@ -130,7 +136,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do end def add_mention_tags(object) do - mentions = object["to"] + recipients = object["to"] ++ (object["cc"] || []) + mentions = recipients |> Enum.map(fn (ap_id) -> User.get_cached_by_ap_id(ap_id) end) |> Enum.filter(&(&1)) |> Enum.map(fn(user) -> %{"type" => "Mention", "href" => user.ap_id, "name" => "@#{user.nickname}"} end) diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 08f8e8206..45e284157 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -33,6 +33,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do ] assert object["actor"] == "http://mastodon.example.org/users/admin" assert object["attributedTo"] == "http://mastodon.example.org/users/admin" + assert object["context"] == "tag:mastodon.example.org,2018-02-12:objectId=20:objectType=Conversation" assert object["sensitive"] == true end @@ -111,6 +112,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do "name" => "@#{other_user.nickname}", "type" => "Mention" } + expected_tag = %{ "href" => Pleroma.Web.Endpoint.url <> "/tags/2hu", "type" => "Hashtag", -- 2.45.2