From 7a47afed3c52f537e9a4851372d76ccf95459799 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Fri, 14 Apr 2017 18:59:11 +0200 Subject: [PATCH] Update object correctly after setting context. --- lib/pleroma/web/twitter_api/twitter_api.ex | 5 +++++ test/web/twitter_api/twitter_api_test.exs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index a23f465d4..76dbc77a1 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -204,6 +204,11 @@ defp add_conversation_id(activity) do |> put_in(["object", "statusnetConversationId"], activity.id) |> put_in(["statusnetConversationId"], activity.id) + object = Object.get_by_ap_id(activity.data["object"]["id"]) + + changeset = Ecto.Changeset.change(object, data: data["object"]) + Repo.update(changeset) + changeset = Ecto.Changeset.change(activity, data: data) Repo.update(changeset) end diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 36d4f4012..fd9908b9f 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -48,6 +48,8 @@ test "create a status" do assert get_in(activity.data, ["statusnetConversationId"]) == activity.id assert is_list(activity.data["object"]["attachment"]) + + assert activity.data["object"] == Object.get_by_ap_id(activity.data["object"]["id"]).data end test "create a status that is a reply" do