feat: Add command to upgrade room

This commit is contained in:
Krille 2025-02-24 10:52:27 +01:00
parent 77c3dc8d2d
commit 70dc9c6ef9
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
2 changed files with 12 additions and 0 deletions

View File

@ -2046,6 +2046,8 @@ class Room {
/// `m.sticker` use `canSendEvent('<event-type>')`.
bool get canSendDefaultMessages {
if (encrypted && !client.encryptionEnabled) return false;
if (isExtinct) return false;
if (membership != Membership.join) return false;
return canSendEvent(encrypted ? EventTypes.Encrypted : EventTypes.Message);
}

View File

@ -460,6 +460,16 @@ extension CommandsClientExtension on Client {
stdout?.write(DefaultCommandOutput(users: [mxid]).toString());
return null;
});
addCommand('roomupgrade', (args, stdout) async {
final version = args.msg;
if (version.isEmpty) {
throw CommandException('Please provide a room version');
}
final newRoomId =
await args.room!.client.upgradeRoom(args.room!.id, version);
stdout?.write(DefaultCommandOutput(rooms: [newRoomId]).toString());
return null;
});
}
}