From 0ee0a43b6af0cffad08d37511a170ec3f9bb2c9a Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 7 Apr 2026 11:38:07 +0100 Subject: [PATCH] feat: add configuration model and appsettings.json --- .../Configuration/SpamGuardOptions.cs | 36 ++++++++++++++++++ src/SpamGuard/appsettings.json | 38 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/SpamGuard/Configuration/SpamGuardOptions.cs create mode 100644 src/SpamGuard/appsettings.json diff --git a/src/SpamGuard/Configuration/SpamGuardOptions.cs b/src/SpamGuard/Configuration/SpamGuardOptions.cs new file mode 100644 index 0000000..a58d7f1 --- /dev/null +++ b/src/SpamGuard/Configuration/SpamGuardOptions.cs @@ -0,0 +1,36 @@ +namespace SpamGuard.Configuration; + +public sealed class SpamGuardOptions +{ + public const string SectionName = "SpamGuard"; + + public ImapOptions Imap { get; set; } = new(); + public ClaudeOptions Claude { get; set; } = new(); + public MonitoringOptions Monitoring { get; set; } = new(); +} + +public sealed class ImapOptions +{ + public string Host { get; set; } = ""; + public int Port { get; set; } = 993; + public bool UseSsl { get; set; } = true; + public string Username { get; set; } = ""; + public string Password { get; set; } = ""; +} + +public sealed class ClaudeOptions +{ + public string ApiKey { get; set; } = ""; + public string Model { get; set; } = "claude-sonnet-4-6"; + public int MaxBodyLength { get; set; } = 2000; +} + +public sealed class MonitoringOptions +{ + public int PollIntervalSeconds { get; set; } = 60; + public int TrustedSenderRefreshMinutes { get; set; } = 60; + public double SpamConfidenceThreshold { get; set; } = 0.7; + public string SpamFolderName { get; set; } = "Junk"; + public int InitialScanDays { get; set; } = 7; + public int MaxActivityLogEntries { get; set; } = 500; +} diff --git a/src/SpamGuard/appsettings.json b/src/SpamGuard/appsettings.json new file mode 100644 index 0000000..ffcd56a --- /dev/null +++ b/src/SpamGuard/appsettings.json @@ -0,0 +1,38 @@ +{ + "SpamGuard": { + "Imap": { + "Host": "imap.example.com", + "Port": 993, + "UseSsl": true, + "Username": "user@example.com", + "Password": "" + }, + "Claude": { + "ApiKey": "", + "Model": "claude-sonnet-4-6", + "MaxBodyLength": 2000 + }, + "Monitoring": { + "PollIntervalSeconds": 60, + "TrustedSenderRefreshMinutes": 60, + "SpamConfidenceThreshold": 0.7, + "SpamFolderName": "Junk", + "InitialScanDays": 7, + "MaxActivityLogEntries": 500 + } + }, + "Serilog": { + "MinimumLevel": "Information", + "WriteTo": [ + { "Name": "Console" }, + { + "Name": "File", + "Args": { + "path": "%APPDATA%/SpamGuard/logs/spamguard-.log", + "rollingInterval": "Day", + "retainedFileCountLimit": 7 + } + } + ] + } +}