Commit b727ecc5 authored by lain's avatar lain
Browse files

Add function to deactivate users.

parent 0ec5aeb8
...@@ -334,4 +334,9 @@ def local_user_query() do ...@@ -334,4 +334,9 @@ def local_user_query() do
where: u.local == true where: u.local == true
end 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 end
...@@ -325,5 +325,11 @@ test "get recipients from activity" do ...@@ -325,5 +325,11 @@ test "get recipients from activity" do
assert user in recipients assert user in recipients
assert addressed in recipients assert addressed in recipients
end 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
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