diff --git a/src/models/PowerLevels.ts b/src/models/PowerLevels.ts index d71fae5..0acd29c 100644 --- a/src/models/PowerLevels.ts +++ b/src/models/PowerLevels.ts @@ -42,7 +42,7 @@ export class PowerLevels { } public canUserSend(userId: string, eventType: string, isState: boolean): boolean { - let requiredLevel = isState ? 50 : 0; + let requiredLevel = isState ? (this.event ? 50 : 0) : 0; const defaultLevel = isState ? this.event?.content["state_default"] : this.event?.content["events_default"]; if (Number.isInteger(defaultLevel)) { diff --git a/src/server/room_versions/impl/IDMimiLinearized00.ts b/src/server/room_versions/impl/IDMimiLinearized00.ts index ff9cf10..8f6855a 100644 --- a/src/server/room_versions/impl/IDMimiLinearized00.ts +++ b/src/server/room_versions/impl/IDMimiLinearized00.ts @@ -183,10 +183,7 @@ export class IDMimiLinearized00 implements RoomVersion { } } - if ( - powerLevelsEv !== undefined && - !powerLevels.canUserSend(event.sender, event.type, event.state_key !== undefined) - ) { + if (!powerLevels.canUserSend(event.sender, event.type, event.state_key !== undefined)) { throw new Error(`${event.type}: power levels do not permit sending this event`); }