Commit 8228ae96 authored by lain's avatar lain

Only run the fix-up tasks once.

parent a91adb14
Pipeline #879 passed with stage
in 2 minutes and 30 seconds
...@@ -266,16 +266,19 @@ def upgrade_user_from_ap_id(ap_id, async \\ true) do ...@@ -266,16 +266,19 @@ def upgrade_user_from_ap_id(ap_id, async \\ true) do
data = data data = data
|> Map.put(:info, Map.merge(user.info, data[:info])) |> Map.put(:info, Map.merge(user.info, data[:info]))
already_ap = User.ap_enabled?(user)
{:ok, user} = User.upgrade_changeset(user, data) {:ok, user} = User.upgrade_changeset(user, data)
|> Repo.update() |> Repo.update()
# This could potentially take a long time, do it in the background if !already_ap do
if async do # This could potentially take a long time, do it in the background
Task.start(fn -> if async do
Task.start(fn ->
user_upgrade_task(user)
end)
else
user_upgrade_task(user) user_upgrade_task(user)
end) end
else
user_upgrade_task(user)
end end
{:ok, user} {:ok, user}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment