remove box ids from admin room command arguments

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2025-04-08 04:39:01 +00:00
parent d9616c625d
commit 04d7f7f626
20 changed files with 128 additions and 129 deletions

View file

@ -17,10 +17,9 @@ use conduwuit::{
};
use futures::{FutureExt, StreamExt, TryStreamExt};
use ruma::{
CanonicalJsonObject, EventId, OwnedEventId, OwnedRoomOrAliasId, RoomId, RoomVersionId,
ServerName,
api::{client::error::ErrorKind, federation::event::get_room_state},
events::room::message::RoomMessageEventContent,
CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, OwnedRoomId,
OwnedRoomOrAliasId, OwnedServerName, RoomId, RoomVersionId,
api::federation::event::get_room_state, events::room::message::RoomMessageEventContent,
};
use service::rooms::{
short::{ShortEventId, ShortRoomId},
@ -40,7 +39,7 @@ pub(super) async fn echo(&self, message: Vec<String>) -> Result<RoomMessageEvent
#[admin_command]
pub(super) async fn get_auth_chain(
&self,
event_id: Box<EventId>,
event_id: OwnedEventId,
) -> Result<RoomMessageEventContent> {
let Ok(event) = self.services.rooms.timeline.get_pdu_json(&event_id).await else {
return Ok(RoomMessageEventContent::notice_plain("Event not found."));
@ -109,7 +108,7 @@ pub(super) async fn parse_pdu(&self) -> Result<RoomMessageEventContent> {
}
#[admin_command]
pub(super) async fn get_pdu(&self, event_id: Box<EventId>) -> Result<RoomMessageEventContent> {
pub(super) async fn get_pdu(&self, event_id: OwnedEventId) -> Result<RoomMessageEventContent> {
let mut outlier = false;
let mut pdu_json = self
.services
@ -173,7 +172,7 @@ pub(super) async fn get_short_pdu(
#[admin_command]
pub(super) async fn get_remote_pdu_list(
&self,
server: Box<ServerName>,
server: OwnedServerName,
force: bool,
) -> Result<RoomMessageEventContent> {
if !self.services.server.config.allow_federation {
@ -359,7 +358,7 @@ pub(super) async fn get_room_state(
}
#[admin_command]
pub(super) async fn ping(&self, server: Box<ServerName>) -> Result<RoomMessageEventContent> {
pub(super) async fn ping(&self, server: OwnedServerName) -> Result<RoomMessageEventContent> {
if server == self.services.globals.server_name() {
return Ok(RoomMessageEventContent::text_plain(
"Not allowed to send federation requests to ourselves.",
@ -538,7 +537,7 @@ pub(super) async fn verify_json(&self) -> Result<RoomMessageEventContent> {
}
#[admin_command]
pub(super) async fn verify_pdu(&self, event_id: Box<EventId>) -> Result<RoomMessageEventContent> {
pub(super) async fn verify_pdu(&self, event_id: OwnedEventId) -> Result<RoomMessageEventContent> {
let mut event = self.services.rooms.timeline.get_pdu_json(&event_id).await?;
event.remove("event_id");
@ -556,7 +555,7 @@ pub(super) async fn verify_pdu(&self, event_id: Box<EventId>) -> Result<RoomMess
#[tracing::instrument(skip(self))]
pub(super) async fn first_pdu_in_room(
&self,
room_id: Box<RoomId>,
room_id: OwnedRoomId,
) -> Result<RoomMessageEventContent> {
if !self
.services
@ -585,7 +584,7 @@ pub(super) async fn first_pdu_in_room(
#[tracing::instrument(skip(self))]
pub(super) async fn latest_pdu_in_room(
&self,
room_id: Box<RoomId>,
room_id: OwnedRoomId,
) -> Result<RoomMessageEventContent> {
if !self
.services
@ -614,8 +613,8 @@ pub(super) async fn latest_pdu_in_room(
#[tracing::instrument(skip(self))]
pub(super) async fn force_set_room_state_from_server(
&self,
room_id: Box<RoomId>,
server_name: Box<ServerName>,
room_id: OwnedRoomId,
server_name: OwnedServerName,
) -> Result<RoomMessageEventContent> {
if !self
.services
@ -763,8 +762,8 @@ pub(super) async fn force_set_room_state_from_server(
#[admin_command]
pub(super) async fn get_signing_keys(
&self,
server_name: Option<Box<ServerName>>,
notary: Option<Box<ServerName>>,
server_name: Option<OwnedServerName>,
notary: Option<OwnedServerName>,
query: bool,
) -> Result<RoomMessageEventContent> {
let server_name = server_name.unwrap_or_else(|| self.services.server.name.clone().into());
@ -801,7 +800,7 @@ pub(super) async fn get_signing_keys(
#[admin_command]
pub(super) async fn get_verify_keys(
&self,
server_name: Option<Box<ServerName>>,
server_name: Option<OwnedServerName>,
) -> Result<RoomMessageEventContent> {
let server_name = server_name.unwrap_or_else(|| self.services.server.name.clone().into());
@ -824,7 +823,7 @@ pub(super) async fn get_verify_keys(
#[admin_command]
pub(super) async fn resolve_true_destination(
&self,
server_name: Box<ServerName>,
server_name: OwnedServerName,
no_cache: bool,
) -> Result<RoomMessageEventContent> {
if !self.services.server.config.allow_federation {

View file

@ -3,7 +3,7 @@ pub(crate) mod tester;
use clap::Subcommand;
use conduwuit::Result;
use ruma::{EventId, OwnedRoomOrAliasId, RoomId, ServerName};
use ruma::{OwnedEventId, OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName};
use service::rooms::short::{ShortEventId, ShortRoomId};
use self::tester::TesterCommand;
@ -20,7 +20,7 @@ pub(super) enum DebugCommand {
/// - Get the auth_chain of a PDU
GetAuthChain {
/// An event ID (the $ character followed by the base64 reference hash)
event_id: Box<EventId>,
event_id: OwnedEventId,
},
/// - Parse and print a PDU from a JSON
@ -35,7 +35,7 @@ pub(super) enum DebugCommand {
/// - Retrieve and print a PDU by EventID from the conduwuit database
GetPdu {
/// An event ID (a $ followed by the base64 reference hash)
event_id: Box<EventId>,
event_id: OwnedEventId,
},
/// - Retrieve and print a PDU by PduId from the conduwuit database
@ -52,11 +52,11 @@ pub(super) enum DebugCommand {
/// (following normal event auth rules, handles it as an incoming PDU).
GetRemotePdu {
/// An event ID (a $ followed by the base64 reference hash)
event_id: Box<EventId>,
event_id: OwnedEventId,
/// Argument for us to attempt to fetch the event from the
/// specified remote server.
server: Box<ServerName>,
server: OwnedServerName,
},
/// - Same as `get-remote-pdu` but accepts a codeblock newline delimited
@ -64,7 +64,7 @@ pub(super) enum DebugCommand {
GetRemotePduList {
/// Argument for us to attempt to fetch all the events from the
/// specified remote server.
server: Box<ServerName>,
server: OwnedServerName,
/// If set, ignores errors, else stops at the first error/failure.
#[arg(short, long)]
@ -88,10 +88,10 @@ pub(super) enum DebugCommand {
/// - Get and display signing keys from local cache or remote server.
GetSigningKeys {
server_name: Option<Box<ServerName>>,
server_name: Option<OwnedServerName>,
#[arg(long)]
notary: Option<Box<ServerName>>,
notary: Option<OwnedServerName>,
#[arg(short, long)]
query: bool,
@ -99,14 +99,14 @@ pub(super) enum DebugCommand {
/// - Get and display signing keys from local cache or remote server.
GetVerifyKeys {
server_name: Option<Box<ServerName>>,
server_name: Option<OwnedServerName>,
},
/// - Sends a federation request to the remote server's
/// `/_matrix/federation/v1/version` endpoint and measures the latency it
/// took for the server to respond
Ping {
server: Box<ServerName>,
server: OwnedServerName,
},
/// - Forces device lists for all local and remote users to be updated (as
@ -141,21 +141,21 @@ pub(super) enum DebugCommand {
///
/// This re-verifies a PDU existing in the database found by ID.
VerifyPdu {
event_id: Box<EventId>,
event_id: OwnedEventId,
},
/// - Prints the very first PDU in the specified room (typically
/// m.room.create)
FirstPduInRoom {
/// The room ID
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
/// - Prints the latest ("last") PDU in the specified room (typically a
/// message)
LatestPduInRoom {
/// The room ID
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
/// - Forcefully replaces the room state of our local copy of the specified
@ -174,9 +174,9 @@ pub(super) enum DebugCommand {
/// `/_matrix/federation/v1/state/{roomId}`.
ForceSetRoomStateFromServer {
/// The impacted room ID
room_id: Box<RoomId>,
room_id: OwnedRoomId,
/// The server we will use to query the room state for
server_name: Box<ServerName>,
server_name: OwnedServerName,
},
/// - Runs a server name through conduwuit's true destination resolution
@ -184,7 +184,7 @@ pub(super) enum DebugCommand {
///
/// Useful for debugging well-known issues
ResolveTrueDestination {
server_name: Box<ServerName>,
server_name: OwnedServerName,
#[arg(short, long)]
no_cache: bool,

View file

@ -3,19 +3,19 @@ use std::fmt::Write;
use conduwuit::Result;
use futures::StreamExt;
use ruma::{
OwnedRoomId, RoomId, ServerName, UserId, events::room::message::RoomMessageEventContent,
OwnedRoomId, OwnedServerName, OwnedUserId, events::room::message::RoomMessageEventContent,
};
use crate::{admin_command, get_room_info};
#[admin_command]
pub(super) async fn disable_room(&self, room_id: Box<RoomId>) -> Result<RoomMessageEventContent> {
pub(super) async fn disable_room(&self, room_id: OwnedRoomId) -> Result<RoomMessageEventContent> {
self.services.rooms.metadata.disable_room(&room_id, true);
Ok(RoomMessageEventContent::text_plain("Room disabled."))
}
#[admin_command]
pub(super) async fn enable_room(&self, room_id: Box<RoomId>) -> Result<RoomMessageEventContent> {
pub(super) async fn enable_room(&self, room_id: OwnedRoomId) -> Result<RoomMessageEventContent> {
self.services.rooms.metadata.disable_room(&room_id, false);
Ok(RoomMessageEventContent::text_plain("Room enabled."))
}
@ -42,7 +42,7 @@ pub(super) async fn incoming_federation(&self) -> Result<RoomMessageEventContent
#[admin_command]
pub(super) async fn fetch_support_well_known(
&self,
server_name: Box<ServerName>,
server_name: OwnedServerName,
) -> Result<RoomMessageEventContent> {
let response = self
.services
@ -90,7 +90,7 @@ pub(super) async fn fetch_support_well_known(
#[admin_command]
pub(super) async fn remote_user_in_rooms(
&self,
user_id: Box<UserId>,
user_id: OwnedUserId,
) -> Result<RoomMessageEventContent> {
if user_id.server_name() == self.services.server.name {
return Ok(RoomMessageEventContent::text_plain(

View file

@ -2,7 +2,7 @@ mod commands;
use clap::Subcommand;
use conduwuit::Result;
use ruma::{RoomId, ServerName, UserId};
use ruma::{OwnedRoomId, OwnedServerName, OwnedUserId};
use crate::admin_command_dispatch;
@ -14,12 +14,12 @@ pub(super) enum FederationCommand {
/// - Disables incoming federation handling for a room.
DisableRoom {
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
/// - Enables incoming federation handling for a room again.
EnableRoom {
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
/// - Fetch `/.well-known/matrix/support` from the specified server
@ -32,11 +32,11 @@ pub(super) enum FederationCommand {
/// moderation, and security inquiries. This command provides a way to
/// easily fetch that information.
FetchSupportWellKnown {
server_name: Box<ServerName>,
server_name: OwnedServerName,
},
/// - Lists all the rooms we share/track with the specified *remote* user
RemoteUserInRooms {
user_id: Box<UserId>,
user_id: OwnedUserId,
},
}

View file

@ -5,7 +5,7 @@ use conduwuit::{
};
use conduwuit_service::media::Dim;
use ruma::{
EventId, Mxc, MxcUri, OwnedMxcUri, OwnedServerName, ServerName,
Mxc, OwnedEventId, OwnedMxcUri, OwnedServerName,
events::room::message::RoomMessageEventContent,
};
@ -14,8 +14,8 @@ use crate::{admin_command, utils::parse_local_user_id};
#[admin_command]
pub(super) async fn delete(
&self,
mxc: Option<Box<MxcUri>>,
event_id: Option<Box<EventId>>,
mxc: Option<OwnedMxcUri>,
event_id: Option<OwnedEventId>,
) -> Result<RoomMessageEventContent> {
if event_id.is_some() && mxc.is_some() {
return Ok(RoomMessageEventContent::text_plain(
@ -282,7 +282,7 @@ pub(super) async fn delete_all_from_user(
#[admin_command]
pub(super) async fn delete_all_from_server(
&self,
server_name: Box<ServerName>,
server_name: OwnedServerName,
yes_i_want_to_delete_local_media: bool,
) -> Result<RoomMessageEventContent> {
if server_name == self.services.globals.server_name() && !yes_i_want_to_delete_local_media {

View file

@ -3,7 +3,7 @@ mod commands;
use clap::Subcommand;
use conduwuit::Result;
use ruma::{EventId, MxcUri, OwnedMxcUri, OwnedServerName, ServerName};
use ruma::{OwnedEventId, OwnedMxcUri, OwnedServerName};
use crate::admin_command_dispatch;
@ -15,12 +15,12 @@ pub(super) enum MediaCommand {
Delete {
/// The MXC URL to delete
#[arg(long)]
mxc: Option<Box<MxcUri>>,
mxc: Option<OwnedMxcUri>,
/// - The message event ID which contains the media and thumbnail MXC
/// URLs
#[arg(long)]
event_id: Option<Box<EventId>>,
event_id: Option<OwnedEventId>,
},
/// - Deletes a codeblock list of MXC URLs from our database and on the
@ -57,7 +57,7 @@ pub(super) enum MediaCommand {
/// - Deletes all remote media from the specified remote server. This will
/// always ignore errors by default.
DeleteAllFromServer {
server_name: Box<ServerName>,
server_name: OwnedServerName,
/// Long argument to delete local media
#[arg(long)]

View file

@ -1,7 +1,7 @@
use clap::Subcommand;
use conduwuit::Result;
use futures::StreamExt;
use ruma::{RoomId, UserId, events::room::message::RoomMessageEventContent};
use ruma::{OwnedRoomId, OwnedUserId, events::room::message::RoomMessageEventContent};
use crate::{admin_command, admin_command_dispatch};
@ -12,30 +12,30 @@ pub(crate) enum AccountDataCommand {
/// - Returns all changes to the account data that happened after `since`.
ChangesSince {
/// Full user ID
user_id: Box<UserId>,
user_id: OwnedUserId,
/// UNIX timestamp since (u64)
since: u64,
/// Optional room ID of the account data
room_id: Option<Box<RoomId>>,
room_id: Option<OwnedRoomId>,
},
/// - Searches the account data for a specific kind.
AccountDataGet {
/// Full user ID
user_id: Box<UserId>,
user_id: OwnedUserId,
/// Account data event type
kind: String,
/// Optional room ID of the account data
room_id: Option<Box<RoomId>>,
room_id: Option<OwnedRoomId>,
},
}
#[admin_command]
async fn changes_since(
&self,
user_id: Box<UserId>,
user_id: OwnedUserId,
since: u64,
room_id: Option<Box<RoomId>>,
room_id: Option<OwnedRoomId>,
) -> Result<RoomMessageEventContent> {
let timer = tokio::time::Instant::now();
let results: Vec<_> = self
@ -54,9 +54,9 @@ async fn changes_since(
#[admin_command]
async fn account_data_get(
&self,
user_id: Box<UserId>,
user_id: OwnedUserId,
kind: String,
room_id: Option<Box<RoomId>>,
room_id: Option<OwnedRoomId>,
) -> Result<RoomMessageEventContent> {
let timer = tokio::time::Instant::now();
let results = self

View file

@ -9,7 +9,7 @@ pub(crate) enum AppserviceCommand {
/// - Gets the appservice registration info/details from the ID as a string
GetRegistration {
/// Appservice registration ID
appservice_id: Box<str>,
appservice_id: String,
},
/// - Gets all appservice registrations with their ID and registration info

View file

@ -1,6 +1,6 @@
use clap::Subcommand;
use conduwuit::Result;
use ruma::ServerName;
use ruma::OwnedServerName;
use crate::Command;
@ -16,7 +16,7 @@ pub(crate) enum GlobalsCommand {
/// - This returns an empty `Ok(BTreeMap<..>)` when there are no keys found
/// for the server.
SigningKeysFor {
origin: Box<ServerName>,
origin: OwnedServerName,
},
}

View file

@ -1,7 +1,7 @@
use clap::Subcommand;
use conduwuit::Result;
use futures::StreamExt;
use ruma::UserId;
use ruma::OwnedUserId;
use crate::Command;
@ -11,7 +11,7 @@ pub(crate) enum PresenceCommand {
/// - Returns the latest presence event for the given user.
GetPresence {
/// Full user ID
user_id: Box<UserId>,
user_id: OwnedUserId,
},
/// - Iterator of the most recent presence updates that happened after the

View file

@ -1,6 +1,6 @@
use clap::Subcommand;
use conduwuit::Result;
use ruma::UserId;
use ruma::OwnedUserId;
use crate::Command;
@ -9,7 +9,7 @@ pub(crate) enum PusherCommand {
/// - Returns all the pushers for the user.
GetPushers {
/// Full user ID
user_id: Box<UserId>,
user_id: OwnedUserId,
},
}

View file

@ -1,7 +1,7 @@
use clap::Subcommand;
use conduwuit::Result;
use futures::StreamExt;
use ruma::{RoomAliasId, RoomId};
use ruma::{OwnedRoomAliasId, OwnedRoomId};
use crate::Command;
@ -10,13 +10,13 @@ use crate::Command;
pub(crate) enum RoomAliasCommand {
ResolveLocalAlias {
/// Full room alias
alias: Box<RoomAliasId>,
alias: OwnedRoomAliasId,
},
/// - Iterator of all our local room aliases for the room ID
LocalAliasesForRoom {
/// Full room ID
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
/// - Iterator of all our local aliases in our database with their room IDs

View file

@ -1,78 +1,80 @@
use clap::Subcommand;
use conduwuit::{Error, Result};
use futures::StreamExt;
use ruma::{RoomId, ServerName, UserId, events::room::message::RoomMessageEventContent};
use ruma::{
OwnedRoomId, OwnedServerName, OwnedUserId, events::room::message::RoomMessageEventContent,
};
use crate::Command;
#[derive(Debug, Subcommand)]
pub(crate) enum RoomStateCacheCommand {
ServerInRoom {
server: Box<ServerName>,
room_id: Box<RoomId>,
server: OwnedServerName,
room_id: OwnedRoomId,
},
RoomServers {
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
ServerRooms {
server: Box<ServerName>,
server: OwnedServerName,
},
RoomMembers {
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
LocalUsersInRoom {
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
ActiveLocalUsersInRoom {
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
RoomJoinedCount {
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
RoomInvitedCount {
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
RoomUserOnceJoined {
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
RoomMembersInvited {
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
GetInviteCount {
room_id: Box<RoomId>,
user_id: Box<UserId>,
room_id: OwnedRoomId,
user_id: OwnedUserId,
},
GetLeftCount {
room_id: Box<RoomId>,
user_id: Box<UserId>,
room_id: OwnedRoomId,
user_id: OwnedUserId,
},
RoomsJoined {
user_id: Box<UserId>,
user_id: OwnedUserId,
},
RoomsLeft {
user_id: Box<UserId>,
user_id: OwnedUserId,
},
RoomsInvited {
user_id: Box<UserId>,
user_id: OwnedUserId,
},
InviteState {
user_id: Box<UserId>,
room_id: Box<RoomId>,
user_id: OwnedUserId,
room_id: OwnedRoomId,
},
}

View file

@ -1,7 +1,7 @@
use clap::Subcommand;
use conduwuit::Result;
use futures::StreamExt;
use ruma::{ServerName, UserId, events::room::message::RoomMessageEventContent};
use ruma::{OwnedServerName, OwnedUserId, events::room::message::RoomMessageEventContent};
use service::sending::Destination;
use crate::Command;
@ -27,9 +27,9 @@ pub(crate) enum SendingCommand {
#[arg(short, long)]
appservice_id: Option<String>,
#[arg(short, long)]
server_name: Option<Box<ServerName>>,
server_name: Option<OwnedServerName>,
#[arg(short, long)]
user_id: Option<Box<UserId>>,
user_id: Option<OwnedUserId>,
#[arg(short, long)]
push_key: Option<String>,
},
@ -49,15 +49,15 @@ pub(crate) enum SendingCommand {
#[arg(short, long)]
appservice_id: Option<String>,
#[arg(short, long)]
server_name: Option<Box<ServerName>>,
server_name: Option<OwnedServerName>,
#[arg(short, long)]
user_id: Option<Box<UserId>>,
user_id: Option<OwnedUserId>,
#[arg(short, long)]
push_key: Option<String>,
},
GetLatestEduCount {
server_name: Box<ServerName>,
server_name: OwnedServerName,
},
}
@ -120,7 +120,7 @@ pub(super) async fn reprocess(
| (None, Some(server_name), None, None) => services
.sending
.db
.queued_requests(&Destination::Federation(server_name.into())),
.queued_requests(&Destination::Federation(server_name)),
| (None, None, Some(user_id), Some(push_key)) => {
if push_key.is_empty() {
return Ok(RoomMessageEventContent::text_plain(
@ -132,7 +132,7 @@ pub(super) async fn reprocess(
services
.sending
.db
.queued_requests(&Destination::Push(user_id.into(), push_key))
.queued_requests(&Destination::Push(user_id, push_key))
},
| (Some(_), Some(_), Some(_), Some(_)) => {
return Ok(RoomMessageEventContent::text_plain(
@ -190,7 +190,7 @@ pub(super) async fn reprocess(
| (None, Some(server_name), None, None) => services
.sending
.db
.active_requests_for(&Destination::Federation(server_name.into())),
.active_requests_for(&Destination::Federation(server_name)),
| (None, None, Some(user_id), Some(push_key)) => {
if push_key.is_empty() {
return Ok(RoomMessageEventContent::text_plain(
@ -202,7 +202,7 @@ pub(super) async fn reprocess(
services
.sending
.db
.active_requests_for(&Destination::Push(user_id.into(), push_key))
.active_requests_for(&Destination::Push(user_id, push_key))
},
| (Some(_), Some(_), Some(_), Some(_)) => {
return Ok(RoomMessageEventContent::text_plain(

View file

@ -3,9 +3,7 @@ use std::fmt::Write;
use clap::Subcommand;
use conduwuit::Result;
use futures::StreamExt;
use ruma::{
OwnedRoomAliasId, OwnedRoomId, RoomId, events::room::message::RoomMessageEventContent,
};
use ruma::{OwnedRoomAliasId, OwnedRoomId, events::room::message::RoomMessageEventContent};
use crate::{Command, escape_html};
@ -18,7 +16,7 @@ pub(crate) enum RoomAliasCommand {
force: bool,
/// The room id to set the alias on
room_id: Box<RoomId>,
room_id: OwnedRoomId,
/// The alias localpart to use (`alias`, not `#alias:servername.tld`)
room_alias_localpart: String,
@ -40,7 +38,7 @@ pub(crate) enum RoomAliasCommand {
/// - List aliases currently being used
List {
/// If set, only list the aliases for this room
room_id: Option<Box<RoomId>>,
room_id: Option<OwnedRoomId>,
},
}

View file

@ -1,7 +1,7 @@
use clap::Subcommand;
use conduwuit::Result;
use futures::StreamExt;
use ruma::{RoomId, events::room::message::RoomMessageEventContent};
use ruma::{OwnedRoomId, events::room::message::RoomMessageEventContent};
use crate::{Command, PAGE_SIZE, get_room_info};
@ -10,13 +10,13 @@ pub(crate) enum RoomDirectoryCommand {
/// - Publish a room to the room directory
Publish {
/// The room id of the room to publish
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
/// - Unpublish a room to the room directory
Unpublish {
/// The room id of the room to unpublish
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
/// - List rooms that are published

View file

@ -1,7 +1,7 @@
use clap::Subcommand;
use conduwuit::{Result, utils::ReadyExt};
use futures::StreamExt;
use ruma::{RoomId, events::room::message::RoomMessageEventContent};
use ruma::{OwnedRoomId, events::room::message::RoomMessageEventContent};
use crate::{admin_command, admin_command_dispatch};
@ -10,7 +10,7 @@ use crate::{admin_command, admin_command_dispatch};
pub(crate) enum RoomInfoCommand {
/// - List joined members in a room
ListJoinedMembers {
room_id: Box<RoomId>,
room_id: OwnedRoomId,
/// Lists only our local users in the specified room
#[arg(long)]
@ -22,14 +22,14 @@ pub(crate) enum RoomInfoCommand {
/// Room topics can be huge, so this is in its
/// own separate command
ViewRoomTopic {
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
}
#[admin_command]
async fn list_joined_members(
&self,
room_id: Box<RoomId>,
room_id: OwnedRoomId,
local_only: bool,
) -> Result<RoomMessageEventContent> {
let room_name = self
@ -79,7 +79,7 @@ async fn list_joined_members(
}
#[admin_command]
async fn view_room_topic(&self, room_id: Box<RoomId>) -> Result<RoomMessageEventContent> {
async fn view_room_topic(&self, room_id: OwnedRoomId) -> Result<RoomMessageEventContent> {
let Ok(room_topic) = self
.services
.rooms

View file

@ -7,7 +7,7 @@ use conduwuit::{
};
use futures::StreamExt;
use ruma::{
OwnedRoomId, RoomAliasId, RoomId, RoomOrAliasId,
OwnedRoomId, OwnedRoomOrAliasId, RoomAliasId, RoomId, RoomOrAliasId,
events::room::message::RoomMessageEventContent,
};
@ -24,7 +24,7 @@ pub(crate) enum RoomModerationCommand {
BanRoom {
/// The room in the format of `!roomid:example.com` or a room alias in
/// the format of `#roomalias:example.com`
room: Box<RoomOrAliasId>,
room: OwnedRoomOrAliasId,
},
/// - Bans a list of rooms (room IDs and room aliases) from a newline
@ -36,7 +36,7 @@ pub(crate) enum RoomModerationCommand {
UnbanRoom {
/// The room in the format of `!roomid:example.com` or a room alias in
/// the format of `#roomalias:example.com`
room: Box<RoomOrAliasId>,
room: OwnedRoomOrAliasId,
},
/// - List of all rooms we have banned
@ -49,7 +49,7 @@ pub(crate) enum RoomModerationCommand {
}
#[admin_command]
async fn ban_room(&self, room: Box<RoomOrAliasId>) -> Result<RoomMessageEventContent> {
async fn ban_room(&self, room: OwnedRoomOrAliasId) -> Result<RoomMessageEventContent> {
debug!("Got room alias or ID: {}", room);
let admin_room_alias = &self.services.globals.admin_alias;
@ -363,7 +363,7 @@ async fn ban_list_of_rooms(&self) -> Result<RoomMessageEventContent> {
}
#[admin_command]
async fn unban_room(&self, room: Box<RoomOrAliasId>) -> Result<RoomMessageEventContent> {
async fn unban_room(&self, room: OwnedRoomOrAliasId) -> Result<RoomMessageEventContent> {
let room_id = if room.is_room_id() {
let room_id = match RoomId::parse(&room) {
| Ok(room_id) => room_id,

View file

@ -10,7 +10,7 @@ use conduwuit::{
use conduwuit_api::client::{leave_all_rooms, update_avatar_url, update_displayname};
use futures::StreamExt;
use ruma::{
EventId, OwnedRoomId, OwnedRoomOrAliasId, OwnedUserId, RoomId, UserId,
OwnedEventId, OwnedRoomId, OwnedRoomOrAliasId, OwnedUserId, UserId,
events::{
RoomAccountDataEventType, StateEventType,
room::{
@ -802,7 +802,7 @@ pub(super) async fn make_user_admin(&self, user_id: String) -> Result<RoomMessag
pub(super) async fn put_room_tag(
&self,
user_id: String,
room_id: Box<RoomId>,
room_id: OwnedRoomId,
tag: String,
) -> Result<RoomMessageEventContent> {
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
@ -840,7 +840,7 @@ pub(super) async fn put_room_tag(
pub(super) async fn delete_room_tag(
&self,
user_id: String,
room_id: Box<RoomId>,
room_id: OwnedRoomId,
tag: String,
) -> Result<RoomMessageEventContent> {
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
@ -876,7 +876,7 @@ pub(super) async fn delete_room_tag(
pub(super) async fn get_room_tags(
&self,
user_id: String,
room_id: Box<RoomId>,
room_id: OwnedRoomId,
) -> Result<RoomMessageEventContent> {
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
@ -898,7 +898,7 @@ pub(super) async fn get_room_tags(
#[admin_command]
pub(super) async fn redact_event(
&self,
event_id: Box<EventId>,
event_id: OwnedEventId,
) -> Result<RoomMessageEventContent> {
let Ok(event) = self
.services

View file

@ -2,7 +2,7 @@ mod commands;
use clap::Subcommand;
use conduwuit::Result;
use ruma::{EventId, OwnedRoomOrAliasId, RoomId};
use ruma::{OwnedEventId, OwnedRoomId, OwnedRoomOrAliasId};
use crate::admin_command_dispatch;
@ -102,21 +102,21 @@ pub(super) enum UserCommand {
/// room's internal ID, and the tag name `m.server_notice`.
PutRoomTag {
user_id: String,
room_id: Box<RoomId>,
room_id: OwnedRoomId,
tag: String,
},
/// - Deletes the room tag for the specified user and room ID
DeleteRoomTag {
user_id: String,
room_id: Box<RoomId>,
room_id: OwnedRoomId,
tag: String,
},
/// - Gets all the room tags for the specified user and room ID
GetRoomTags {
user_id: String,
room_id: Box<RoomId>,
room_id: OwnedRoomId,
},
/// - Attempts to forcefully redact the specified event ID from the sender
@ -124,7 +124,7 @@ pub(super) enum UserCommand {
///
/// This is only valid for local users
RedactEvent {
event_id: Box<EventId>,
event_id: OwnedEventId,
},
/// - Force joins a specified list of local users to join the specified