mirror of
https://github.com/Govor-team/Govor.git
synced 2026-11-16 20:56:03 +00:00
2e9d7e625e
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.
34 lines
1.5 KiB
C#
34 lines
1.5 KiB
C#
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();
|
|
}
|
|
}
|