Skip to main content

tuwunel_admin/room/
mod.rs

1mod alias;
2mod delete;
3mod directory;
4mod exists;
5mod info;
6mod list;
7mod moderation;
8mod prune_empty;
9mod purge_user;
10
11use clap::Subcommand;
12use ruma::OwnedRoomId;
13use tuwunel_core::Result;
14
15use self::{
16	alias::RoomAliasCommand, directory::RoomDirectoryCommand, info::RoomInfoCommand,
17	moderation::RoomModerationCommand,
18};
19use crate::admin_command_dispatch;
20
21#[admin_command_dispatch(handler_prefix = "room")]
22#[derive(Debug, Subcommand)]
23pub(super) enum RoomCommand {
24	/// - List all rooms the server knows about
25	List {
26		page: Option<usize>,
27
28		/// Excludes rooms that we have federation disabled with
29		#[arg(long)]
30		exclude_disabled: bool,
31
32		/// Excludes rooms that we have banned
33		#[arg(long)]
34		exclude_banned: bool,
35
36		#[arg(long)]
37		/// Whether to only output room IDs without supplementary room
38		/// information
39		no_details: bool,
40	},
41
42	#[command(subcommand)]
43	/// - View information about a room we know about
44	Info(RoomInfoCommand),
45
46	#[command(subcommand)]
47	/// - Manage moderation of remote or local rooms
48	Moderation(RoomModerationCommand),
49
50	#[command(subcommand)]
51	/// - Manage room aliases
52	Alias(RoomAliasCommand),
53
54	#[command(subcommand)]
55	/// - Manage the room directory
56	Directory(RoomDirectoryCommand),
57
58	/// - Check if we know about a room
59	Exists {
60		room_id: OwnedRoomId,
61	},
62
63	/// - Delete room
64	Delete {
65		room_id: OwnedRoomId,
66
67		#[arg(short, long)]
68		force: bool,
69	},
70
71	/// - Prune empty rooms
72	PruneEmpty {
73		#[arg(short, long)]
74		force: bool,
75	},
76
77	/// - Delete every room a user is joined to
78	///
79	/// Useful for cleaning up after spam invitations or a faulty appservice
80	/// registration. With --regex the argument is a pattern matched against
81	/// every joined member of each room, so a whole namespace
82	/// (e.g. `@bot_[A-Za-z0-9]+:example\.com`) can be cleared at once.
83	PurgeUser {
84		/// A user ID, or (with --regex) a pattern matched against the joined
85		/// members of every room
86		user_id: String,
87
88		/// Interpret user_id as a regular expression
89		#[arg(long)]
90		regex: bool,
91
92		/// Only delete rooms where the matched user is the only joined member
93		#[arg(long)]
94		sole_member: bool,
95
96		/// List the rooms that would be deleted without deleting them
97		#[arg(long)]
98		dry_run: bool,
99	},
100}