Stop MemberBanSynchronisation banning for all recommendations. (#1062)
Docker Hub - Develop / docker-latest (push) Failing after 31s
GHCR - Development Branches / ghcr-publish (push) Failing after 33s
Tests / Unit tests (push) Successful in 7m9s
Tests / Build & Lint (push) Failing after 7m21s
Tests / Application Service Integration tests (push) Failing after 22s
Tests / Integration tests (push) Failing after 11m48s

Originally contributed in https://github.com/Gnuxie/matrix-protection-suite/pull/102.

Co-authored-by: nexy7574 <git@nexy7574.co.uk>
This commit is contained in:
Gnuxieandnexy7574 authored and GitHub committed 2026-03-29 16:30:55 +01:00
1 parent b4d105f915
commit 5870c02933
2 files changed
+29 -9

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
---
"@the-draupnir-project/matrix-protection-suite": patch
"draupnir": patch
---
Fixed a bug where User policies of any recommendation would result in the
MemberBanSynchronisationProtection banning users. This is was a particularly
important issue for compatibility with Meowlnir.
@@ -27,7 +27,7 @@ import {
import { RoomMembershipRevision } from "../../../Membership/MembershipRevision";
import { ProtectedRoomsSet } from "../../ProtectedRoomsSet";
import { PolicyRuleType } from "../../../MatrixTypes/PolicyEvents";
import { Recommendation } from "../../../PolicyList/PolicyRule";
import { PolicyRule, Recommendation } from "../../../PolicyList/PolicyRule";
import { MultipleErrors } from "../../../Interface/MultipleErrors";
import { UserConsequences } from "../../Capability/StandardCapability/UserConsequences";
import "../../Capability/StandardCapability/UserConsequences"; // need this to load the interface.
@@ -45,14 +45,26 @@ import {
StandardMemberBanIntentProjection,
} from "./MemberBanIntentProjection";
function revisionMatchesWithUserRules(
function isRecommendationWorthBanning(policyRule: PolicyRule) {
return (
policyRule.recommendation === Recommendation.Ban ||
policyRule.recommendation === Recommendation.Takedown
);
}
function revisionMatchesWithUserBans(
revision: SetMembershipPolicyRevision
): MemberPolicyMatches[] {
return revision
.allMembersWithRules()
.filter((match) =>
match.policies.some((policy) => policy.kind === PolicyRuleType.User)
);
return revision.allMembersWithRules().filter((match) =>
match.policies.some(
(policy) =>
// We only ban for user policies and not server ones at the time being,
// As this keeps ACL non-disruptive when it is necessary to temporarily
// ban a server.
policy.kind === PolicyRuleType.User &&
isRecommendationWorthBanning(policy)
)
);
}
export type MemberBanSynchronisationProtectionDescription =
@@ -148,7 +160,7 @@ export class MemberBanSynchronisationProtection
revision: SetMembershipPolicyRevision
): Promise<ActionResult<void>> {
const result = await this.userConsequences.consequenceForUsersInRoomSet(
revisionMatchesWithUserRules(revision)
revisionMatchesWithUserBans(revision)
);
if (isError(result)) {
return result;
@@ -162,7 +174,7 @@ export class MemberBanSynchronisationProtection
(async () => {
await this.userConsequences.consequenceForUsersInRoom(
room.toRoomIDOrAlias(),
revisionMatchesWithUserRules(
revisionMatchesWithUserBans(
this.protectedRoomsSet.setPoliciesMatchingMembership.currentRevision
)
);