Files
Govor/Govor.Application/PrivateUserChats/UserPrivateChatsGetter.cs
T
Artemy 29cc51ee0c Add reactions, reliable push & session checks
Implements message reactions and reaction packs (domain models, services, admin HTTP API, media processing via ImageSharp and limits) and adds reliable push delivery (ChatPushNotification, ChatPushDispatcher, ChatPushWorker, improved ChatNotificationService). Enhances message reading (ReadChat API, unread counts, concurrency-safe receipts) and tightens session security (access-token session validation in JWT, hub filter, SessionAuthorization). Improves SignalR behavior (session groups, reaction/channel events, hub/error mappings). Adds EF migrations, many controller fixes (Forbid handling, password API), tests (Govor.Server.Tests), docs, CI and tooling updates (Dockerfile → .NET 10, GH Actions matrix for sqlite/postgres, Govor.Server.slnx, global.json), and small infra changes (AutoMapper bump, NullPushProvider, storage/token handling).
2026-10-03 17:42:24 +07:00

50 lines
1.4 KiB
C#

using Govor.Domain;
using Govor.Domain.Common;
using Govor.Domain.Models;
using Microsoft.EntityFrameworkCore;
using SmartRes;
namespace Govor.Application.PrivateUserChats;
public class UserPrivateChatsGetter : IUserPrivateChatsGetterService
{
private readonly GovorDbContext _context;
public UserPrivateChatsGetter(GovorDbContext context)
{
_context = context;
}
public async Task<List<PrivateChat>> GetUserChatsAsync(Guid userId)
{
return await _context.PrivateChats
.AsNoTracking()
.Where(p => p.UserAId == userId || p.UserBId == userId)
.ToListAsync();
}
public async Task<Result<PrivateChat, Error>> GetPrivateChatAsync(Guid chatId)
{
var res = await _context.PrivateChats.AsNoTracking()
.FirstOrDefaultAsync(p => p.Id == chatId);
if (res == null)
return Result.Failure<PrivateChat>(
Error.NotFound(
"PrivateChat.NotFound",
"PrivateChat not found.")
);
return res;
}
public async Task<bool> ExistChatAsync(Guid userIdA, Guid userIdB)
{
return await _context.PrivateChats
.AsNoTracking()
.AnyAsync(p => (p.UserAId == userIdA && p.UserBId == userIdB) ||
(p.UserBId == userIdA && p.UserAId == userIdB)
);
}
}