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