From b727ecc5e75388e2b2d67c76cab6df1a7e6719b3 Mon Sep 17 00:00:00 2001 From: Lain Iwakura Date: Thu, 7 Dec 2017 17:47:23 +0100 Subject: [PATCH] Add function to deactivate users. --- lib/pleroma/user.ex | 5 +++++ test/user_test.exs | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index afc62f265..779a89a12 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -334,4 +334,9 @@ def local_user_query() do where: u.local == true end + def deactivate (%User{} = user) do + new_info = Map.put(user.info, "deactivated", true) + cs = User.info_changeset(user, %{info: new_info}) + Repo.update(cs) + end end diff --git a/test/user_test.exs b/test/user_test.exs index 31c5962e2..6daf1ecb7 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -325,5 +325,11 @@ test "get recipients from activity" do assert user in recipients assert addressed in recipients end -end + test ".deactivate deactivates a user" do + user = insert(:user) + assert false == !!user.info["deactivated"] + {:ok, user} = User.deactivate(user) + assert true == user.info["deactivated"] + end +end