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
206206.Sy :room unread unset .
207207.It Sy ":room version show"
208208Show 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...]"
210210Upgrade the Matrix version for this room to the specified version.
211211Note that room upgrading in Matrix works by creating a new room that everyone else will then need to join.
212212.It Sy ":room notify set [level]"
src/commands.rs +20 −6
@@ -775,10 +775,21 @@ fn iamb_room(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
775775 let additional_creators = trailing
776776 .iter()
777777 .map(|u| {
778 OwnedUserId::from_str(u).map_err(|e| {
779 let msg = format!("{u:?} is not a valid user identifier: {e}");
780 CommandError::Error(msg)
781 })
778 let (flag, v) = match OptionType::from_str(u)? {
779 OptionType::Positional(_) => return Err(CommandError::InvalidArgument),
780 OptionType::Flag(_, None) => return Err(CommandError::InvalidArgument),
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 }
782793 })
783794 .collect::<Result<Vec<_>, _>>()?;
784795 RoomAction::Upgrade(version, additional_creators, desc.bang).into()
@@ -1794,7 +1805,7 @@ mod tests {
17941805 assert_eq!(res, vec![(act.into(), ctx.clone())]);
17951806
17961807 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())
17981809 .unwrap();
17991810 let act = IambAction::Room(RoomAction::Upgrade(
18001811 RoomVersionId::V12,
@@ -1804,7 +1815,10 @@ mod tests {
18041815 assert_eq!(res, vec![(act.into(), ctx.clone())]);
18051816
18061817 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 )
18081822 .unwrap();
18091823 let act = IambAction::Room(RoomAction::Upgrade(
18101824 RoomVersionId::V12,
src/completions.rs +10 −1
@@ -477,7 +477,16 @@ fn complete_iamb_room(args: Vec<String>, store: &ChatStore) -> Vec<String> {
477477 } else {
478478 let input = args.last().unwrap();
479479 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 },
481490 ("access", "set", "restricted") | ("access", "set", "knock-restricted") => {
482491 if let Some(remaining) = input.strip_prefix("++members=") {
483492 complete_room_alias_or_id(remaining, store)
src/windows/room/chat.rs +1 −5
@@ -1343,11 +1343,7 @@ mod tests {
13431343 use crate::tests::{TEST_ROOM1_ID, mock_store};
13441344
13451345 fn mentions_in(html: &str) -> Vec<String> {
1346 extract_mentions_str(&html)
1347 .user_ids
1348 .iter()
1349 .map(|u| u.to_string())
1350 .collect()
1346 extract_mentions_str(html).user_ids.iter().map(|u| u.to_string()).collect()
13511347 }
13521348
13531349 #[test]