Summary Update.
This commit is contained in:
@@ -7,6 +7,28 @@ using SurrealDb.Net;
|
||||
|
||||
namespace RelayServer.Services.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Idempotent server setup. Runs once at boot from Program.cs.
|
||||
///
|
||||
/// Each "Ensure*" helper either inserts a missing row or patches an existing one so the
|
||||
/// declared state matches the code. Running this twice in a row is a no-op.
|
||||
///
|
||||
/// What it provisions:
|
||||
/// - Verifies the three test users exist via CoreClientService (currently a hardcoded stub).
|
||||
/// - Creates the "Test Server" row in the servers table if missing.
|
||||
/// - Adds those users to server_members, with Keeper317 as IsOwner=true.
|
||||
/// - Creates the four premade channels with correct ChannelType and IsReadOnly flags:
|
||||
/// welcome (Text, read-only) general (Text)
|
||||
/// files (File, read-only) voice-general (Voice)
|
||||
/// - Links #general → #files so attachments posted in #general auto-mirror to #files.
|
||||
/// - Creates the three roles: Admin (all perms), Moderator (manage messages), Member (read+send).
|
||||
/// - Assigns exactly one role per user (Keeper→Admin, Kira→Moderator, Test→Member).
|
||||
/// SetUserRoleAsync DELETES stale assignments to guarantee single-role-per-user.
|
||||
/// - Writes channel_permissions overrides explicitly denying Members SendMessages in
|
||||
/// #welcome and #files.
|
||||
/// - Generates the server's RSA keypair + the channel AES key on first boot, stores both
|
||||
/// in server_encryption_keys, and copies them into ChatSocketBehavior's static fields.
|
||||
/// </summary>
|
||||
public sealed class ServerBootstrapService
|
||||
{
|
||||
private readonly SurrealDbClient _db;
|
||||
|
||||
Reference in New Issue
Block a user