Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
847B

  1. defmodule Pleroma.Repo.Migrations.MoveActivityExpirationsToOban do
  2. use Ecto.Migration
  3. import Ecto.Query, only: [from: 2]
  4. def change do
  5. Pleroma.Config.Oban.warn()
  6. Application.ensure_all_started(:oban)
  7. Supervisor.start_link([{Oban, Pleroma.Config.get(Oban)}],
  8. strategy: :one_for_one,
  9. name: Pleroma.Supervisor
  10. )
  11. from(e in "activity_expirations",
  12. select: %{id: e.id, activity_id: e.activity_id, scheduled_at: e.scheduled_at}
  13. )
  14. |> Pleroma.Repo.stream()
  15. |> Stream.each(fn expiration ->
  16. with {:ok, expires_at} <- DateTime.from_naive(expiration.scheduled_at, "Etc/UTC") do
  17. Pleroma.Workers.PurgeExpiredActivity.enqueue(%{
  18. activity_id: FlakeId.to_string(expiration.activity_id),
  19. expires_at: expires_at
  20. })
  21. end
  22. end)
  23. |> Stream.run()
  24. end
  25. end