tuwunel_admin/room/mod.rs
1mod alias;
2mod clear_soft_failed_events;
3mod delete;
4mod directory;
5mod exists;
6mod info;
7mod list;
8mod list_extremities;
9mod list_joined_members;
10mod moderation;
11mod prune_empty;
12mod prune_extremities;
13mod purge_user;
14
15use clap::Subcommand;
16use ruma::{OwnedRoomId, OwnedRoomOrAliasId};
17use tuwunel_core::Result;
18
19use self::{
20 alias::RoomAliasCommand, directory::RoomDirectoryCommand, moderation::RoomModerationCommand,
21};
22use crate::admin_command_dispatch;
23
24#[admin_command_dispatch(handler_prefix = "room")]
25#[derive(Debug, Subcommand)]
26pub(super) enum RoomCommand {
27 /// - List all rooms the server knows about
28 List {
29 page: Option<usize>,
30
31 /// Excludes rooms that we have federation disabled with
32 #[arg(long)]
33 exclude_disabled: bool,
34
35 /// Excludes rooms that we have banned
36 #[arg(long)]
37 exclude_banned: bool,
38
39 #[arg(long)]
40 /// Whether to only output room IDs without supplementary room
41 /// information
42 no_details: bool,
43 },
44
45 /// - Get general information about a room
46 ///
47 /// Shows the room's name, topic, canonical alias, local aliases, and
48 /// admins (users with a power level greater than or equal to
49 /// state_default).
50 Info {
51 /// Room ID or alias
52 room: OwnedRoomOrAliasId,
53 },
54
55 /// - List joined members in a room
56 ListJoinedMembers {
57 room_id: OwnedRoomId,
58
59 /// Lists only our local users in the specified room
60 #[arg(long)]
61 local_only: bool,
62 },
63
64 #[command(subcommand)]
65 /// - Manage moderation of remote or local rooms
66 Moderation(RoomModerationCommand),
67
68 #[command(subcommand)]
69 /// - Manage room aliases
70 Alias(RoomAliasCommand),
71
72 #[command(subcommand)]
73 /// - Manage the room directory
74 Directory(RoomDirectoryCommand),
75
76 /// - Check if we know about a room
77 Exists {
78 room_id: OwnedRoomId,
79 },
80
81 /// - Clear stored soft-fail and policy decisions for a room
82 ///
83 /// Changes stored moderation state so matching events are re-checked on the
84 /// next delivery instead of waiting out the retry window. Does not replay
85 /// or insert events.
86 ClearSoftFailedEvents {
87 /// Room ID or alias
88 room_id: OwnedRoomOrAliasId,
89 },
90
91 /// - Delete room
92 Delete {
93 room_id: OwnedRoomId,
94
95 #[arg(short, long)]
96 force: bool,
97 },
98
99 /// - Prune empty rooms
100 PruneEmpty {
101 #[arg(short, long)]
102 force: bool,
103 },
104
105 /// - List a room's forward extremities with a total
106 ListExtremities {
107 room_id: OwnedRoomOrAliasId,
108 },
109
110 /// - Scored prune of a room's forward extremities down to a target
111 PruneExtremities {
112 room_id: OwnedRoomOrAliasId,
113
114 /// Target frontier size (default: forward_extremities_max, min 1)
115 target: Option<usize>,
116
117 /// Show the plan without writing
118 #[arg(long)]
119 dry_run: bool,
120 },
121
122 /// - Delete every room a user is joined to
123 ///
124 /// Useful for cleaning up after spam invitations or a faulty appservice
125 /// registration. With --regex the argument is a pattern matched against
126 /// every joined member of each room, so a whole namespace
127 /// (e.g. `@bot_[A-Za-z0-9]+:example\.com`) can be cleared at once.
128 PurgeUser {
129 /// A user ID, or (with --regex) a pattern matched against the joined
130 /// members of every room
131 user_id: String,
132
133 /// Interpret user_id as a regular expression
134 #[arg(long)]
135 regex: bool,
136
137 /// Only delete rooms where the matched user is the only joined member
138 #[arg(long)]
139 sole_member: bool,
140
141 /// List the rooms that would be deleted without deleting them
142 #[arg(long)]
143 dry_run: bool,
144 },
145}