From b8912ff954a0aa6426eb2205da82db8bee6c5a6a Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 10 Sep 2017 17:20:53 +0200 Subject: [PATCH] Fix masto api context. --- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 900f9e3da..1aa7f43ab 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -64,10 +64,11 @@ def get_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do def get_context(%{assigns: %{user: user}} = conn, %{"id" => id}) do with %Activity{} = activity <- Repo.get(Activity, id), activities <- ActivityPub.fetch_activities_for_context(activity.data["object"]["context"]), - %{true: ancestors, false: descendants} <- Enum.group_by(activities, fn (%{id: id}) -> id < activity.id end) do + activities <- activities |> Enum.filter(fn (%{id: aid}) -> to_string(aid) != to_string(id) end), + grouped_activities <- Enum.group_by(activities, fn (%{id: id}) -> id < activity.id end) do result = %{ - ancestors: StatusView.render("index.json", for: user, activities: ancestors, as: :activity) |> Enum.reverse, - descendants: StatusView.render("index.json", for: user, activities: descendants, as: :activity) |> Enum.reverse, + ancestors: StatusView.render("index.json", for: user, activities: grouped_activities[true] || [], as: :activity) |> Enum.reverse, + descendants: StatusView.render("index.json", for: user, activities: grouped_activities[false] || [], as: :activity) |> Enum.reverse, } json(conn, result)