Commit e021d4a55d

e021d4a55d3ef6a33f5b50a95174a74869ca856a

parent: b01dbe5a5d

Unregistered key

vaw <git@nlih.de> · 2025-10-25 20:41 UTC
committer: <noreply@github.com>

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

Layout: unified · split

docs/iamb.1 +2
@@ -67,6 +67,8 @@ View a list of unread rooms.
6767Mark all rooms as read.
6868.It Sy ":welcome"
6969View the startup Welcome window.
70.It Sy ":forget"
71Remove all left rooms from the internal database.
7072.El
7173
7274.Sh "E2EE COMMANDS"
src/base.rs +2
@@ -491,6 +491,8 @@ pub enum HomeserverAction {
491491 /// Create a new room with an optional localpart.
492492 CreateRoom(Option<String>, CreateRoomType, CreateRoomFlags),
493493 Logout(String, bool),
494 /// Forget all left rooms
495 Forget,
494496}
495497
496498/// An action performed against the user's room keys.
src/commands.rs +16
@@ -200,6 +200,17 @@ fn iamb_leave(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
200200 return Ok(step);
201201}
202202
203fn iamb_forget(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
204 if !desc.arg.text.is_empty() {
205 return Result::Err(CommandError::InvalidArgument);
206 }
207
208 let forget = IambAction::Homeserver(HomeserverAction::Forget);
209 let step = CommandStep::Continue(forget.into(), ctx.context.clone());
210
211 return Ok(step);
212}
213
203214fn iamb_cancel(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
204215 if !desc.arg.text.is_empty() {
205216 return Result::Err(CommandError::InvalidArgument);
@@ -731,6 +742,11 @@ fn add_iamb_commands(cmds: &mut ProgramCommands) {
731742 aliases: vec![],
732743 f: iamb_leave,
733744 });
745 cmds.add_command(ProgramCommand {
746 name: "forget".into(),
747 aliases: vec![],
748 f: iamb_forget,
749 });
734750 cmds.add_command(ProgramCommand {
735751 name: "members".into(),
736752 aliases: vec![],
src/main.rs +7
@@ -663,6 +663,13 @@ impl Application {
663663
664664 Err(UIError::NeedConfirm(prompt))
665665 },
666 HomeserverAction::Forget => {
667 let client = &store.application.worker.client;
668 for room in client.left_rooms() {
669 room.forget().await.map_err(IambError::from)?;
670 }
671 Ok(vec![])
672 },
666673 }
667674 }
668675