mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-19 11:29:17 +00:00
Only run the fix-up tasks once.
This commit is contained in:
parent
a91adb146e
commit
8228ae96d8
|
@ -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}
|
||||||
|
|
Loading…
Reference in a new issue