Commit fe0ac776e1
fe0ac776e12b4c67c30d1b63c0ad9e5570f43bcb
parent: 82384ac79b
Unregistered key
vaw <git@nlih.de> · 2026-09-11 21:18 UTC
committer: <noreply@github.com>
Don't force user to join room on `:space child set` (#675)
Layout: unified · split
src/base.rs
+2 −2
| @@ -137,8 +137,8 @@ pub enum MessageAction { |
| 137 | 137 | pub enum SpaceAction { |
| 138 | 138 | /// Add a room or update metadata. |
| 139 | 139 | SetChild { |
| 140 | | /// The room ID, alias, or a user whose DM room should be added to the space. |
| 141 | | child: String, |
| 140 | /// The room that should be added to the space. |
| 141 | child: OwnedRoomOrAliasId, |
| 142 | 142 | /// The order parameter to use when sorting children in the space. |
| 143 | 143 | order: Option<String>, |
| 144 | 144 | /// Whether the room is suggested. |
src/commands.rs
+8 −5
| @@ -911,10 +911,13 @@ fn iamb_space(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { |
| 911 | 911 | } |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | | let Some(child) = raw_child else { |
| 914 | let child = raw_child.ok_or_else(|| { |
| 915 | 915 | let msg = "Must specify a room to add"; |
| 916 | | return Err(CommandError::Error(msg.into())); |
| 917 | | }; |
| 916 | CommandError::Error(msg.into()) |
| 917 | })?; |
| 918 | let child = OwnedRoomOrAliasId::from_str(&child).map_err(|e| { |
| 919 | CommandError::Error(format!("{child:?} is not a valid room identifier: {e}")) |
| 920 | })?; |
| 918 | 921 | |
| 919 | 922 | SpaceAction::SetChild { child, order, suggested }.into() |
| 920 | 923 | }, |
| @@ -1521,7 +1524,7 @@ mod tests { |
| 1521 | 1524 | let cmd = "space child set !roomid:example.org"; |
| 1522 | 1525 | let res = cmds.input_cmd(cmd, ctx.clone()).unwrap(); |
| 1523 | 1526 | let act = SpaceAction::SetChild { |
| 1524 | | child: "!roomid:example.org".to_owned(), |
| 1527 | child: owned_room_id!("!roomid:example.org").into(), |
| 1525 | 1528 | order: None, |
| 1526 | 1529 | suggested: false, |
| 1527 | 1530 | }; |
| @@ -1530,7 +1533,7 @@ mod tests { |
| 1530 | 1533 | let cmd = "space child set ++order=abcd ++suggested !roomid:example.org"; |
| 1531 | 1534 | let res = cmds.input_cmd(cmd, ctx.clone()).unwrap(); |
| 1532 | 1535 | let act = SpaceAction::SetChild { |
| 1533 | | child: "!roomid:example.org".to_owned(), |
| 1536 | child: owned_room_id!("!roomid:example.org").into(), |
| 1534 | 1537 | order: Some("abcd".into()), |
| 1535 | 1538 | suggested: true, |
| 1536 | 1539 | }; |
src/completions.rs
+2 −2
| @@ -507,13 +507,13 @@ fn complete_iamb_space(args: Vec<String>, store: &ChatStore) -> Vec<String> { |
| 507 | 507 | if arg.is_empty() { |
| 508 | 508 | let mut opts = complete_options(args.as_slice(), &options); |
| 509 | 509 | if !has_room { |
| 510 | | opts.extend(complete_matrix_names(arg, store)); |
| 510 | opts.extend(complete_room_alias_or_id(arg, store)); |
| 511 | 511 | } |
| 512 | 512 | opts |
| 513 | 513 | } else if arg.starts_with('+') { |
| 514 | 514 | complete_options(args.as_slice(), &options) |
| 515 | 515 | } else if !has_room { |
| 516 | | complete_matrix_names(arg, store) |
| 516 | complete_room_alias_or_id(arg, store) |
| 517 | 517 | } else { |
| 518 | 518 | vec![] |
| 519 | 519 | } |
src/windows/room/space.rs
+19 −2
| @@ -73,9 +73,26 @@ impl SpaceState { |
| 73 | 73 | return Err(IambError::InsufficientPermission.into()); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | | let child_id = store.application.worker.join_room(child)?; |
| 76 | let (child_id, via) = match OwnedRoomId::try_from(child) { |
| 77 | Ok(room_id) => { |
| 78 | // assume the new child is reachable the same way as the parent |
| 79 | let via = self.room.route().await.map_err(IambError::from)?; |
| 80 | |
| 81 | (room_id, via) |
| 82 | }, |
| 83 | Err(alias) => { |
| 84 | let resp = store |
| 85 | .application |
| 86 | .worker |
| 87 | .client |
| 88 | .resolve_room_alias(&alias) |
| 89 | .await |
| 90 | .map_err(IambError::from)?; |
| 91 | |
| 92 | (resp.room_id, resp.servers) |
| 93 | }, |
| 94 | }; |
| 77 | 95 | |
| 78 | | let via = self.room.route().await.map_err(IambError::from)?; |
| 79 | 96 | let mut ev = SpaceChildEventContent::new(via); |
| 80 | 97 | ev.order = order |
| 81 | 98 | .as_deref() |