Import object from self-Announce whenever possible

This commit is contained in:
Thibaut Girka 2019-10-02 13:18:51 +02:00
commit 977e711e22
4 changed files with 86 additions and 2 deletions

View file

@ -0,0 +1,35 @@
{
"type": "Announce",
"to": [
"http://mastodon.example.org/users/admin/followers"
],
"published": "2018-02-17T19:39:15Z",
"object": {
"type": "Note",
"id": "http://mastodon.example.org/@admin/99541947525187368",
"attributedTo": "http://mastodon.example.org/users/admin",
"content": "this is a private toot",
"to": [
"http://mastodon.example.org/users/admin/followers"
]
},
"id": "http://mastodon.example.org/users/admin/statuses/99542391527669785/activity",
"atomUri": "http://mastodon.example.org/users/admin/statuses/99542391527669785/activity",
"actor": "http://mastodon.example.org/users/admin",
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"toot": "http://joinmastodon.org/ns#",
"sensitive": "as:sensitive",
"ostatus": "http://ostatus.org#",
"movedTo": "as:movedTo",
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"inReplyToAtomUri": "ostatus:inReplyToAtomUri",
"conversation": "ostatus:conversation",
"atomUri": "ostatus:atomUri",
"Hashtag": "as:Hashtag",
"Emoji": "toot:Emoji"
}
]
}

View file

@ -349,6 +349,14 @@ defmodule HttpRequestMock do
}}
end
def get("http://mastodon.example.org/@admin/99541947525187368", _, _, _) do
{:ok,
%Tesla.Env{
status: 404,
body: ""
}}
end
def get("https://shitposter.club/notice/7369654", _, _, _) do
{:ok,
%Tesla.Env{

View file

@ -442,6 +442,25 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert Activity.get_create_by_object_ap_id(data["object"]).id == activity.id
end
test "it works for incoming announces with an inlined activity" do
data =
File.read!("test/fixtures/mastodon-announce-private.json")
|> Poison.decode!()
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
assert data["actor"] == "http://mastodon.example.org/users/admin"
assert data["type"] == "Announce"
assert data["id"] ==
"http://mastodon.example.org/users/admin/statuses/99542391527669785/activity"
object = Object.normalize(data["object"])
assert object.data["id"] == "http://mastodon.example.org/@admin/99541947525187368"
assert object.data["content"] == "this is a private toot"
end
test "it does not clobber the addressing on announce activities" do
user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
@ -1084,7 +1103,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
{: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"]