summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-11-21 20:33:11 +0000
committerrinpatch <rinpatch@sdf.org>2019-11-21 20:33:11 +0000
commitc2ad9fd5f93b8bbbea19089eb8a2456eb207ff18 (patch)
tree8fd6f311dbcb013e0fbb5ad3cb241f922fa2402b
parentdedb1ad5d68406bf16ac47d5ad7d2c12f97a10b4 (diff)
parentfbc379d68990b166e1034cfff252f975f793eba1 (diff)
Merge branch 'list-users' into 'develop'
Add CLI list users command See merge request pleroma/pleroma!1990
-rw-r--r--CHANGELOG.md1
-rw-r--r--docs/administration/CLI_tasks/user.md5
-rw-r--r--lib/mix/tasks/pleroma/user.ex18
3 files changed, 24 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6bd835a3d..9d27dced1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -42,6 +42,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Authentication: Added rate limit for password-authorized actions / login existence checks
- Static Frontend: Add the ability to render user profiles and notices server-side without requiring JS app.
- Mix task to re-count statuses for all users (`mix pleroma.count_statuses`)
+- Mix task to list all users (`mix pleroma.user list`)
- Support for `X-Forwarded-For` and similar HTTP headers which used by reverse proxies to pass a real user IP address to the backend. Must not be enabled unless your instance is behind at least one reverse proxy (such as Nginx, Apache HTTPD or Varnish Cache).
- MRF: New module which handles incoming posts based on their age. By default, all incoming posts that are older than 2 days will be unlisted and not shown to their followers.
<details>
diff --git a/docs/administration/CLI_tasks/user.md b/docs/administration/CLI_tasks/user.md
index cf120f2c9..96b2d9e6a 100644
--- a/docs/administration/CLI_tasks/user.md
+++ b/docs/administration/CLI_tasks/user.md
@@ -15,6 +15,11 @@ $PREFIX new <nickname> <email> [<options>]
- `--admin`/`--no-admin` - whether the user should be an admin
- `-y`, `--assume-yes`/`--no-assume-yes` - whether to assume yes to all questions
+## List local users
+```sh
+$PREFIX list
+```
+
## Generate an invite link
```sh
$PREFIX invite [<options>]
diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex
index 4e3b80db3..bc8eacda8 100644
--- a/lib/mix/tasks/pleroma/user.ex
+++ b/lib/mix/tasks/pleroma/user.ex
@@ -364,6 +364,24 @@ defmodule Mix.Tasks.Pleroma.User do
end
end
+ def run(["list"]) do
+ start_pleroma()
+
+ Pleroma.User.Query.build(%{local: true})
+ |> Pleroma.RepoStreamer.chunk_stream(500)
+ |> Stream.each(fn users ->
+ users
+ |> Enum.each(fn user ->
+ shell_info(
+ "#{user.nickname} moderator: #{user.info.is_moderator}, admin: #{user.info.is_admin}, locked: #{
+ user.info.locked
+ }, deactivated: #{user.info.deactivated}"
+ )
+ end)
+ end)
+ |> Stream.run()
+ end
+
defp set_moderator(user, value) do
{:ok, user} =
user