fix(retention): keep threads whose post a local user quoted

A quote has a context of its own, so the quoted remote thread counted as
untouched and was evicted, breaking the local quote. On lain.com 45 of
134 quoted posts went this way. The objects_quote_url index keeps the
lookup at one probe per post.
This commit is contained in:
Lain Soykaf 2026-09-25 08:50:41 +04:00
commit e93f05a79f
No known key found for this signature in database
5 changed files with 53 additions and 5 deletions

View file

@ -200,6 +200,29 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do
refute Object.get_by_ap_id(old_remote_post2_id)
end
test "with the --keep-threads option it keeps old threads a local user quoted", %{
old_insert_date: old_insert_date
} do
remote_user = insert(:user, local: false)
local_user = insert(:user)
{:ok, quoted} = CommonAPI.post(remote_user, %{status: "quote me"})
quoted
|> Ecto.Changeset.change(%{local: false, updated_at: old_insert_date})
|> Repo.update!()
{:ok, quote} = CommonAPI.post(local_user, %{status: "look", quote_id: quoted.id})
quote
|> Ecto.Changeset.change(%{updated_at: old_insert_date})
|> Repo.update!()
Mix.Tasks.Pleroma.Database.run(["prune_objects", "--keep-threads"])
assert Object.get_by_ap_id(quoted.data["object"])
end
test "with the --keep-threads option it keeps old threads addressed to a local user", %{
old_insert_date: old_insert_date
} do

View file

@ -244,6 +244,21 @@ defmodule Pleroma.RetentionTest do
assert Object.get_by_ap_id(post.data["object"])
end
test "keeps an old remote thread whose post a local user quoted", %{old_date: old_date} do
remote_user = insert(:user, local: false)
local_user = insert(:user)
quoted = old_remote_post(remote_user, old_date)
{:ok, quote} = CommonAPI.post(local_user, %{status: "look at this", quote_id: quoted.id})
make_old(quote, old_date)
# The quote has a context of its own and does not pin the quoted thread.
refute quote.data["context"] == quoted.data["context"]
assert %{contexts: 0} = Retention.run()
assert Object.get_by_ap_id(quoted.data["object"])
end
test "keeps an old remote post that was reported", %{old_date: old_date} do
remote_user = insert(:user, local: false)
local_user = insert(:user)