feat: implement channel membership management and ensure default channels are public

This commit is contained in:
HueByte
2026-02-19 19:21:27 +01:00
parent 246eb2b0bb
commit 38b60e5626
11 changed files with 446 additions and 7 deletions
@@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
using EchoHub.Core.Constants;
using EchoHub.Server.Data;
using Microsoft.EntityFrameworkCore;
@@ -13,9 +14,24 @@ public static partial class DataMigrationService
var logger = scope.ServiceProvider.GetRequiredService<ILoggerFactory>()
.CreateLogger("EchoHub.Server.Setup.DataMigration");
await EnsureDefaultChannelsPublicAsync(db, logger);
await MigrateAnsiMessagesAsync(db, logger);
}
/// <summary>
/// Ensure the #general channel (and any pre-existing channels from before the IsPublic column) are public.
/// </summary>
private static async Task EnsureDefaultChannelsPublicAsync(EchoHubDbContext db, ILogger logger)
{
var general = await db.Channels.FirstOrDefaultAsync(c => c.Name == HubConstants.DefaultChannel);
if (general is not null && !general.IsPublic)
{
general.IsPublic = true;
await db.SaveChangesAsync();
logger.LogInformation("Marked #{Channel} as public.", HubConstants.DefaultChannel);
}
}
private static async Task MigrateAnsiMessagesAsync(EchoHubDbContext db, ILogger logger)
{
// Load messages that contain the ESC byte (0x1B) — these have legacy ANSI color codes.