mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-26 16:02:18 +00:00
29 lines
804 B
Elixir
29 lines
804 B
Elixir
defmodule Pleroma.Repo.Migrations.MoveActivityExpirationsToOban do
|
|
use Ecto.Migration
|
|
|
|
import Ecto.Query, only: [from: 2]
|
|
|
|
def change do
|
|
Pleroma.Config.Oban.warn()
|
|
|
|
Supervisor.start_link([{Oban, Pleroma.Config.get(Oban)}],
|
|
strategy: :one_for_one,
|
|
name: Pleroma.Supervisor
|
|
)
|
|
|
|
from(e in "activity_expirations",
|
|
select: %{id: e.id, activity_id: e.activity_id, scheduled_at: e.scheduled_at}
|
|
)
|
|
|> Pleroma.Repo.stream()
|
|
|> Stream.each(fn expiration ->
|
|
with {:ok, expires_at} <- DateTime.from_naive(expiration.scheduled_at, "Etc/UTC") do
|
|
Pleroma.Workers.PurgeExpiredActivity.enqueue(%{
|
|
activity_id: FlakeId.to_string(expiration.activity_id),
|
|
expires_at: expires_at
|
|
})
|
|
end
|
|
end)
|
|
|> Stream.run()
|
|
end
|
|
end
|