Add :forget to forget all left rooms (#507)
This commit is contained in:
@@ -67,6 +67,8 @@ View a list of unread rooms.
|
|||||||
Mark all rooms as read.
|
Mark all rooms as read.
|
||||||
.It Sy ":welcome"
|
.It Sy ":welcome"
|
||||||
View the startup Welcome window.
|
View the startup Welcome window.
|
||||||
|
.It Sy ":forget"
|
||||||
|
Remove all left rooms from the internal database.
|
||||||
.El
|
.El
|
||||||
|
|
||||||
.Sh "E2EE COMMANDS"
|
.Sh "E2EE COMMANDS"
|
||||||
|
|||||||
@@ -491,6 +491,8 @@ pub enum HomeserverAction {
|
|||||||
/// Create a new room with an optional localpart.
|
/// Create a new room with an optional localpart.
|
||||||
CreateRoom(Option<String>, CreateRoomType, CreateRoomFlags),
|
CreateRoom(Option<String>, CreateRoomType, CreateRoomFlags),
|
||||||
Logout(String, bool),
|
Logout(String, bool),
|
||||||
|
/// Forget all left rooms
|
||||||
|
Forget,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An action performed against the user's room keys.
|
/// An action performed against the user's room keys.
|
||||||
|
|||||||
@@ -200,6 +200,17 @@ fn iamb_leave(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||||||
return Ok(step);
|
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 {
|
fn iamb_cancel(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
||||||
if !desc.arg.text.is_empty() {
|
if !desc.arg.text.is_empty() {
|
||||||
return Result::Err(CommandError::InvalidArgument);
|
return Result::Err(CommandError::InvalidArgument);
|
||||||
@@ -731,6 +742,11 @@ fn add_iamb_commands(cmds: &mut ProgramCommands) {
|
|||||||
aliases: vec![],
|
aliases: vec![],
|
||||||
f: iamb_leave,
|
f: iamb_leave,
|
||||||
});
|
});
|
||||||
|
cmds.add_command(ProgramCommand {
|
||||||
|
name: "forget".into(),
|
||||||
|
aliases: vec![],
|
||||||
|
f: iamb_forget,
|
||||||
|
});
|
||||||
cmds.add_command(ProgramCommand {
|
cmds.add_command(ProgramCommand {
|
||||||
name: "members".into(),
|
name: "members".into(),
|
||||||
aliases: vec![],
|
aliases: vec![],
|
||||||
|
|||||||
@@ -663,6 +663,13 @@ impl Application {
|
|||||||
|
|
||||||
Err(UIError::NeedConfirm(prompt))
|
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![])
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user