From 92f1ea911219eebb848c39c3930accd6f1bdc639 Mon Sep 17 00:00:00 2001 From: fox Date: Mon, 6 Mar 2023 23:23:36 +0000 Subject: [PATCH] revert 745e15468e64991e710467e3809bc62424014a52 - kill yourself revert Use same context for quote posts as the post that's being quoted (#379) See https://akkoma.dev/AkkomaGang/akkoma/pulls/350#issuecomment-6109 When making quotes through Mast-API, they will now have the same context as the quoted post. This also results in them being showed when fetching the thread. I checked Misskey to see how it's there, and they show the quotes there as well, see e.g. . An example from Akkoma: Co-authored-by: ilja Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/379 Reviewed-by: floatingghost Co-authored-by: ilja Co-committed-by: ilja --- lib/pleroma/web/common_api/activity_draft.ex | 2 +- lib/pleroma/web/common_api/utils.ex | 7 +++---- .../mastodon_api/controllers/status_controller_test.exs | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/pleroma/web/common_api/activity_draft.ex b/lib/pleroma/web/common_api/activity_draft.ex index ced6371d6..0879bf9a6 100644 --- a/lib/pleroma/web/common_api/activity_draft.ex +++ b/lib/pleroma/web/common_api/activity_draft.ex @@ -194,7 +194,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do end defp context(draft) do - context = Utils.make_context(draft) + context = Utils.make_context(draft.in_reply_to, draft.in_reply_to_conversation) %__MODULE__{draft | context: context} end diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 54918d13c..b3f9077ff 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -230,13 +230,12 @@ defmodule Pleroma.Web.CommonAPI.Utils do end end - def make_context(%{in_reply_to_conversation: %Participation{} = participation}) do + def make_context(_, %Participation{} = participation) do Repo.preload(participation, :conversation).conversation.ap_id end - def make_context(%{in_reply_to: %Activity{data: %{"context" => context}}}), do: context - def make_context(%{quote: %Activity{data: %{"context" => context}}}), do: context - def make_context(_), do: Utils.generate_context_id() + def make_context(%Activity{data: %{"context" => context}}, _), do: context + def make_context(_, _), do: Utils.generate_context_id() def maybe_add_attachments(parsed, _attachments, false = _no_links), do: parsed diff --git a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs index 6f04975b8..b8994170a 100644 --- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -2041,7 +2041,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do assert response["quote_id"] == quoted_status.id assert response["quote"]["id"] == quoted_status.id assert response["quote"]["content"] == quoted_status.object.data["content"] - assert response["pleroma"]["context"] == quoted_status.data["context"] end test "posting a quote, quoting a status that isn't public", %{conn: conn} do