Add :forget to forget all left rooms (#507)

This commit is contained in:
vaw
2025-10-25 20:41:34 +00:00
committed by GitHub
parent b01dbe5a5d
commit e021d4a55d
4 changed files with 27 additions and 0 deletions

View File

@@ -67,6 +67,8 @@ View a list of unread rooms.
Mark all rooms as read.
.It Sy ":welcome"
View the startup Welcome window.
.It Sy ":forget"
Remove all left rooms from the internal database.
.El
.Sh "E2EE COMMANDS"

View File

@@ -491,6 +491,8 @@ pub enum HomeserverAction {
/// Create a new room with an optional localpart.
CreateRoom(Option<String>, CreateRoomType, CreateRoomFlags),
Logout(String, bool),
/// Forget all left rooms
Forget,
}
/// An action performed against the user's room keys.

View File

@@ -200,6 +200,17 @@ fn iamb_leave(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
return Ok(step);
}
fn iamb_forget(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
if !desc.arg.text.is_empty() {
return Result::Err(CommandError::InvalidArgument);
}
let forget = IambAction::Homeserver(HomeserverAction::Forget);
let step = CommandStep::Continue(forget.into(), ctx.context.clone());
return Ok(step);
}
fn iamb_cancel(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
if !desc.arg.text.is_empty() {
return Result::Err(CommandError::InvalidArgument);
@@ -731,6 +742,11 @@ fn add_iamb_commands(cmds: &mut ProgramCommands) {
aliases: vec![],
f: iamb_leave,
});
cmds.add_command(ProgramCommand {
name: "forget".into(),
aliases: vec![],
f: iamb_forget,
});
cmds.add_command(ProgramCommand {
name: "members".into(),
aliases: vec![],

View File

@@ -663,6 +663,13 @@ impl Application {
Err(UIError::NeedConfirm(prompt))
},
HomeserverAction::Forget => {
let client = &store.application.worker.client;
for room in client.left_rooms() {
room.forget().await.map_err(IambError::from)?;
}
Ok(vec![])
},
}
}