1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Repo.Migrations.MoveActivityExpirationsToOban do
8 import Ecto.Query, only: [from: 2]
11 Pleroma.Config.Oban.warn()
13 Application.ensure_all_started(:oban)
15 Supervisor.start_link([{Oban, Pleroma.Config.get(Oban)}],
16 strategy: :one_for_one,
17 name: Pleroma.Supervisor
20 from(e in "activity_expirations",
21 select: %{id: e.id, activity_id: e.activity_id, scheduled_at: e.scheduled_at}
23 |> Pleroma.Repo.stream()
24 |> Stream.each(fn expiration ->
25 with {:ok, expires_at} <- DateTime.from_naive(expiration.scheduled_at, "Etc/UTC") do
26 Pleroma.Workers.PurgeExpiredActivity.enqueue(%{
27 activity_id: FlakeId.to_string(expiration.activity_id),
28 expires_at: expires_at