Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MTRNord
Copy link
Collaborator

@MTRNord MTRNord commented Mar 7, 2024

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.

@MTRNord MTRNord requested a review from Gnuxie March 7, 2024 17:23
@@ -146,9 +135,21 @@ export class ProtectionManager {
get protections(): Readonly<Map<string /* protection name */, Protection>> {
return this._protections;
}
private readonly protection_classes: Protection[] = [
Copy link
Member

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');
Copy link
Member

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[] = [
Copy link
Member

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) {
Copy link
Member

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`?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants