1
0
Fork 0
forked from mirrors/akkoma

Add function to deactivate users.

This commit is contained in:
Lain Iwakura 2017-12-07 17:47:23 +01:00
parent 0ec5aeb8a7
commit b727ecc5e7
2 changed files with 12 additions and 1 deletions

View file

@ -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

View file

@ -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