Support room version 12 and the "creator power level"

This commit is contained in:
N-Pex 2025-08-06 12:07:50 +02:00
parent f804e0377b
commit c36deef7e2
13 changed files with 351 additions and 113 deletions

View file

@ -699,7 +699,7 @@ export default {
roomCreatedByUsRecently() {
const createEvent = this.room && this.room.currentState.getStateEvents("m.room.create", "");
if (createEvent) {
const creatorId = createEvent.getContent().creator;
const creatorId = createEvent.getSender();
return (creatorId == this.$matrix.currentUserId && createEvent.getLocalAge() < 5 * 60000 /* 5 minutes */);
}
return false;
@ -1367,6 +1367,24 @@ export default {
},
sendMessage(text) {
//TEMP TEMP TEMP
if (text.startsWith("/version") && this.room && this.room.userMayUpgradeRoom(this.$matrix.currentUserId)) {
this.room.getRecommendedVersion().then((v) => {
console.error("Room version:", this.room.getVersion());
console.error("Recommended:", v);
});
this.$matrix.matrixClient.getCapabilities().then((c) => {
console.error("Capabilities:", c);
});
return;
}
if (text.startsWith("/upgrade ") && this.room && this.room.userMayUpgradeRoom(this.$matrix.currentUserId)) {
const version = text.substring(9);
this.$matrix.matrixClient.upgradeRoom(this.roomId, version).then((r) => {
console.error("Upgrade result", JSON.stringify(r));
})
return;
}
if (text && text.length > 0) {
util
.sendTextMessage(this.$matrix.matrixClient, this.roomId, text, this.editedEvent, this.replyToEvent)