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

View file

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

View file

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

View file

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

View file

@ -5,7 +5,7 @@ use conduwuit::{
}; };
use conduwuit_service::media::Dim; use conduwuit_service::media::Dim;
use ruma::{ use ruma::{
EventId, Mxc, MxcUri, OwnedMxcUri, OwnedServerName, ServerName, Mxc, OwnedEventId, OwnedMxcUri, OwnedServerName,
events::room::message::RoomMessageEventContent, events::room::message::RoomMessageEventContent,
}; };
@ -14,8 +14,8 @@ use crate::{admin_command, utils::parse_local_user_id};
#[admin_command] #[admin_command]
pub(super) async fn delete( pub(super) async fn delete(
&self, &self,
mxc: Option<Box<MxcUri>>, mxc: Option<OwnedMxcUri>,
event_id: Option<Box<EventId>>, event_id: Option<OwnedEventId>,
) -> Result<RoomMessageEventContent> { ) -> Result<RoomMessageEventContent> {
if event_id.is_some() && mxc.is_some() { if event_id.is_some() && mxc.is_some() {
return Ok(RoomMessageEventContent::text_plain( return Ok(RoomMessageEventContent::text_plain(
@ -282,7 +282,7 @@ pub(super) async fn delete_all_from_user(
#[admin_command] #[admin_command]
pub(super) async fn delete_all_from_server( pub(super) async fn delete_all_from_server(
&self, &self,
server_name: Box<ServerName>, server_name: OwnedServerName,
yes_i_want_to_delete_local_media: bool, yes_i_want_to_delete_local_media: bool,
) -> Result<RoomMessageEventContent> { ) -> Result<RoomMessageEventContent> {
if server_name == self.services.globals.server_name() && !yes_i_want_to_delete_local_media { 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 clap::Subcommand;
use conduwuit::Result; use conduwuit::Result;
use ruma::{EventId, MxcUri, OwnedMxcUri, OwnedServerName, ServerName}; use ruma::{OwnedEventId, OwnedMxcUri, OwnedServerName};
use crate::admin_command_dispatch; use crate::admin_command_dispatch;
@ -15,12 +15,12 @@ pub(super) enum MediaCommand {
Delete { Delete {
/// The MXC URL to delete /// The MXC URL to delete
#[arg(long)] #[arg(long)]
mxc: Option<Box<MxcUri>>, mxc: Option<OwnedMxcUri>,
/// - The message event ID which contains the media and thumbnail MXC /// - The message event ID which contains the media and thumbnail MXC
/// URLs /// URLs
#[arg(long)] #[arg(long)]
event_id: Option<Box<EventId>>, event_id: Option<OwnedEventId>,
}, },
/// - Deletes a codeblock list of MXC URLs from our database and on the /// - 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 /// - Deletes all remote media from the specified remote server. This will
/// always ignore errors by default. /// always ignore errors by default.
DeleteAllFromServer { DeleteAllFromServer {
server_name: Box<ServerName>, server_name: OwnedServerName,
/// Long argument to delete local media /// Long argument to delete local media
#[arg(long)] #[arg(long)]

View file

@ -1,7 +1,7 @@
use clap::Subcommand; use clap::Subcommand;
use conduwuit::Result; use conduwuit::Result;
use futures::StreamExt; 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}; 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`. /// - Returns all changes to the account data that happened after `since`.
ChangesSince { ChangesSince {
/// Full user ID /// Full user ID
user_id: Box<UserId>, user_id: OwnedUserId,
/// UNIX timestamp since (u64) /// UNIX timestamp since (u64)
since: u64, since: u64,
/// Optional room ID of the account data /// Optional room ID of the account data
room_id: Option<Box<RoomId>>, room_id: Option<OwnedRoomId>,
}, },
/// - Searches the account data for a specific kind. /// - Searches the account data for a specific kind.
AccountDataGet { AccountDataGet {
/// Full user ID /// Full user ID
user_id: Box<UserId>, user_id: OwnedUserId,
/// Account data event type /// Account data event type
kind: String, kind: String,
/// Optional room ID of the account data /// Optional room ID of the account data
room_id: Option<Box<RoomId>>, room_id: Option<OwnedRoomId>,
}, },
} }
#[admin_command] #[admin_command]
async fn changes_since( async fn changes_since(
&self, &self,
user_id: Box<UserId>, user_id: OwnedUserId,
since: u64, since: u64,
room_id: Option<Box<RoomId>>, room_id: Option<OwnedRoomId>,
) -> Result<RoomMessageEventContent> { ) -> Result<RoomMessageEventContent> {
let timer = tokio::time::Instant::now(); let timer = tokio::time::Instant::now();
let results: Vec<_> = self let results: Vec<_> = self
@ -54,9 +54,9 @@ async fn changes_since(
#[admin_command] #[admin_command]
async fn account_data_get( async fn account_data_get(
&self, &self,
user_id: Box<UserId>, user_id: OwnedUserId,
kind: String, kind: String,
room_id: Option<Box<RoomId>>, room_id: Option<OwnedRoomId>,
) -> Result<RoomMessageEventContent> { ) -> Result<RoomMessageEventContent> {
let timer = tokio::time::Instant::now(); let timer = tokio::time::Instant::now();
let results = self 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 /// - Gets the appservice registration info/details from the ID as a string
GetRegistration { GetRegistration {
/// Appservice registration ID /// Appservice registration ID
appservice_id: Box<str>, appservice_id: String,
}, },
/// - Gets all appservice registrations with their ID and registration info /// - Gets all appservice registrations with their ID and registration info

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,9 +3,7 @@ use std::fmt::Write;
use clap::Subcommand; use clap::Subcommand;
use conduwuit::Result; use conduwuit::Result;
use futures::StreamExt; use futures::StreamExt;
use ruma::{ use ruma::{OwnedRoomAliasId, OwnedRoomId, events::room::message::RoomMessageEventContent};
OwnedRoomAliasId, OwnedRoomId, RoomId, events::room::message::RoomMessageEventContent,
};
use crate::{Command, escape_html}; use crate::{Command, escape_html};
@ -18,7 +16,7 @@ pub(crate) enum RoomAliasCommand {
force: bool, force: bool,
/// The room id to set the alias on /// 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`) /// The alias localpart to use (`alias`, not `#alias:servername.tld`)
room_alias_localpart: String, room_alias_localpart: String,
@ -40,7 +38,7 @@ pub(crate) enum RoomAliasCommand {
/// - List aliases currently being used /// - List aliases currently being used
List { List {
/// If set, only list the aliases for this room /// 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 clap::Subcommand;
use conduwuit::Result; use conduwuit::Result;
use futures::StreamExt; 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}; use crate::{Command, PAGE_SIZE, get_room_info};
@ -10,13 +10,13 @@ pub(crate) enum RoomDirectoryCommand {
/// - Publish a room to the room directory /// - Publish a room to the room directory
Publish { Publish {
/// The room id of the room to publish /// The room id of the room to publish
room_id: Box<RoomId>, room_id: OwnedRoomId,
}, },
/// - Unpublish a room to the room directory /// - Unpublish a room to the room directory
Unpublish { Unpublish {
/// The room id of the room to unpublish /// The room id of the room to unpublish
room_id: Box<RoomId>, room_id: OwnedRoomId,
}, },
/// - List rooms that are published /// - List rooms that are published

View file

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

View file

@ -7,7 +7,7 @@ use conduwuit::{
}; };
use futures::StreamExt; use futures::StreamExt;
use ruma::{ use ruma::{
OwnedRoomId, RoomAliasId, RoomId, RoomOrAliasId, OwnedRoomId, OwnedRoomOrAliasId, RoomAliasId, RoomId, RoomOrAliasId,
events::room::message::RoomMessageEventContent, events::room::message::RoomMessageEventContent,
}; };
@ -24,7 +24,7 @@ pub(crate) enum RoomModerationCommand {
BanRoom { BanRoom {
/// The room in the format of `!roomid:example.com` or a room alias in /// The room in the format of `!roomid:example.com` or a room alias in
/// the format of `#roomalias:example.com` /// the format of `#roomalias:example.com`
room: Box<RoomOrAliasId>, room: OwnedRoomOrAliasId,
}, },
/// - Bans a list of rooms (room IDs and room aliases) from a newline /// - Bans a list of rooms (room IDs and room aliases) from a newline
@ -36,7 +36,7 @@ pub(crate) enum RoomModerationCommand {
UnbanRoom { UnbanRoom {
/// The room in the format of `!roomid:example.com` or a room alias in /// The room in the format of `!roomid:example.com` or a room alias in
/// the format of `#roomalias:example.com` /// the format of `#roomalias:example.com`
room: Box<RoomOrAliasId>, room: OwnedRoomOrAliasId,
}, },
/// - List of all rooms we have banned /// - List of all rooms we have banned
@ -49,7 +49,7 @@ pub(crate) enum RoomModerationCommand {
} }
#[admin_command] #[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); debug!("Got room alias or ID: {}", room);
let admin_room_alias = &self.services.globals.admin_alias; let admin_room_alias = &self.services.globals.admin_alias;
@ -363,7 +363,7 @@ async fn ban_list_of_rooms(&self) -> Result<RoomMessageEventContent> {
} }
#[admin_command] #[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 = if room.is_room_id() {
let room_id = match RoomId::parse(&room) { let room_id = match RoomId::parse(&room) {
| Ok(room_id) => room_id, | 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 conduwuit_api::client::{leave_all_rooms, update_avatar_url, update_displayname};
use futures::StreamExt; use futures::StreamExt;
use ruma::{ use ruma::{
EventId, OwnedRoomId, OwnedRoomOrAliasId, OwnedUserId, RoomId, UserId, OwnedEventId, OwnedRoomId, OwnedRoomOrAliasId, OwnedUserId, UserId,
events::{ events::{
RoomAccountDataEventType, StateEventType, RoomAccountDataEventType, StateEventType,
room::{ 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( pub(super) async fn put_room_tag(
&self, &self,
user_id: String, user_id: String,
room_id: Box<RoomId>, room_id: OwnedRoomId,
tag: String, tag: String,
) -> Result<RoomMessageEventContent> { ) -> Result<RoomMessageEventContent> {
let user_id = parse_active_local_user_id(self.services, &user_id).await?; 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( pub(super) async fn delete_room_tag(
&self, &self,
user_id: String, user_id: String,
room_id: Box<RoomId>, room_id: OwnedRoomId,
tag: String, tag: String,
) -> Result<RoomMessageEventContent> { ) -> Result<RoomMessageEventContent> {
let user_id = parse_active_local_user_id(self.services, &user_id).await?; 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( pub(super) async fn get_room_tags(
&self, &self,
user_id: String, user_id: String,
room_id: Box<RoomId>, room_id: OwnedRoomId,
) -> Result<RoomMessageEventContent> { ) -> Result<RoomMessageEventContent> {
let user_id = parse_active_local_user_id(self.services, &user_id).await?; 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] #[admin_command]
pub(super) async fn redact_event( pub(super) async fn redact_event(
&self, &self,
event_id: Box<EventId>, event_id: OwnedEventId,
) -> Result<RoomMessageEventContent> { ) -> Result<RoomMessageEventContent> {
let Ok(event) = self let Ok(event) = self
.services .services

View file

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