-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
config.disableServerACL
to disable `ServerBanSynchronisationP…
…rotection` (#339) * Update for MPS ~0.16.0. * Update for new MPS ProtectionsManager. Part of #317. * `config.disableServerACL` now disabled `ServerBanSynchronisationProtection` Fixes #317.
- Loading branch information
Showing
5 changed files
with
92 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2024 Gnuxie <[email protected]> | ||
// | ||
// SPDX-License-Identifier: AFL-3.0 | ||
|
||
import { ActionResult, Ok, ProtectionsConfig, ServerBanSynchronisationProtection, isError } from "matrix-protection-suite"; | ||
import { IConfig } from "../config"; | ||
|
||
type ConfigHook = (config: IConfig, protectionsConfig: ProtectionsConfig) => Promise<ActionResult<void>>; | ||
|
||
const hooks: ConfigHook[] = [ | ||
async function disableServerACL (config, protectionsConfig) { | ||
if (config.disableServerACL) { | ||
return await protectionsConfig.disableProtection(ServerBanSynchronisationProtection.name); | ||
} else { | ||
return Ok(undefined); | ||
} | ||
} | ||
] | ||
|
||
/** | ||
* Introduced to allow the legacy option `config.disableServerACL` to map onto | ||
* MPS's ServerBanSynchronisationProtection. I think we need to deprecate the | ||
* option and offer something else. | ||
*/ | ||
export async function runProtectionConfigHooks(config: IConfig, protectionsConfig: ProtectionsConfig): Promise<ActionResult<void>> { | ||
for (const hook of hooks) { | ||
const result = await hook(config, protectionsConfig); | ||
if (isError(result)) { | ||
return result; | ||
} | ||
} | ||
return Ok(undefined); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters