tuwunel_admin/user/mod.rs
1mod commands;
2
3use clap::Subcommand;
4use ruma::{OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedRoomOrAliasId, OwnedUserId};
5use tuwunel_core::Result;
6
7use crate::admin_command_dispatch;
8
9#[admin_command_dispatch]
10#[derive(Debug, Subcommand)]
11pub(super) enum UserCommand {
12 /// - Create a new user
13 #[clap(alias = "create")]
14 CreateUser {
15 /// Username of the new user
16 username: String,
17 /// Password of the new user, if unspecified one is generated
18 password: Option<String>,
19 },
20
21 /// - Reset user password
22 ResetPassword {
23 /// Username of the user for whom the password should be reset
24 username: String,
25 /// New password for the user, if unspecified one is generated
26 password: Option<String>,
27 },
28
29 /// - Deactivate a user
30 ///
31 /// User will be removed from all rooms by default.
32 /// Use --no-leave-rooms to not leave all rooms by default.
33 Deactivate {
34 #[arg(short, long)]
35 no_leave_rooms: bool,
36 user_id: String,
37 },
38
39 /// - Deactivate a list of users
40 ///
41 /// Recommended to use in conjunction with list-local-users.
42 ///
43 /// Users will be removed from joined rooms by default.
44 ///
45 /// Can be overridden with --no-leave-rooms.
46 ///
47 /// Removing a mass amount of users from a room may cause a significant
48 /// amount of leave events. The time to leave rooms may depend significantly
49 /// on joined rooms and servers.
50 ///
51 /// This command needs a newline separated list of users provided in a
52 /// Markdown code block below the command.
53 DeactivateAll {
54 #[arg(short, long)]
55 /// Does not leave any rooms the user is in on deactivation
56 no_leave_rooms: bool,
57 #[arg(short, long)]
58 /// Also deactivate admin accounts and will assume leave all rooms too
59 force: bool,
60 },
61
62 /// - Deletes a user's device.
63 DeleteDevice {
64 user_id: OwnedUserId,
65 device_id: OwnedDeviceId,
66 },
67
68 /// - List local users by recent activity.
69 LastActive {
70 #[arg(short, long)]
71 limit: Option<usize>,
72 },
73
74 /// - List local users in the database
75 #[clap(alias = "list")]
76 ListUsers,
77
78 /// - Lists all the rooms (local and remote) that the specified user is
79 /// joined in
80 ListJoinedRooms {
81 user_id: String,
82 },
83
84 /// - Manually join a local user to a room.
85 ForceJoinRoom {
86 user_id: String,
87 room: OwnedRoomOrAliasId,
88 },
89
90 /// - Manually leave a local user from a room.
91 ForceLeaveRoom {
92 user_id: String,
93 room_id: OwnedRoomOrAliasId,
94 },
95
96 /// - Reject all pending invites for a local user.
97 RejectInvites {
98 user_id: String,
99
100 /// Optional reason attached to each rejection.
101 #[arg(long)]
102 reason: Option<String>,
103 },
104
105 /// - Forces the specified user to drop their power levels to the room
106 /// default, if their permissions allow and the auth check permits
107 ForceDemote {
108 user_id: String,
109 room_id: OwnedRoomOrAliasId,
110 },
111
112 /// - Force promote
113 ForcePromote {
114 user_id: String,
115 room_id: OwnedRoomOrAliasId,
116 },
117
118 /// - Grant server-admin privileges to a user.
119 MakeUserAdmin {
120 user_id: String,
121 },
122
123 /// - Puts a room tag for the specified user and room ID.
124 ///
125 /// This is primarily useful if you'd like to set your admin room
126 /// to the special "System Alerts" section in Element as a way to
127 /// permanently see your admin room without it being buried away in your
128 /// favourites or rooms. To do this, you would pass your user, your admin
129 /// room's internal ID, and the tag name `m.server_notice`.
130 PutRoomTag {
131 user_id: String,
132 room_id: OwnedRoomId,
133 tag: String,
134 },
135
136 /// - Deletes the room tag for the specified user and room ID
137 DeleteRoomTag {
138 user_id: String,
139 room_id: OwnedRoomId,
140 tag: String,
141 },
142
143 /// - Gets all the room tags for the specified user and room ID
144 GetRoomTags {
145 user_id: String,
146 room_id: OwnedRoomId,
147 },
148
149 /// - Attempts to forcefully redact the specified event ID from the sender
150 /// user
151 ///
152 /// This is only valid for local users
153 RedactEvent {
154 event_id: OwnedEventId,
155 },
156
157 /// - Force joins a specified list of local users to join the specified
158 /// room.
159 ///
160 /// Specify a codeblock of usernames.
161 ///
162 /// Requires the `--yes-i-want-to-do-this` flag.
163 ForceJoinListOfLocalUsers {
164 room: OwnedRoomOrAliasId,
165
166 #[arg(long)]
167 yes_i_want_to_do_this: bool,
168 },
169
170 /// - Force joins all local users to the specified room.
171 ///
172 /// Requires the `--yes-i-want-to-do-this` flag.
173 ForceJoinAllLocalUsers {
174 room: OwnedRoomOrAliasId,
175
176 #[arg(long)]
177 yes_i_want_to_do_this: bool,
178 },
179}