logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

20240729163838_publisher_job_change.exs (700B)


  1. defmodule Pleroma.Repo.Migrations.PublisherJobChange do
  2. use Ecto.Migration
  3. alias Pleroma.Activity
  4. alias Pleroma.Repo
  5. import Ecto.Query
  6. def up do
  7. query =
  8. from(j in Oban.Job,
  9. where: j.worker == "Pleroma.Workers.PublisherWorker",
  10. where: j.state in ["available", "retryable"]
  11. )
  12. jobs = Repo.all(query)
  13. Enum.each(jobs, fn job ->
  14. args = job.args
  15. case Activity.get_by_ap_id(args["id"]) do
  16. nil ->
  17. :ok
  18. %Activity{id: activity_id} ->
  19. updated_args = Map.put(args, "activity_id", activity_id)
  20. Pleroma.Workers.PublisherWorker.new(updated_args)
  21. |> Oban.insert()
  22. end
  23. end)
  24. end
  25. end