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.
67Mark all rooms as read. 67Mark all rooms as read.
68.It Sy ":welcome" 68.It Sy ":welcome"
69View the startup Welcome window. 69View the startup Welcome window.
70.It Sy ":forget"
71Remove all left rooms from the internal database.
70.El 72.El
71 73
72.Sh "E2EE COMMANDS" 74.Sh "E2EE COMMANDS"
src/base.rs +2
@@ -491,6 +491,8 @@ pub enum HomeserverAction {
491 /// Create a new room with an optional localpart. 491 /// Create a new room with an optional localpart.
492 CreateRoom(Option<String>, CreateRoomType, CreateRoomFlags), 492 CreateRoom(Option<String>, CreateRoomType, CreateRoomFlags),
493 Logout(String, bool), 493 Logout(String, bool),
494 /// Forget all left rooms
495 Forget,
494} 496}
495 497
496/// An action performed against the user's room keys. 498/// 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 {
200 return Ok(step); 200 return Ok(step);
201} 201}
202 202
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
203fn iamb_cancel(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { 214fn iamb_cancel(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
204 if !desc.arg.text.is_empty() { 215 if !desc.arg.text.is_empty() {
205 return Result::Err(CommandError::InvalidArgument); 216 return Result::Err(CommandError::InvalidArgument);
@@ -731,6 +742,11 @@ fn add_iamb_commands(cmds: &mut ProgramCommands) {
731 aliases: vec![], 742 aliases: vec![],
732 f: iamb_leave, 743 f: iamb_leave,
733 }); 744 });
745 cmds.add_command(ProgramCommand {
746 name: "forget".into(),
747 aliases: vec![],
748 f: iamb_forget,
749 });
734 cmds.add_command(ProgramCommand { 750 cmds.add_command(ProgramCommand {
735 name: "members".into(), 751 name: "members".into(),
736 aliases: vec![], 752 aliases: vec![],
src/main.rs +7
@@ -663,6 +663,13 @@ impl Application {
663 663
664 Err(UIError::NeedConfirm(prompt)) 664 Err(UIError::NeedConfirm(prompt))
665 }, 665 },
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 },
666 } 673 }
667 } 674 }
668 675