Merge branch 'accept-embedded-announce-object' into 'develop'
Inline object when Announcing a self-owned private object See merge request pleroma/pleroma!1769
This commit is contained in:
commit
debd0a3066
|
@ -830,6 +830,27 @@ def prepare_outgoing(%{"type" => activity_type, "object" => object_id} = data)
|
||||||
{:ok, data}
|
{:ok, data}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prepare_outgoing(%{"type" => "Announce", "actor" => ap_id, "object" => object_id} = data) do
|
||||||
|
object =
|
||||||
|
object_id
|
||||||
|
|> Object.normalize()
|
||||||
|
|
||||||
|
data =
|
||||||
|
if Visibility.is_private?(object) && object.data["actor"] == ap_id do
|
||||||
|
data |> Map.put("object", object |> Map.get(:data) |> prepare_object)
|
||||||
|
else
|
||||||
|
data |> maybe_fix_object_url
|
||||||
|
end
|
||||||
|
|
||||||
|
data =
|
||||||
|
data
|
||||||
|
|> strip_internal_fields
|
||||||
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
|
|> Map.delete("bcc")
|
||||||
|
|
||||||
|
{:ok, data}
|
||||||
|
end
|
||||||
|
|
||||||
# Mastodon Accept/Reject requires a non-normalized object containing the actor URIs,
|
# Mastodon Accept/Reject requires a non-normalized object containing the actor URIs,
|
||||||
# because of course it does.
|
# because of course it does.
|
||||||
def prepare_outgoing(%{"type" => "Accept"} = data) do
|
def prepare_outgoing(%{"type" => "Accept"} = data) do
|
||||||
|
|
|
@ -1076,6 +1076,20 @@ test "it accepts Flag activities" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "prepare outgoing" do
|
describe "prepare outgoing" do
|
||||||
|
test "it inlines private announced objects" do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey", "visibility" => "private"})
|
||||||
|
|
||||||
|
{:ok, announce_activity, _} = CommonAPI.repeat(activity.id, user)
|
||||||
|
|
||||||
|
{:ok, modified} = Transmogrifier.prepare_outgoing(announce_activity.data)
|
||||||
|
object = modified["object"]
|
||||||
|
|
||||||
|
assert modified["object"]["content"] == "hey"
|
||||||
|
assert modified["object"]["actor"] == modified["object"]["attributedTo"]
|
||||||
|
end
|
||||||
|
|
||||||
test "it turns mentions into tags" do
|
test "it turns mentions into tags" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
|
|
Loading…
Reference in a new issue