From af50fe22cdf03ffb19e2c2a6b76ae51b98d95574 Mon Sep 17 00:00:00 2001 From: gnuxie Date: Sun, 13 Apr 2025 12:16:53 +0100 Subject: [PATCH] Unrestrict users automatically on policy changes too. --- .../HomeserverUserPolicyApplication.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/protections/HomeserverUserPolicyApplication/HomeserverUserPolicyApplication.ts b/src/protections/HomeserverUserPolicyApplication/HomeserverUserPolicyApplication.ts index ca7ba424..d94c6cc3 100644 --- a/src/protections/HomeserverUserPolicyApplication/HomeserverUserPolicyApplication.ts +++ b/src/protections/HomeserverUserPolicyApplication/HomeserverUserPolicyApplication.ts @@ -94,8 +94,22 @@ export class HomeserverUserPolicyApplication { (async () => { for (const change of changes) { if (change.changeType === PolicyRuleChangeType.Removed) { + if ( + change.rule.matchType === PolicyRuleMatchType.Literal && + isStringUserID(change.rule.entity) + ) { + const unrestrictResult = await this.consequences.unrestrictUser( + change.rule.entity, + change.event.sender + ); + if (isError(unrestrictResult)) { + log.error( + `Failed to unrestrict the user ${change.rule.entity}`, + unrestrictResult.error + ); + } + } continue; - // FIXME: Don't we want to unsuspend here? // FIXME: What about modifying from a automaticallyRedactReason to a non redact reason? } const policy = change.rule;