Commit b57b5b86df

b57b5b86dfd214aaab4563a0c530390d992dec1c

parent: beddf49e33

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-09-18 05:20 UTC
committer: <noreply@github.com>

Make `:room version upgrade` use `++creator` for additional creators (#714)

Layout: unified · split

docs/iamb.1 +1 −1
@@ -206,7 +206,7 @@ Alias for
206.Sy :room unread unset . 206.Sy :room unread unset .
207.It Sy ":room version show" 207.It Sy ":room version show"
208Show the Matrix version for this room. 208Show the Matrix version for this room.
209.It Sy ":room version upgrade [version] [additional creators...]" 209.It Sy ":room version upgrade [version] [++creator=additional creator...]"
210Upgrade the Matrix version for this room to the specified version. 210Upgrade the Matrix version for this room to the specified version.
211Note that room upgrading in Matrix works by creating a new room that everyone else will then need to join. 211Note that room upgrading in Matrix works by creating a new room that everyone else will then need to join.
212.It Sy ":room notify set [level]" 212.It Sy ":room notify set [level]"
src/commands.rs +20 −6
@@ -775,10 +775,21 @@ fn iamb_room(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
775 let additional_creators = trailing 775 let additional_creators = trailing
776 .iter() 776 .iter()
777 .map(|u| { 777 .map(|u| {
778 OwnedUserId::from_str(u).map_err(|e| { 778 let (flag, v) = match OptionType::from_str(u)? {
779 let msg = format!("{u:?} is not a valid user identifier: {e}"); 779 OptionType::Positional(_) => return Err(CommandError::InvalidArgument),
780 CommandError::Error(msg) 780 OptionType::Flag(_, None) => return Err(CommandError::InvalidArgument),
781 }) 781 OptionType::Flag(f, Some(v)) => (f, v),
782 };
783
784 match flag.as_str() {
785 "creator" => {
786 OwnedUserId::from_str(&v).map_err(|e| {
787 let msg = format!("{u:?} is not a valid user identifier: {e}");
788 CommandError::Error(msg)
789 })
790 },
791 _ => Err(CommandError::Error(format!("unknown flag {flag:?}"))),
792 }
782 }) 793 })
783 .collect::<Result<Vec<_>, _>>()?; 794 .collect::<Result<Vec<_>, _>>()?;
784 RoomAction::Upgrade(version, additional_creators, desc.bang).into() 795 RoomAction::Upgrade(version, additional_creators, desc.bang).into()
@@ -1794,7 +1805,7 @@ mod tests {
1794 assert_eq!(res, vec![(act.into(), ctx.clone())]); 1805 assert_eq!(res, vec![(act.into(), ctx.clone())]);
1795 1806
1796 let res = cmds 1807 let res = cmds
1797 .input_cmd("room version upgrade 12 @foo:example.com", ctx.clone()) 1808 .input_cmd("room version upgrade 12 ++creator=@foo:example.com", ctx.clone())
1798 .unwrap(); 1809 .unwrap();
1799 let act = IambAction::Room(RoomAction::Upgrade( 1810 let act = IambAction::Room(RoomAction::Upgrade(
1800 RoomVersionId::V12, 1811 RoomVersionId::V12,
@@ -1804,7 +1815,10 @@ mod tests {
1804 assert_eq!(res, vec![(act.into(), ctx.clone())]); 1815 assert_eq!(res, vec![(act.into(), ctx.clone())]);
1805 1816
1806 let res = cmds 1817 let res = cmds
1807 .input_cmd("room version upgrade 12 @foo:example.com @bar:example.com", ctx.clone()) 1818 .input_cmd(
1819 "room version upgrade 12 ++creator=@foo:example.com ++creator=@bar:example.com",
1820 ctx.clone(),
1821 )
1808 .unwrap(); 1822 .unwrap();
1809 let act = IambAction::Room(RoomAction::Upgrade( 1823 let act = IambAction::Room(RoomAction::Upgrade(
1810 RoomVersionId::V12, 1824 RoomVersionId::V12,
src/completions.rs +10 −1
@@ -477,7 +477,16 @@ fn complete_iamb_room(args: Vec<String>, store: &ChatStore) -> Vec<String> {
477 } else { 477 } else {
478 let input = args.last().unwrap(); 478 let input = args.last().unwrap();
479 match (args[0].as_str(), args[1].as_str(), args[2].as_str()) { 479 match (args[0].as_str(), args[1].as_str(), args[2].as_str()) {
480 ("version", "upgrade", _) => complete_users(input, store), 480 ("version", "upgrade", _) => {
481 if let Some(remaining) = input.strip_prefix("++creator=") {
482 complete_users(remaining, store)
483 .into_iter()
484 .map(|id| format!("++creator={id}"))
485 .collect()
486 } else {
487 complete_choices(input, &["++creator="])
488 }
489 },
481 ("access", "set", "restricted") | ("access", "set", "knock-restricted") => { 490 ("access", "set", "restricted") | ("access", "set", "knock-restricted") => {
482 if let Some(remaining) = input.strip_prefix("++members=") { 491 if let Some(remaining) = input.strip_prefix("++members=") {
483 complete_room_alias_or_id(remaining, store) 492 complete_room_alias_or_id(remaining, store)
src/windows/room/chat.rs +1 −5
@@ -1343,11 +1343,7 @@ mod tests {
1343 use crate::tests::{TEST_ROOM1_ID, mock_store}; 1343 use crate::tests::{TEST_ROOM1_ID, mock_store};
1344 1344
1345 fn mentions_in(html: &str) -> Vec<String> { 1345 fn mentions_in(html: &str) -> Vec<String> {
1346 extract_mentions_str(&html) 1346 extract_mentions_str(html).user_ids.iter().map(|u| u.to_string()).collect()
1347 .user_ids
1348 .iter()
1349 .map(|u| u.to_string())
1350 .collect()
1351 } 1347 }
1352 1348
1353 #[test] 1349 #[test]