using Application.Abstractions.Data;
using Microsoft.EntityFrameworkCore;
namespace Application.Helpers;
///
/// 채팅 제재 검사 — RoomKey NULL(전체) 또는 해당 룸 제재가 만료 전이면 발언 차단.
/// 읽기(수신/히스토리)는 차단하지 않는다.
///
public static class ChatBanChecker
{
public static async Task IsBannedAsync(IAppDbContext db, int memberID, string roomKey, DateTime nowUtc, CancellationToken ct)
{
return await db.ChatBan.AsNoTracking().AnyAsync(c => c.MemberID == memberID && (c.RoomKey == null || c.RoomKey == roomKey) && (c.ExpiresAt == null || c.ExpiresAt > nowUtc), ct);
}
}