Skip to content

Commit

Permalink
Fix auth rule 7 implementation on power level check
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Mar 30, 2023
1 parent 9773e65 commit 6082107
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/models/PowerLevels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
5 changes: 1 addition & 4 deletions src/server/room_versions/impl/IDMimiLinearized00.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}

Expand Down

0 comments on commit 6082107

Please sign in to comment.