pleroma/lib/mix/tasks/fix_ap_users.ex

30 lines
626 B
Elixir
Raw Normal View History

2018-02-21 16:59:00 -05:00
defmodule Mix.Tasks.FixApUsers do
use Mix.Task
import Mix.Ecto
import Ecto.Query
alias Pleroma.{Repo, User}
@shortdoc "Grab all ap users again"
def run([]) do
Mix.Task.run("app.start")
2018-03-30 09:01:53 -04:00
q =
from(
u in User,
where: fragment("? @> ?", u.info, ^%{"ap_enabled" => true}),
where: u.local == false
)
2018-02-21 16:59:00 -05:00
users = Repo.all(q)
2018-03-30 09:01:53 -04:00
Enum.each(users, fn user ->
2018-02-24 04:52:12 -05:00
try do
IO.puts("Fetching #{user.nickname}")
Pleroma.Web.ActivityPub.Transmogrifier.upgrade_user_from_ap_id(user.ap_id, false)
rescue
e -> IO.inspect(e)
end
2018-02-21 16:59:00 -05:00
end)
end
end