ChatBanChecker.cs 678 B

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