feat: invites

This commit is contained in:
2026-09-28 09:32:22 +04:00
parent 3055381788
commit 7e1e036bf1
24 changed files with 936 additions and 29 deletions
@@ -1,4 +1,5 @@
using MemeVault.Domain.Aggregates.Collection;
using MemeVault.Domain.Enums;
using MemeVault.Domain.Repositories;
using Microsoft.EntityFrameworkCore;
@@ -24,7 +25,8 @@ public sealed class CollectionRepository : ICollectionRepository
{
return await _db.Collections
.Include(c => c.Members)
.Where(x => x.OwnerTelegramId == ownerTelegramId)
.Where(c => c.Members.Any(m =>
m.TelegramId == ownerTelegramId && m.Role == CollectionRole.Owner))
.OrderBy(x => x.IsInbox ? 0 : 1) // Inbox всегда первым
.ThenBy(x => x.Name)
.ToListAsync(ct);
@@ -32,7 +34,11 @@ public sealed class CollectionRepository : ICollectionRepository
public Task<Collection?> GetInboxAsync(long ownerTelegramId, CancellationToken ct) =>
_db.Collections
.FirstOrDefaultAsync(x => x.OwnerTelegramId == ownerTelegramId && x.IsInbox, ct);
.Include(c => c.Members)
.FirstOrDefaultAsync(c =>
c.IsInbox &&
c.Members.Any(m => m.TelegramId == ownerTelegramId && m.Role == CollectionRole.Owner),
ct);
public async Task AddAsync(Collection collection, CancellationToken ct) =>
await _db.Collections.AddAsync(collection, ct);