feat: invites
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user