feat: add SiteNotificationRepository and SMTP storage
This commit is contained in:
@@ -77,6 +77,18 @@ public class SiteStorageService
|
||||
recipient_emails TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS smtp_configurations (
|
||||
name TEXT PRIMARY KEY,
|
||||
server TEXT NOT NULL,
|
||||
port INTEGER NOT NULL,
|
||||
auth_mode TEXT NOT NULL,
|
||||
from_address TEXT NOT NULL,
|
||||
username TEXT,
|
||||
password TEXT,
|
||||
oauth_config TEXT,
|
||||
updated_at TEXT NOT NULL
|
||||
);
|
||||
";
|
||||
await command.ExecuteNonQueryAsync();
|
||||
|
||||
@@ -416,6 +428,45 @@ public class SiteStorageService
|
||||
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
|
||||
// ── WP-33: SMTP Configuration CRUD ──
|
||||
|
||||
/// <summary>
|
||||
/// Stores or updates an SMTP configuration.
|
||||
/// </summary>
|
||||
public async Task StoreSmtpConfigurationAsync(
|
||||
string name, string server, int port, string authMode, string fromAddress,
|
||||
string? username, string? password, string? oauthConfig)
|
||||
{
|
||||
await using var connection = new SqliteConnection(_connectionString);
|
||||
await connection.OpenAsync();
|
||||
|
||||
await using var command = connection.CreateCommand();
|
||||
command.CommandText = @"
|
||||
INSERT INTO smtp_configurations (name, server, port, auth_mode, from_address, username, password, oauth_config, updated_at)
|
||||
VALUES (@name, @server, @port, @authMode, @fromAddress, @username, @password, @oauthConfig, @updatedAt)
|
||||
ON CONFLICT(name) DO UPDATE SET
|
||||
server = excluded.server,
|
||||
port = excluded.port,
|
||||
auth_mode = excluded.auth_mode,
|
||||
from_address = excluded.from_address,
|
||||
username = excluded.username,
|
||||
password = excluded.password,
|
||||
oauth_config = excluded.oauth_config,
|
||||
updated_at = excluded.updated_at";
|
||||
|
||||
command.Parameters.AddWithValue("@name", name);
|
||||
command.Parameters.AddWithValue("@server", server);
|
||||
command.Parameters.AddWithValue("@port", port);
|
||||
command.Parameters.AddWithValue("@authMode", authMode);
|
||||
command.Parameters.AddWithValue("@fromAddress", fromAddress);
|
||||
command.Parameters.AddWithValue("@username", (object?)username ?? DBNull.Value);
|
||||
command.Parameters.AddWithValue("@password", (object?)password ?? DBNull.Value);
|
||||
command.Parameters.AddWithValue("@oauthConfig", (object?)oauthConfig ?? DBNull.Value);
|
||||
command.Parameters.AddWithValue("@updatedAt", DateTimeOffset.UtcNow.ToString("O"));
|
||||
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user