mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-23 01:35:28 +00:00
Add function to deactivate users.
This commit is contained in:
parent
0ec5aeb8a7
commit
b727ecc5e7
|
@ -334,4 +334,9 @@ defmodule Pleroma.User 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 @@ defmodule Pleroma.UserTest 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
|
||||||
|
|
Loading…
Reference in a new issue