diff --git a/lib/pleroma/object/pruner.ex b/lib/pleroma/object/pruner.ex index 51066e1ff..991d8b0eb 100644 --- a/lib/pleroma/object/pruner.ex +++ b/lib/pleroma/object/pruner.ex @@ -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")) diff --git a/test/pleroma/object/pruner_test.exs b/test/pleroma/object/pruner_test.exs index a6b4f5bc1..46f784ce5 100644 --- a/test/pleroma/object/pruner_test.exs +++ b/test/pleroma/object/pruner_test.exs @@ -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 diff --git a/test/pleroma/web/mastodon_api/update_credentials_test.exs b/test/pleroma/web/mastodon_api/update_credentials_test.exs index 435782d0a..a5403f360 100644 --- a/test/pleroma/web/mastodon_api/update_credentials_test.exs +++ b/test/pleroma/web/mastodon_api/update_credentials_test.exs @@ -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 diff --git a/test/support/factory.ex b/test/support/factory.ex index a2498f5a8..904987aaf 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -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