Fixing up deletes a bit #327
4 changed files with 30 additions and 5 deletions
|
@ -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"))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue