Use same context for quote posts as the post that's being quoted (#379)
authorilja <akkoma.dev@ilja.space>
Sat, 31 Dec 2022 18:09:27 +0000 (18:09 +0000)
committerfloatingghost <hannah@coffee-and-dreams.uk>
Sat, 31 Dec 2022 18:09:27 +0000 (18:09 +0000)
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. <https://mk.toast.cafe/notes/98u1g0tulg>.

An example from Akkoma:

Co-authored-by: ilja <git@ilja.space>
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/379
Reviewed-by: floatingghost <hannah@coffee-and-dreams.uk>
Co-authored-by: ilja <akkoma.dev@ilja.space>
Co-committed-by: ilja <akkoma.dev@ilja.space>
CHANGELOG.md
lib/pleroma/web/common_api/activity_draft.ex
lib/pleroma/web/common_api/utils.ex
test/pleroma/web/mastodon_api/controllers/status_controller_test.exs

index 6125c09623aa694620bec0f17d54daae8bc8fd11..73563c3128b7b842f5e54df5b26d1db41bd892b2 100644 (file)
@@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Non-admin users now cannot register `admin` scope tokens (not security-critical, they didn't work before, but you _could_ create them)
   - Admin scopes will be dropped on create
 - Rich media will now backoff for 20 minutes after a failure
+- Quote posts are now considered as part of the same thread as the post they are quoting
 - Simplified HTTP signature processing
 - Rich media will now hard-exit after 5 seconds, to prevent timeline hangs
 
index b3a49de441d8b13957ba43263fed476f5c564f67..8b0eaaadf498b12366e6338e3460a3513c323106 100644 (file)
@@ -177,7 +177,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
   end
 
   defp context(draft) do
-    context = Utils.make_context(draft.in_reply_to, draft.in_reply_to_conversation)
+    context = Utils.make_context(draft)
     %__MODULE__{draft | context: context}
   end
 
index 22594be4605f24fb81b3166f1b002e9aa1df4c15..aee19a840de04aa2c1cc9e5d1e73a0a6299557f7 100644 (file)
@@ -230,12 +230,13 @@ defmodule Pleroma.Web.CommonAPI.Utils do
     end
   end
 
-  def make_context(_, %Participation{} = participation) do
+  def make_context(%{in_reply_to_conversation: %Participation{} = participation}) do
     Repo.preload(participation, :conversation).conversation.ap_id
   end
 
-  def make_context(%Activity{data: %{"context" => context}}, _), do: context
-  def make_context(_, _), do: Utils.generate_context_id()
+  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 maybe_add_attachments(parsed, _attachments, false = _no_links), do: parsed
 
index 7931d1d697c407026f365762b218f5587c30c129..45da22d917aeef9a9929bbb2ce16c0245f29d7e3 100644 (file)
@@ -2023,6 +2023,7 @@ 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