Fixing up deletes a bit #327

Merged
floatingghost merged 10 commits from delete-fixing into develop 2022-12-01 15:00:54 +00:00
4 changed files with 30 additions and 5 deletions
Showing only changes of commit 9c0c27e7b0 - Show all commits

View file

@ -10,8 +10,6 @@ defmodule Pleroma.Object.Pruner do
import Ecto.Query
def prune_tombstoned_deliveries do
before_time = cutoff()
from(d in Delivery)
|> join(:inner, [d], o in Object, on: d.object_id == o.id)
|> where([d, o], fragment("?->>'type' = ?", o.data, "Tombstone"))

View file

@ -1,8 +1,7 @@
defmodule Pleroma.Object.PrunerTest do
use Pleroma.DataCase, async: true
alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.Delivery
alias Pleroma.Object.Pruner
import Pleroma.Factory
@ -21,4 +20,22 @@ test "it prunes old delete objects" do
refute Object.get_by_id(old_tombstone.id)
end
end
describe "prune_tombstoned_deliveries" do
test "it prunes old tombstone deliveries" do
user = insert(:user)
tombstone = insert(:tombstone)
tombstoned = insert(:delivery, object: tombstone, user: user)
note = insert(:note)
not_tombstoned = insert(:delivery, object: note, user: user)
Pruner.prune_tombstoned_deliveries()
|> IO.inspect()
refute Repo.get(Delivery, tombstoned.id)
assert Repo.get(Delivery, not_tombstoned.id)
end
end
end

View file

@ -226,7 +226,7 @@ test "resets the user's default post expiry", %{conn: conn} do
test "does not allow negative integers other than -1 for TTL", %{conn: conn} do
conn = patch(conn, "/api/v1/accounts/update_credentials", %{"status_ttl_days" => "-2"})
assert user_data = json_response_and_validate_schema(conn, 403)
assert json_response_and_validate_schema(conn, 403)
end
test "updates the user's AKAs", %{conn: conn} do

View file

@ -704,4 +704,14 @@ def frontend_setting_profile_factory(params \\ %{}) do
}
|> Map.merge(params)
end
def delivery_factory(params \\ %{}) do
object = Map.get(params, :object, build(:note))
user = Map.get(params, :user, build(:user))
%Pleroma.Delivery{
object: object,
user: user
}
end
end