end
test "it prunes orphaned activities with the --prune-orphaned-activities" do
- # Add a remote activity which references an Object
%Object{} |> Map.merge(%{data: %{"id" => "object_for_activity"}}) |> Repo.insert()
%Activity{}
})
|> Repo.insert()
- # Add a remote activity which references an activity
%Activity{}
|> Map.merge(%{
local: false,
})
|> Repo.insert()
- # Add a remote activity which references an Actor
%User{} |> Map.merge(%{ap_id: "actor"}) |> Repo.insert()
%Activity{}
})
|> Repo.insert()
- # Add a remote activity without existing referenced object, activity or actor
%Activity{}
|> Map.merge(%{
local: false,
})
|> Repo.insert()
- # Add a local activity without existing referenced object, activity or actor
%Activity{}
|> Map.merge(%{
local: true,
})
|> Repo.insert()
- # The remote activities without existing reference, and only the remote activities without existing reference, are deleted
- # if, and only if, we provide the --prune-orphaned-activities option
assert length(Repo.all(Activity)) == 5
Mix.Tasks.Pleroma.Database.run(["prune_objects"])
assert length(Repo.all(Activity)) == 5
%Object{} |> Map.merge(%{data: %{"id" => "existing_object"}}) |> Repo.insert()
%User{} |> Map.merge(%{ap_id: "existing_actor"}) |> Repo.insert()
- # Multiple objects, one object exists (keep)
%Activity{}
|> Map.merge(%{
local: false,
})
|> Repo.insert()
- # Multiple objects, one actor exists (keep)
%Activity{}
|> Map.merge(%{
local: false,
})
|> Repo.insert()
- # Multiple objects, one activity exists (keep)
%Activity{}
|> Map.merge(%{
local: false,
})
|> Repo.insert()
- # Multiple objects none exist (prune)
%Activity{}
|> Map.merge(%{
local: false,