feat: Add invite codes and message replies functionality

- Introduced a new migration to add InviteCodes table and ReplyToMessageId column in Messages.
- Updated ChatHub to support replying to messages.
- Enhanced ChatService to handle message replies and validate reply targets.
- Modified UserService to implement invite-only registration mode with invite code consumption.
- Added configuration options for registration modes in appsettings.
- Created unit tests for new features including invite code registration and message reply formatting.
This commit is contained in:
HueByte
2026-07-17 19:47:57 +02:00
parent bb987dda82
commit 3281064720
44 changed files with 2484 additions and 74 deletions
@@ -0,0 +1,56 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EchoHub.Server.Data.Migrations
{
/// <inheritdoc />
public partial class AddInvitesAndReplies : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "ReplyToMessageId",
table: "Messages",
type: "TEXT",
nullable: true);
migrationBuilder.CreateTable(
name: "InviteCodes",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Code = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
CreatedByUserId = table.Column<Guid>(type: "TEXT", nullable: false),
CreatedByUsername = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
CreatedAt = table.Column<long>(type: "INTEGER", nullable: false),
ExpiresAt = table.Column<long>(type: "INTEGER", nullable: true),
MaxUses = table.Column<int>(type: "INTEGER", nullable: false),
UseCount = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InviteCodes", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_InviteCodes_Code",
table: "InviteCodes",
column: "Code",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "InviteCodes");
migrationBuilder.DropColumn(
name: "ReplyToMessageId",
table: "Messages");
}
}
}