From 2e89d505d357c17962fdcf48b7ab48ae69ec519e Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 30 Mar 2017 18:07:38 +0200 Subject: [PATCH] Connect attachments with objects, not activities. --- .../web/twitter_api/representers/activity_representer.ex | 2 +- lib/pleroma/web/twitter_api/twitter_api.ex | 6 +++--- .../representers/activity_representer_test.exs | 8 ++++---- test/web/twitter_api/twitter_api_test.exs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex index bcb819200..0cf20dc45 100644 --- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -17,7 +17,7 @@ def to_map(%Activity{} = activity, %{user: user} = opts) do "created_at" => published, "in_reply_to_status_id" => activity.data["object"]["inReplyToStatusId"], "statusnet_conversation_id" => activity.data["object"]["statusnetConversationId"], - "attachments" => (activity.data["attachment"] || []) |> ObjectRepresenter.enum_to_list(opts) + "attachments" => (activity.data["object"]["attachment"] || []) |> ObjectRepresenter.enum_to_list(opts) } end end diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index ab2b1aab7..c07c7cfbf 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -24,11 +24,11 @@ def create_status(user = %User{}, data = %{}) do "type" => "Note", "content" => data["status"], "published" => date, - "context" => context + "context" => context, + "attachment" => attachments }, "published" => date, - "context" => context, - "attachment" => attachments + "context" => context } # Wire up reply info. diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs index 96e6dc98e..91300f229 100644 --- a/test/web/twitter_api/representers/activity_representer_test.exs +++ b/test/web/twitter_api/representers/activity_representer_test.exs @@ -33,16 +33,16 @@ test "an activity" do User.ap_followers(user), "https://www.w3.org/ns/activitystreams#Public" ], - "attachment" => [ - object - ], "actor" => User.ap_id(user), "object" => %{ "published" => date, "type" => "Note", "content" => content, "inReplyToStatusId" => 213123, - "statusnetConversationId" => 4711 + "statusnetConversationId" => 4711, + "attachment" => [ + object + ] }, "published" => date } diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 97657eae0..8d123ff4e 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -40,7 +40,7 @@ test "create a status" do assert get_in(activity.data, ["object", "statusnetConversationId"]) == activity.id assert get_in(activity.data, ["statusnetConversationId"]) == activity.id - assert is_list(activity.data["attachment"]) + assert is_list(activity.data["object"]["attachment"]) end test "create a status that is a reply" do