From c3519132dfdcd5f59c0ebe99fa8ab4b764ac4982 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Wed, 5 Dec 2018 16:44:15 +0100 Subject: [PATCH] Sorry --- lib/mix/tasks/make_moderator.ex | 7 +++++-- lib/mix/tasks/set_admin.ex | 7 +++++-- lib/mix/tasks/set_locked.ex | 9 ++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/mix/tasks/make_moderator.ex b/lib/mix/tasks/make_moderator.ex index 9ea6c45c1..8dc0a04dd 100644 --- a/lib/mix/tasks/make_moderator.ex +++ b/lib/mix/tasks/make_moderator.ex @@ -22,8 +22,11 @@ def run([nickname | rest]) do with %User{local: true} = user <- User.get_by_nickname(nickname) do info_cng = User.Info.admin_api_update(user.info, %{is_moderator: !!moderator}) - user_cng = Ecto.Changeset.change(user) - |> put_embed(:info, info_cng) + + user_cng = + Ecto.Changeset.change(user) + |> put_embed(:info, info_cng) + {:ok, user} = User.update_and_set_cache(user_cng) IO.puts("Moderator status of #{nickname}: #{user.info.is_moderator}") diff --git a/lib/mix/tasks/set_admin.ex b/lib/mix/tasks/set_admin.ex index 9788e49b9..ac26516f1 100644 --- a/lib/mix/tasks/set_admin.ex +++ b/lib/mix/tasks/set_admin.ex @@ -18,8 +18,11 @@ def run([nickname | rest]) do with %User{local: true} = user <- User.get_by_nickname(nickname) do info_cng = User.Info.admin_api_update(user.info, %{is_admin: !!admin}) - user_cng = Ecto.Changeset.change(user) - |> put_embed(:info, info_cng) + + user_cng = + Ecto.Changeset.change(user) + |> put_embed(:info, info_cng) + {:ok, user} = User.update_and_set_cache(user_cng) IO.puts("Admin status of #{nickname}: #{user.info.is_admin}") diff --git a/lib/mix/tasks/set_locked.ex b/lib/mix/tasks/set_locked.ex index 42d978599..e93a63505 100644 --- a/lib/mix/tasks/set_locked.ex +++ b/lib/mix/tasks/set_locked.ex @@ -8,7 +8,7 @@ defmodule Mix.Tasks.SetLocked do Example: ``mix set_locked lain`` """ - + use Mix.Task import Ecto.Changeset alias Pleroma.{Repo, User} @@ -24,8 +24,11 @@ def run([nickname | rest]) do with %User{local: true} = user <- User.get_by_nickname(nickname) do info_cng = User.Info.profile_update(user.info, %{locked: !!locked}) - user_cng = Ecto.Changeset.change(user) - |> put_embed(:info, info_cng) + + user_cng = + Ecto.Changeset.change(user) + |> put_embed(:info, info_cng) + {:ok, user} = User.update_and_set_cache(user_cng) IO.puts("Locked status of #{nickname}: #{user.info.locked}")