mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-09 14:33:03 +02:00
feat: Force leave remote rooms admin command
This commit is contained in:
parent
d970df5fd2
commit
241371463e
4 changed files with 36 additions and 4 deletions
|
@ -1,8 +1,8 @@
|
||||||
use std::{collections::BTreeMap, fmt::Write as _};
|
use std::{collections::BTreeMap, fmt::Write as _};
|
||||||
|
|
||||||
use api::client::{
|
use api::client::{
|
||||||
full_user_deactivate, join_room_by_id_helper, leave_all_rooms, leave_room, update_avatar_url,
|
full_user_deactivate, join_room_by_id_helper, leave_all_rooms, leave_room, remote_leave_room,
|
||||||
update_displayname,
|
update_avatar_url, update_displayname,
|
||||||
};
|
};
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, debug, debug_warn, error, info, is_equal_to,
|
Err, Result, debug, debug_warn, error, info, is_equal_to,
|
||||||
|
@ -926,3 +926,29 @@ pub(super) async fn redact_event(&self, event_id: OwnedEventId) -> Result {
|
||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
|
pub(super) async fn force_leave_remote_room(
|
||||||
|
&self,
|
||||||
|
user_id: String,
|
||||||
|
room_id: OwnedRoomOrAliasId,
|
||||||
|
) -> Result {
|
||||||
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
|
let (room_id, _) = self
|
||||||
|
.services
|
||||||
|
.rooms
|
||||||
|
.alias
|
||||||
|
.resolve_with_servers(&room_id, None)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
self.services.globals.user_is_local(&user_id),
|
||||||
|
"Parsed user_id must be a local user"
|
||||||
|
);
|
||||||
|
remote_leave_room(self.services, &user_id, &room_id, None)
|
||||||
|
.boxed()
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
self.write_str(&format!("{user_id} has been joined to {room_id}.",))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
|
@ -103,6 +103,12 @@ pub enum UserCommand {
|
||||||
room_id: OwnedRoomOrAliasId,
|
room_id: OwnedRoomOrAliasId,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// - Manually leave a remote room for a local user.
|
||||||
|
ForceLeaveRemoteRoom {
|
||||||
|
user_id: String,
|
||||||
|
room_id: OwnedRoomOrAliasId,
|
||||||
|
},
|
||||||
|
|
||||||
/// - Forces the specified user to drop their power levels to the room
|
/// - Forces the specified user to drop their power levels to the room
|
||||||
/// default, if their permissions allow and the auth check permits
|
/// default, if their permissions allow and the auth check permits
|
||||||
ForceDemote {
|
ForceDemote {
|
||||||
|
|
|
@ -215,7 +215,7 @@ pub async fn leave_room(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn remote_leave_room(
|
pub async fn remote_leave_room(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub(crate) use self::{
|
||||||
};
|
};
|
||||||
pub use self::{
|
pub use self::{
|
||||||
join::join_room_by_id_helper,
|
join::join_room_by_id_helper,
|
||||||
leave::{leave_all_rooms, leave_room},
|
leave::{leave_all_rooms, leave_room, remote_leave_room},
|
||||||
};
|
};
|
||||||
use crate::{Ruma, client::full_user_deactivate};
|
use crate::{Ruma, client::full_user_deactivate};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue