forked from AkkomaGang/akkoma
Merge branch 'feature/remote-user-deactivation' into 'develop'
remote user deactivation See merge request pleroma/pleroma!154
This commit is contained in:
commit
ad563669c8
2 changed files with 27 additions and 0 deletions
13
lib/mix/tasks/deactivate_user.ex
Normal file
13
lib/mix/tasks/deactivate_user.ex
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
defmodule Mix.Tasks.DeactivateUser do
|
||||||
|
use Mix.Task
|
||||||
|
alias Pleroma.User
|
||||||
|
|
||||||
|
@shortdoc "Toggle deactivation status for a user"
|
||||||
|
def run([nickname]) do
|
||||||
|
Mix.Task.run("app.start")
|
||||||
|
|
||||||
|
with user <- User.get_by_nickname(nickname) do
|
||||||
|
User.deactivate(user)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -16,9 +16,23 @@ def get_recipients(data) do
|
||||||
(data["to"] || []) ++ (data["cc"] || [])
|
(data["to"] || []) ++ (data["cc"] || [])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp check_actor_is_active(actor) do
|
||||||
|
if not is_nil(actor) do
|
||||||
|
with user <- User.get_cached_by_ap_id(actor),
|
||||||
|
nil <- user.info["deactivated"] do
|
||||||
|
:ok
|
||||||
|
else
|
||||||
|
_e -> :reject
|
||||||
|
end
|
||||||
|
else
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def insert(map, local \\ true) when is_map(map) do
|
def insert(map, local \\ true) when is_map(map) do
|
||||||
with nil <- Activity.get_by_ap_id(map["id"]),
|
with nil <- Activity.get_by_ap_id(map["id"]),
|
||||||
map <- lazy_put_activity_defaults(map),
|
map <- lazy_put_activity_defaults(map),
|
||||||
|
:ok <- check_actor_is_active(map["actor"]),
|
||||||
{:ok, map} <- MRF.filter(map),
|
{:ok, map} <- MRF.filter(map),
|
||||||
:ok <- insert_full_object(map) do
|
:ok <- insert_full_object(map) do
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
|
|
Loading…
Reference in a new issue