-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix d4all protections #284
base: main
Are you sure you want to change the base?
Fix d4all protections #284
Conversation
@@ -146,9 +135,21 @@ export class ProtectionManager { | |||
get protections(): Readonly<Map<string /* protection name */, Protection>> { | |||
return this._protections; | |||
} | |||
private readonly protection_classes: Protection[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Let's stick to the naming convention of protectionClasses
please, sorry if that's been butchered in some other place.
) { | ||
super() | ||
const banPropagationProtection = this.protections.find(p => p.name === 'BanPropagationProtection'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be cool if we could make 'BanPropagationProtection' a static name
field on the BanPropagationProtection class so we don't have to risk typoing it. Which would then remove the need for this check
@@ -146,9 +135,21 @@ export class ProtectionManager { | |||
get protections(): Readonly<Map<string /* protection name */, Protection>> { | |||
return this._protections; | |||
} | |||
private readonly protection_classes: Protection[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm seems like the _protections
member is already doing this job...
@@ -159,7 +160,7 @@ export class ProtectionManager { | |||
await this.enabledProtectionsManager.start(); | |||
this.mjolnir.reportManager.on("report.new", this.handleReport.bind(this)); | |||
this.mjolnir.matrixEmitter.on("room.event", this.handleEvent.bind(this)); | |||
for (const protection of PROTECTIONS) { | |||
for (const protection of this.protection_classes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could just move the list of protections (formerly) PROTECTIONS
to here? and then pass _protections
to the EnabledProtectionsManager`?
This fixes a long standing bug where we had things activated that didnt seem active. This should now have a clean protection instance per mjolnir instance.