Commit 3ea75bac19
Unregistered key
Layout: unified · split
Cargo.lock +1
| @@ -2386,6 +2386,7 @@ dependencies = [ | ||
| 2386 | 2386 | "linkify", |
| 2387 | 2387 | "markup5ever_rcdom", |
| 2388 | 2388 | "matrix-sdk", |
| 2389 | "matrix-sdk-base", | |
| 2389 | 2390 | "matrix-sdk-crypto", |
| 2390 | 2391 | "mime", |
| 2391 | 2392 | "mime_guess", |
Cargo.toml +3
| @@ -90,6 +90,9 @@ version = "0.0.25" | ||
| 90 | 90 | #git = "https://github.com/ulyssa/modalkit" |
| 91 | 91 | #rev = "e40dbb0bfeabe4cfd08facd2acb446080a330d75" |
| 92 | 92 | |
| 93 | [dependencies.matrix-sdk-base] | |
| 94 | version = "0.18.0" | |
| 95 | ||
| 93 | 96 | [dependencies.matrix-sdk] |
| 94 | 97 | version = "0.18.0" |
| 95 | 98 | default-features = false |
docs/iamb.1 +8
| @@ -144,6 +144,14 @@ Reject an invitation to the currently focused room. | ||
| 144 | 144 | Send an invitation to a user to join the currently focused room. |
| 145 | 145 | .It Sy ":join [room]" |
| 146 | 146 | Join a room or open it if you are already joined. |
| 147 | .It Sy ":knock accept [user]" | |
| 148 | Accept a knock from the specified user in the currently focused room. | |
| 149 | .It Sy ":knock ban [user] [reason]" | |
| 150 | Reject a knock from the specified user to the currently focused room, and ban them with an optional reason. | |
| 151 | .It Sy ":knock reject [user] [reason]" | |
| 152 | Reject a knock from the specified user to the currently focused room with an optional reason. | |
| 153 | .It Sy ":knock send [room] [reason]" | |
| 154 | Send an invitation to a user to join the currently focused room with an optional reason. | |
| 147 | 155 | .It Sy ":leave" |
| 148 | 156 | Leave the currently focused room. |
| 149 | 157 | .It Sy ":members" |
docs/iamb.5 +1 −1
| @@ -485,7 +485,7 @@ How to sort the | ||
| 485 | 485 | .Sy :members |
| 486 | 486 | window. |
| 487 | 487 | Defaults to |
| 488 | .Sy ["power",\ "id"] . | |
| 488 | .Sy ["power",\ "knock",\ "~invite",\ "id"] . | |
| 489 | 489 | .El |
| 490 | 490 | .Pp |
| 491 | 491 | The available values for sorting rooms are: |
src/base.rs +29 −6
| @@ -13,12 +13,6 @@ use std::time::{Duration, Instant}; | ||
| 13 | 13 | |
| 14 | 14 | use emojis::Emoji; |
| 15 | 15 | |
| 16 | use matrix_sdk::ruma::events::OriginalMessageLikeEvent; | |
| 17 | use matrix_sdk::ruma::events::receipt::ReceiptThread; | |
| 18 | use matrix_sdk::ruma::events::room::MediaSource; | |
| 19 | use matrix_sdk::ruma::events::room::message::MessageType; | |
| 20 | use matrix_sdk::ruma::events::sticker::{StickerEvent, StickerEventContent}; | |
| 21 | use matrix_sdk::ruma::{OwnedMxcUri, OwnedTransactionId, RoomVersionId}; | |
| 22 | 16 | use ratatui::{ |
| 23 | 17 | buffer::Buffer, |
| 24 | 18 | layout::{Alignment, Rect}, |
| @@ -44,17 +38,25 @@ use matrix_sdk::{ | ||
| 44 | 38 | ruma::{ |
| 45 | 39 | EventId, |
| 46 | 40 | OwnedEventId, |
| 41 | OwnedMxcUri, | |
| 47 | 42 | OwnedRoomId, |
| 43 | OwnedRoomOrAliasId, | |
| 44 | OwnedTransactionId, | |
| 48 | 45 | OwnedUserId, |
| 49 | 46 | RoomId, |
| 47 | RoomVersionId, | |
| 50 | 48 | UserId, |
| 51 | 49 | events::{ |
| 52 | 50 | AnySyncStateEvent, |
| 53 | 51 | MessageLikeEvent, |
| 52 | OriginalMessageLikeEvent, | |
| 54 | 53 | reaction::ReactionEvent, |
| 54 | receipt::ReceiptThread, | |
| 55 | 55 | relation::{Replacement, Thread}, |
| 56 | room::MediaSource, | |
| 56 | 57 | room::encrypted::RoomEncryptedEvent, |
| 57 | 58 | room::message::{ |
| 59 | MessageType, | |
| 58 | 60 | OriginalRoomMessageEvent, |
| 59 | 61 | Relation, |
| 60 | 62 | RoomMessageEvent, |
| @@ -62,6 +64,7 @@ use matrix_sdk::{ | ||
| 62 | 64 | RoomMessageEventContentWithoutRelation, |
| 63 | 65 | }, |
| 64 | 66 | room::redaction::{OriginalSyncRoomRedactionEvent, SyncRoomRedactionEvent}, |
| 67 | sticker::{StickerEvent, StickerEventContent}, | |
| 65 | 68 | tag::{TagName, Tags}, |
| 66 | 69 | }, |
| 67 | 70 | presence::PresenceState, |
| @@ -283,6 +286,8 @@ pub enum SortFieldUser { | ||
| 283 | 286 | UserId, |
| 284 | 287 | LocalPart, |
| 285 | 288 | Server, |
| 289 | Knock, | |
| 290 | Invite, | |
| 286 | 291 | } |
| 287 | 292 | |
| 288 | 293 | /// Whether to use the default sort direction for a field, or to reverse it. |
| @@ -389,6 +394,8 @@ impl Visitor<'_> for SortUserVisitor { | ||
| 389 | 394 | "localpart" => SortFieldUser::LocalPart, |
| 390 | 395 | "server" => SortFieldUser::Server, |
| 391 | 396 | "power" => SortFieldUser::PowerLevel, |
| 397 | "knock" => SortFieldUser::Knock, | |
| 398 | "invite" => SortFieldUser::Invite, | |
| 392 | 399 | _ => { |
| 393 | 400 | let msg = format!("Unknown sort field: {value:?}"); |
| 394 | 401 | return Err(E::custom(msg)); |
| @@ -469,6 +476,16 @@ pub enum RoomAction { | ||
| 469 | 476 | /// Invite a user to this room. |
| 470 | 477 | InviteSend(OwnedUserId), |
| 471 | 478 | |
| 479 | /// Accept a knock from someone who wants to join this room. | |
| 480 | KnockAccept(OwnedUserId), | |
| 481 | ||
| 482 | /// Reject a knock from someone who wants to join this room. | |
| 483 | KnockReject(OwnedUserId, Option<String>), | |
| 484 | ||
| 485 | /// Reject a knock from someone who wants to join this room and ban them | |
| 486 | /// to prevent them from being able to try knocking again. | |
| 487 | KnockBan(OwnedUserId, Option<String>), | |
| 488 | ||
| 472 | 489 | /// Leave this room. |
| 473 | 490 | Leave(bool), |
| 474 | 491 | |
| @@ -523,7 +540,13 @@ pub enum SendAction { | ||
| 523 | 540 | pub enum HomeserverAction { |
| 524 | 541 | /// Create a new room with an optional localpart. |
| 525 | 542 | CreateRoom(Option<String>, CreateRoomType, CreateRoomFlags), |
| 543 | ||
| 544 | /// "Knock" on a room, aka "request to join". | |
| 545 | KnockSend(OwnedRoomOrAliasId, Option<String>), | |
| 546 | ||
| 547 | /// Logout the current iamb session on the homeserver. | |
| 526 | 548 | Logout(String, bool), |
| 549 | ||
| 527 | 550 | /// Forget all left rooms |
| 528 | 551 | Forget, |
| 529 | 552 | } |
src/commands.rs +69 −1
| @@ -4,7 +4,13 @@ | ||
| 4 | 4 | //! [modalkit::env::vim::command] for additional Vim commands we pull in. |
| 5 | 5 | use std::{convert::TryFrom, str::FromStr as _}; |
| 6 | 6 | |
| 7 | use matrix_sdk::ruma::{OwnedRoomId, OwnedUserId, RoomVersionId, events::tag::TagName}; | |
| 7 | use matrix_sdk::ruma::{ | |
| 8 | OwnedRoomId, | |
| 9 | OwnedRoomOrAliasId, | |
| 10 | OwnedUserId, | |
| 11 | RoomVersionId, | |
| 12 | events::tag::TagName, | |
| 13 | }; | |
| 8 | 14 | |
| 9 | 15 | use modalkit::{ |
| 10 | 16 | commands::{CommandError, CommandResult, CommandStep}, |
| @@ -128,6 +134,63 @@ fn iamb_keys(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 128 | 134 | return Ok(step); |
| 129 | 135 | } |
| 130 | 136 | |
| 137 | fn iamb_knock(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | |
| 138 | let mut args = desc.arg.strings()?; | |
| 139 | ||
| 140 | if args.len() < 2 || args.len() > 3 { | |
| 141 | return Err(CommandError::InvalidArgument); | |
| 142 | } | |
| 143 | ||
| 144 | let cmd = args.remove(0); | |
| 145 | let arg = args.remove(0); | |
| 146 | let reason = args.pop(); | |
| 147 | ||
| 148 | let act: IambAction = match (cmd.as_str(), arg, reason) { | |
| 149 | // :knock send #room:example.org "reason" | |
| 150 | ("send", alias, reason) => { | |
| 151 | let alias = OwnedRoomOrAliasId::from_str(&alias).map_err(|e| { | |
| 152 | CommandError::Error(format!( | |
| 153 | "{alias:?} is not a valid alias or room identifier: {e}" | |
| 154 | )) | |
| 155 | })?; | |
| 156 | HomeserverAction::KnockSend(alias, reason).into() | |
| 157 | }, | |
| 158 | ||
| 159 | // :knock accept @user:example.org | |
| 160 | ("accept", user, None) => { | |
| 161 | let user = OwnedUserId::from_str(&user).map_err(|e| { | |
| 162 | CommandError::Error(format!("{user:?} is not a valid user identifier: {e}")) | |
| 163 | })?; | |
| 164 | RoomAction::KnockAccept(user).into() | |
| 165 | }, | |
| 166 | ("accept", _, Some(_)) => return Err(CommandError::InvalidArgument), | |
| 167 | ||
| 168 | // :knock reject @user:example.org "reason" | |
| 169 | ("reject", user, reason) => { | |
| 170 | let user = OwnedUserId::from_str(&user).map_err(|e| { | |
| 171 | CommandError::Error(format!("{user:?} is not a valid user identifier: {e}")) | |
| 172 | })?; | |
| 173 | RoomAction::KnockReject(user, reason).into() | |
| 174 | }, | |
| 175 | ||
| 176 | // :knock ban @user:example.org "reason" | |
| 177 | ("ban", user, reason) => { | |
| 178 | let user = OwnedUserId::from_str(&user).map_err(|e| { | |
| 179 | CommandError::Error(format!("{user:?} is not a valid user identifier: {e}")) | |
| 180 | })?; | |
| 181 | RoomAction::KnockBan(user, reason).into() | |
| 182 | }, | |
| 183 | ||
| 184 | (cmd, _, _) => { | |
| 185 | return Err(CommandError::Error(format!("unrecognized `knock` subcommand: {cmd:?}"))); | |
| 186 | }, | |
| 187 | }; | |
| 188 | ||
| 189 | let step = CommandStep::Continue(act.into(), ctx.context.clone()); | |
| 190 | ||
| 191 | return Ok(step); | |
| 192 | } | |
| 193 | ||
| 131 | 194 | fn iamb_verify(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { |
| 132 | 195 | let mut args = desc.arg.strings()?; |
| 133 | 196 | |
| @@ -858,6 +921,11 @@ fn add_iamb_commands(cmds: &mut ProgramCommands) { | ||
| 858 | 921 | }); |
| 859 | 922 | cmds.add_command(ProgramCommand { name: "join".into(), aliases: vec![], f: iamb_join }); |
| 860 | 923 | cmds.add_command(ProgramCommand { name: "keys".into(), aliases: vec![], f: iamb_keys }); |
| 924 | cmds.add_command(ProgramCommand { | |
| 925 | name: "knock".into(), | |
| 926 | aliases: vec![], | |
| 927 | f: iamb_knock, | |
| 928 | }); | |
| 861 | 929 | cmds.add_command(ProgramCommand { |
| 862 | 930 | name: "leave".into(), |
| 863 | 931 | aliases: vec![], |
src/config.rs +3 −1
| @@ -47,8 +47,10 @@ macro_rules! usage { | ||
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | const DEFAULT_MEMBERS_SORT: [SortColumn<SortFieldUser>; 2] = [ | |
| 50 | const DEFAULT_MEMBERS_SORT: [SortColumn<SortFieldUser>; 4] = [ | |
| 51 | 51 | SortColumn(SortFieldUser::PowerLevel, SortOrder::Ascending), |
| 52 | SortColumn(SortFieldUser::Knock, SortOrder::Ascending), | |
| 53 | SortColumn(SortFieldUser::Invite, SortOrder::Descending), | |
| 52 | 54 | SortColumn(SortFieldUser::UserId, SortOrder::Ascending), |
| 53 | 55 | ]; |
| 54 | 56 | |
src/main.rs +9
| @@ -651,6 +651,15 @@ impl Application { | ||
| 651 | 651 | |
| 652 | 652 | Ok(vec![(action.into(), ctx)]) |
| 653 | 653 | }, |
| 654 | HomeserverAction::KnockSend(alias, reason) => { | |
| 655 | let _ = self | |
| 656 | .worker | |
| 657 | .client | |
| 658 | .knock(alias, reason, vec![]) | |
| 659 | .await | |
| 660 | .map_err(IambError::from)?; | |
| 661 | Ok(vec![]) | |
| 662 | }, | |
| 654 | 663 | HomeserverAction::Logout(user, true) => { |
| 655 | 664 | self.worker.logout(user)?; |
| 656 | 665 | let flags = CloseFlags::QUIT | CloseFlags::FORCE; |
src/windows/mod.rs +28 −3
| @@ -128,6 +128,7 @@ fn selected_text(s: &str, selected: bool) -> Text<'_> { | ||
| 128 | 128 | fn name_and_labels<'a>( |
| 129 | 129 | name: &'a str, |
| 130 | 130 | unread: &UnreadInfo, |
| 131 | room: &MatrixRoom, | |
| 131 | 132 | style: Style, |
| 132 | 133 | ) -> (Span<'a>, Vec<Vec<Span<'static>>>) { |
| 133 | 134 | // TODO: use different colors for "mention", "notification", "muted room" |
| @@ -141,6 +142,14 @@ fn name_and_labels<'a>( | ||
| 141 | 142 | |
| 142 | 143 | let mut labels = vec![]; |
| 143 | 144 | |
| 145 | match room.state() { | |
| 146 | MatrixRoomState::Joined => {}, | |
| 147 | MatrixRoomState::Left => labels.push(vec![Span::styled("Left", style)]), | |
| 148 | MatrixRoomState::Banned => labels.push(vec![Span::styled("Banned", style)]), | |
| 149 | MatrixRoomState::Knocked => labels.push(vec![Span::styled("Knocked", style)]), | |
| 150 | MatrixRoomState::Invited => labels.push(vec![Span::styled("Invited", style)]), | |
| 151 | } | |
| 152 | ||
| 144 | 153 | if unread.unread_mentions > 0 { |
| 145 | 154 | labels.push(vec![Span::styled("Unread Mention", style)]); |
| 146 | 155 | } else if unread.is_unread() { |
| @@ -172,6 +181,14 @@ fn user_cmp(a: &MemberItem, b: &MemberItem, field: &SortFieldUser) -> Ordering { | ||
| 172 | 181 | SortFieldUser::UserId => a_id.cmp(b_id), |
| 173 | 182 | SortFieldUser::LocalPart => a_id.localpart().cmp(b_id.localpart()), |
| 174 | 183 | SortFieldUser::Server => a_id.server_name().cmp(b_id.server_name()), |
| 184 | SortFieldUser::Knock => { | |
| 185 | // Sort knocks before non-knocks: | |
| 186 | b.is_knock().cmp(&a.is_knock()) | |
| 187 | }, | |
| 188 | SortFieldUser::Invite => { | |
| 189 | // Sort invites before non-invites: | |
| 190 | b.is_invite().cmp(&a.is_invite()) | |
| 191 | }, | |
| 175 | 192 | SortFieldUser::PowerLevel => { |
| 176 | 193 | // Sort higher power levels towards the top of the list. |
| 177 | 194 | b.member.power_level().cmp(&a.member.power_level()) |
| @@ -1048,7 +1065,7 @@ impl ListItem<IambInfo> for GenericChatItem { | ||
| 1048 | 1065 | _: &mut ProgramStore, |
| 1049 | 1066 | ) -> Text<'_> { |
| 1050 | 1067 | let style = selected_style(selected); |
| 1051 | let (name, mut labels) = name_and_labels(&self.name, &self.unread, style); | |
| 1068 | let (name, mut labels) = name_and_labels(&self.name, &self.unread, self.room(), style); | |
| 1052 | 1069 | let mut spans = vec![name]; |
| 1053 | 1070 | |
| 1054 | 1071 | labels.push(if self.is_dm { |
| @@ -1166,7 +1183,7 @@ impl ListItem<IambInfo> for RoomItem { | ||
| 1166 | 1183 | _: &mut ProgramStore, |
| 1167 | 1184 | ) -> Text<'_> { |
| 1168 | 1185 | let style = selected_style(selected); |
| 1169 | let (name, mut labels) = name_and_labels(&self.name, &self.unread, style); | |
| 1186 | let (name, mut labels) = name_and_labels(&self.name, &self.unread, self.room(), style); | |
| 1170 | 1187 | let mut spans = vec![name]; |
| 1171 | 1188 | |
| 1172 | 1189 | if let Some(tags) = &self.tags() { |
| @@ -1275,7 +1292,7 @@ impl ListItem<IambInfo> for DirectItem { | ||
| 1275 | 1292 | _: &mut ProgramStore, |
| 1276 | 1293 | ) -> Text<'_> { |
| 1277 | 1294 | let style = selected_style(selected); |
| 1278 | let (name, mut labels) = name_and_labels(&self.name, &self.unread, style); | |
| 1295 | let (name, mut labels) = name_and_labels(&self.name, &self.unread, self.room(), style); | |
| 1279 | 1296 | let mut spans = vec![name]; |
| 1280 | 1297 | |
| 1281 | 1298 | if let Some(tags) = &self.tags() { |
| @@ -1612,6 +1629,14 @@ impl MemberItem { | ||
| 1612 | 1629 | fn new(member: RoomMember, room_id: OwnedRoomId) -> Self { |
| 1613 | 1630 | Self { member, room_id } |
| 1614 | 1631 | } |
| 1632 | ||
| 1633 | fn is_knock(&self) -> bool { | |
| 1634 | self.member.membership() == &MembershipState::Knock | |
| 1635 | } | |
| 1636 | ||
| 1637 | fn is_invite(&self) -> bool { | |
| 1638 | self.member.membership() == &MembershipState::Invite | |
| 1639 | } | |
| 1615 | 1640 | } |
| 1616 | 1641 | |
| 1617 | 1642 | impl Display for MemberItem { |
src/windows/room/mod.rs +64 −4
| @@ -171,6 +171,21 @@ pub async fn room_command( | ||
| 171 | 171 | Err(IambError::NotJoined.into()) |
| 172 | 172 | } |
| 173 | 173 | }, |
| 174 | RoomAction::KnockAccept(user) => { | |
| 175 | let room = worker.client.get_room(id).ok_or(IambError::NotJoined)?; | |
| 176 | room.invite_user_by_id(&user).await.map_err(IambError::from)?; | |
| 177 | Ok(vec![]) | |
| 178 | }, | |
| 179 | RoomAction::KnockReject(user, reason) => { | |
| 180 | let room = worker.client.get_room(id).ok_or(IambError::NotJoined)?; | |
| 181 | room.kick_user(&user, reason.as_deref()).await.map_err(IambError::from)?; | |
| 182 | Ok(vec![]) | |
| 183 | }, | |
| 184 | RoomAction::KnockBan(user, reason) => { | |
| 185 | let room = worker.client.get_room(id).ok_or(IambError::NotJoined)?; | |
| 186 | room.ban_user(&user, reason.as_deref()).await.map_err(IambError::from)?; | |
| 187 | Ok(vec![]) | |
| 188 | }, | |
| 174 | 189 | RoomAction::Leave(skip_confirm) => { |
| 175 | 190 | if let Some(room) = store.application.worker.client.get_room(id) { |
| 176 | 191 | if skip_confirm { |
| @@ -681,7 +696,7 @@ impl RoomState { | ||
| 681 | 696 | |
| 682 | 697 | fn draw_invite( |
| 683 | 698 | &self, |
| 684 | invited: MatrixRoom, | |
| 699 | invited: &MatrixRoom, | |
| 685 | 700 | area: Rect, |
| 686 | 701 | buf: &mut Buffer, |
| 687 | 702 | store: &mut ProgramStore, |
| @@ -712,6 +727,48 @@ impl RoomState { | ||
| 712 | 727 | return; |
| 713 | 728 | } |
| 714 | 729 | |
| 730 | fn draw_knock( | |
| 731 | &self, | |
| 732 | knocked: &MatrixRoom, | |
| 733 | area: Rect, | |
| 734 | buf: &mut Buffer, | |
| 735 | store: &mut ProgramStore, | |
| 736 | ) { | |
| 737 | let name = match knocked.canonical_alias() { | |
| 738 | Some(alias) => alias.to_string(), | |
| 739 | None => format!("{:?}", store.application.get_room_title(self.id())), | |
| 740 | }; | |
| 741 | ||
| 742 | let l1 = Line::from(format!( | |
| 743 | "Your request to join {name} is pending review by room moderators." | |
| 744 | )); | |
| 745 | let l2 = Line::from("You can run `:leave` to withdraw your knock request."); | |
| 746 | let text = Text::from(vec![l1, l2]); | |
| 747 | ||
| 748 | Paragraph::new(text).alignment(Alignment::Center).render(area, buf); | |
| 749 | ||
| 750 | return; | |
| 751 | } | |
| 752 | ||
| 753 | fn draw_left(&self, room: &MatrixRoom, area: Rect, buf: &mut Buffer, store: &mut ProgramStore) { | |
| 754 | let name = match room.canonical_alias() { | |
| 755 | Some(alias) => alias.to_string(), | |
| 756 | None => format!("{:?}", store.application.get_room_title(self.id())), | |
| 757 | }; | |
| 758 | ||
| 759 | let mut lines = vec![Line::from(format!("You have left {name}!"))]; | |
| 760 | ||
| 761 | if room.is_public().is_some_and(|b| b) { | |
| 762 | lines.push(Line::from(format!("You can run `:join {name}` to rejoin."))); | |
| 763 | } | |
| 764 | ||
| 765 | let text = Text::from(lines); | |
| 766 | ||
| 767 | Paragraph::new(text).alignment(Alignment::Center).render(area, buf); | |
| 768 | ||
| 769 | return; | |
| 770 | } | |
| 771 | ||
| 715 | 772 | pub async fn message_command( |
| 716 | 773 | &mut self, |
| 717 | 774 | act: MessageAction, |
| @@ -859,12 +916,15 @@ impl TerminalCursor for RoomState { | ||
| 859 | 916 | |
| 860 | 917 | impl WindowOps<IambInfo> for RoomState { |
| 861 | 918 | fn draw(&mut self, area: Rect, buf: &mut Buffer, focused: bool, store: &mut ProgramStore) { |
| 862 | if self.room().state() == MatrixRoomState::Invited { | |
| 919 | if self.room().state() != MatrixRoomState::Joined { | |
| 863 | 920 | self.refresh_room(store); |
| 864 | 921 | } |
| 865 | 922 | |
| 866 | if self.room().state() == MatrixRoomState::Invited { | |
| 867 | self.draw_invite(self.room().clone(), area, buf, store); | |
| 923 | match self.room().state() { | |
| 924 | MatrixRoomState::Invited => return self.draw_invite(self.room(), area, buf, store), | |
| 925 | MatrixRoomState::Knocked => return self.draw_knock(self.room(), area, buf, store), | |
| 926 | MatrixRoomState::Left => return self.draw_left(self.room(), area, buf, store), | |
| 927 | _ => (), | |
| 868 | 928 | } |
| 869 | 929 | |
| 870 | 930 | match self { |
src/worker.rs +16 −9
| @@ -13,12 +13,7 @@ use std::time::{Duration, Instant}; | ||
| 13 | 13 | |
| 14 | 14 | use futures::{StreamExt, stream::FuturesUnordered}; |
| 15 | 15 | use gethostname::gethostname; |
| 16 | use matrix_sdk::ruma::events::AnyMessageLikeEventContent; | |
| 17 | use matrix_sdk::ruma::events::relation::Thread; | |
| 18 | use matrix_sdk::ruma::events::room::MediaSource; | |
| 19 | use matrix_sdk::ruma::events::room::message::Relation; | |
| 20 | use matrix_sdk::ruma::events::sticker::StickerEventContent; | |
| 21 | use matrix_sdk::send_queue::{LocalEcho, LocalEchoContent, RoomSendQueueUpdate, SendQueueUpdate}; | |
| 16 | use matrix_sdk_base::RoomStateFilter; | |
| 22 | 17 | use ratatui_image::picker::Picker; |
| 23 | 18 | use tokio::sync::Semaphore; |
| 24 | 19 | use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel}; |
| @@ -60,6 +55,7 @@ use matrix_sdk::{ | ||
| 60 | 55 | assign, |
| 61 | 56 | events::{ |
| 62 | 57 | AnyMessageLikeEvent, |
| 58 | AnyMessageLikeEventContent, | |
| 63 | 59 | AnySyncStateEvent, |
| 64 | 60 | AnyTimelineEvent, |
| 65 | 61 | InitialStateEvent, |
| @@ -76,19 +72,23 @@ use matrix_sdk::{ | ||
| 76 | 72 | presence::PresenceEvent, |
| 77 | 73 | reaction::ReactionEventContent, |
| 78 | 74 | receipt::{ReceiptEventContent, ReceiptThread, ReceiptType}, |
| 75 | relation::Thread, | |
| 79 | 76 | room::{ |
| 77 | MediaSource, | |
| 80 | 78 | encryption::RoomEncryptionEventContent, |
| 81 | 79 | member::OriginalSyncRoomMemberEvent, |
| 82 | message::{MessageType, RoomMessageEventContent}, | |
| 80 | message::{MessageType, Relation, RoomMessageEventContent}, | |
| 83 | 81 | name::RoomNameEventContent, |
| 84 | 82 | redaction::OriginalSyncRoomRedactionEvent, |
| 85 | 83 | }, |
| 84 | sticker::StickerEventContent, | |
| 86 | 85 | tag::Tags, |
| 87 | 86 | typing::SyncTypingEvent, |
| 88 | 87 | }, |
| 89 | 88 | room::RoomType, |
| 90 | 89 | serde::Raw, |
| 91 | 90 | }, |
| 91 | send_queue::{LocalEcho, LocalEchoContent, RoomSendQueueUpdate, SendQueueUpdate}, | |
| 92 | 92 | }; |
| 93 | 93 | |
| 94 | 94 | use modalkit::errors::UIError; |
| @@ -431,7 +431,11 @@ async fn refresh_rooms(client: &Client, store: &AsyncProgramStore, first_sync: b | ||
| 431 | 431 | let mut rooms = vec![]; |
| 432 | 432 | let mut dms = vec![]; |
| 433 | 433 | |
| 434 | for room in client.invited_rooms().into_iter().chain(client.joined_rooms().into_iter()) { | |
| 434 | let iter = client.rooms_filtered( | |
| 435 | RoomStateFilter::JOINED | RoomStateFilter::INVITED | RoomStateFilter::KNOCKED, | |
| 436 | ); | |
| 437 | ||
| 438 | for room in iter { | |
| 435 | 439 | let display = if let Some(name) = room.cached_display_name() { |
| 436 | 440 | name |
| 437 | 441 | } else if !first_sync && let Ok(name) = room.display_name().await { |
| @@ -1598,7 +1602,10 @@ impl ClientWorker { | ||
| 1598 | 1602 | |
| 1599 | 1603 | async fn members(&mut self, room_id: OwnedRoomId) -> IambResult<Vec<RoomMember>> { |
| 1600 | 1604 | if let Some(room) = self.client.get_room(room_id.as_ref()) { |
| 1601 | Ok(room.members(RoomMemberships::ACTIVE).await.map_err(IambError::from)?) | |
| 1605 | Ok(room | |
| 1606 | .members(RoomMemberships::ACTIVE | RoomMemberships::KNOCK) | |
| 1607 | .await | |
| 1608 | .map_err(IambError::from)?) | |
| 1602 | 1609 | } else { |
| 1603 | 1610 | Err(IambError::UnknownRoom(room_id).into()) |
| 1604 | 1611 | } |