mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-06 07:36:01 +02:00
deploy: 0105f798e0
This commit is contained in:
@@ -8,12 +8,30 @@ public sealed class SpamOptions
|
||||
```
|
||||
|
||||
|
||||
SpamOptions is a configuration object that encapsulates the anti-spam thresholds used by the server. It is bound from the Spam config section and exposes the toggles and numeric limits that govern how the system enforces per-user rate limits, duplicate message handling, auto-muting behavior, and the protections around first-time channel joins and channel creation. The defaults are intentionally lenient so a fast typist won’t trip them, and moderators (and above) are exempt from these protections. Use this class to adjust spam-protection policy without changing code.
|
||||
SpamOptions is a configuration class bound to the 'Spam' config section that stores all anti-spam thresholds. It centralizes rate limits, duplicate suppression, auto-mute behavior, and onboarding quotas so enforcement logic can apply consistent rules; adjust these values here rather than hard-coding them throughout.
|
||||
|
||||
## Remarks
|
||||
SpamOptions centralizes policy decisions for anti-spam enforcement, serving as a single source of truth for the thresholds consumed by the spam protection subsystem. By binding to configuration, it keeps rules out of hard-coded logic and enables runtime tuning via the Spam section. The design separates concerns across rate limiting (per-user messages), duplicate detection, auto-mute behavior, and early channel-join/channel-create protections, making it easier to tune each facet without collateral impact. The auto-mute behavior ties into the existing moderation tooling (MuteExpirationService), illustrating cohesive behavior with the broader user-suspension lifecycle. The note about end-to-end encrypted rooms clarifies that identical plaintext can yield different ciphertext, so the duplicate-detection rule may not apply in those contexts.
|
||||
SpamOptions acts as the configuration contract for anti-spam behavior. It centralizes all thresholds so the enforcement and moderation subsystems can apply consistent rules without hard-coded values scattered through the codebase. It coordinates rate limiting, duplicate suppression, auto-mute behavior, and first-join/channel-creation limits via a single, testable object that can be configured at startup.
|
||||
|
||||
## Example
|
||||
```csharp
|
||||
var options = new SpamOptions
|
||||
{
|
||||
Enabled = true,
|
||||
MaxMessagesPerWindow = 12,
|
||||
WindowSeconds = 10,
|
||||
MaxDuplicateMessages = 2,
|
||||
AutoMuteMinutes = 10,
|
||||
ViolationThreshold = 6,
|
||||
ViolationWindowMinutes = 3,
|
||||
MaxJoinsPerWindow = 30,
|
||||
JoinWindowSeconds = 20,
|
||||
MaxChannelCreatesPerWindow = 2,
|
||||
ChannelCreateWindowMinutes = 15
|
||||
};
|
||||
```
|
||||
|
||||
## Notes
|
||||
- Auto-mute is controlled by AutoMuteMinutes. Setting AutoMuteMinutes to 0 disables auto-mute (rejections still apply if thresholds are reached).
|
||||
- MaxMessagesPerWindow and WindowSeconds govern per-user message rate; adjust them with awareness of your typical user pacing to avoid false positives.
|
||||
- MaxJoinsPerWindow and JoinWindowSeconds apply to first-time channel joins; joins to channels the user already belongs to do not count toward the limit, ensuring normal reconnects don’t trigger protections.
|
||||
- Auto-mute is disabled when `AutoMuteMinutes` is 0; rejections still apply.
|
||||
- The first-join burst behavior relies on `MaxJoinsPerWindow` being large enough for your public channel count.
|
||||
- These values are loaded from the config and may be adjusted to balance user experience against protection needs.
|
||||
Reference in New Issue
Block a user