Add primitive groups and required channel

Adds server-side group and channel management, private invitations, member moderation, avatar handling, and required-channel configuration. This change also introduces SignalR group profile/member notifications, updates registration to atomically join required channels, and adds EF migration and test coverage for group membership, permissions, and invitation expiry rules.
This commit is contained in:
Artemy
2026-10-04 10:35:07 +07:00
parent fed8f518ee
commit 2e9d7e625e
48 changed files with 3593 additions and 167 deletions
@@ -0,0 +1,33 @@
using Govor.API.Common.Extensions;
using Govor.API.Hubs.Infrastructure;
using Govor.Application.Groups;
using Govor.Application.Infrastructure.Extensions;
using Govor.Contracts.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Govor.API.Controllers.AdminStuff;
[ApiController]
[Authorize(Roles = "Admin")]
[Route("api/admin/required-channel")]
public class RequiredChannelController(IGroupManagementService groups, ICurrentUserService currentUser,
IChatNotificationService notifier) : ControllerBase
{
[HttpGet]
public async Task<IActionResult> Get() => (await groups.GetRequiredChannelAsync(currentUser.GetCurrentUserId()))
.Map(s => new { channelId = s.RequiredChannelId, allowLeave = s.AllowLeave }).ToActionResult();
[HttpPut]
public async Task<IActionResult> Set([FromBody] RequiredChannelRequest request)
{
var actorId = currentUser.GetCurrentUserId();
var previous = await groups.GetRequiredChannelAsync(actorId);
if (previous.IsFailure) return previous.ToActionResult();
var result = await groups.SetRequiredChannelAsync(actorId, request.ChannelId, request.AllowLeave);
if (result.IsSuccess)
foreach (var channelId in new[] { previous.Value.RequiredChannelId, result.Value.RequiredChannelId }.OfType<Guid>().Distinct())
await notifier.NotifyGroupProfileChangedAsync(channelId);
return result.Map(s => new { channelId = s.RequiredChannelId, allowLeave = s.AllowLeave }).ToActionResult();
}
}