Fix #598; setup issues when the bot has PL 0 and room default isn't 0 (#755)

* Fix #598

If the bot has PL 0, the bot incorrectly used the default power level.

* Create 755.bugfix
This commit is contained in:
Christian Paul 2023-05-18 21:18:15 +02:00 committed by GitHub
parent b91ca94249
commit 00771d88c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

1
changelog.d/755.bugfix Normal file
View File

@ -0,0 +1 @@
Fix setup issues when the bot has PL 0 and room default isn't 0.

View File

@ -1143,9 +1143,9 @@ export class Bridge {
if (this.config.widgets?.roomSetupWidget?.addOnInvite && event.type === "m.room.power_levels" && event.state_key === "" && !this.connectionManager.isRoomConnected(roomId)) {
log.debug(`${roomId} got a new powerlevel change and isn't connected to any connections, testing to see if we should create a setup widget`)
const plEvent = new PowerLevelsEvent(event);
const currentPl = plEvent.content.users?.[botUser.userId] || plEvent.defaultUserLevel;
const previousPl = plEvent.previousContent?.users?.[botUser.userId] || plEvent.previousContent?.users_default;
const requiredPl = plEvent.content.events?.["im.vector.modular.widgets"] || plEvent.defaultStateEventLevel;
const currentPl = plEvent.content.users?.[botUser.userId] ?? plEvent.defaultUserLevel;
const previousPl = plEvent.previousContent?.users?.[botUser.userId] ?? plEvent.previousContent?.users_default;
const requiredPl = plEvent.content.events?.["im.vector.modular.widgets"] ?? plEvent.defaultStateEventLevel;
if (currentPl !== previousPl && currentPl >= requiredPl) {
// PL changed for bot user, check to see if the widget can be created.
try {