feat: много запланированного

- клонирование коллекции
- добавление паблик-коллекций
- регенерация паблик-ссылок
This commit is contained in:
2026-10-07 02:45:37 +04:00
parent c1b052e2c7
commit 274e60a433
30 changed files with 719 additions and 112 deletions
@@ -8,6 +8,7 @@ namespace MemeVault.Application.Commands.SetCollectionInbox;
public sealed class SetCollectionInboxCommandHandler(
ICollectionRepository collections,
IBotUserRepository users,
IUnitOfWork unitOfWork)
: IRequestHandler<SetCollectionInboxCommand, bool>
{
@@ -17,16 +18,14 @@ public sealed class SetCollectionInboxCommandHandler(
if (target is null || target.GetRole(request.RequestingTelegramId) != CollectionRole.Owner)
return false;
if (target.IsInbox)
var user = await users.GetByTelegramIdAsync(request.RequestingTelegramId, ct);
if (user is null) return false;
if (user.InboxCollectionId == target.Id)
throw new DomainException("Collection is already the Inbox.");
// Снимаем флаг с текущего Inbox
var currentInbox = await collections.GetInboxAsync(request.RequestingTelegramId, ct);
currentInbox?.DemoteFromInbox();
// Промоция целевой коллекции
target.PromoteToInbox(request.RequestingTelegramId);
user.SetInboxCollection(target.Id);
await users.UpdateAsync(user, ct);
await unitOfWork.SaveChangesAsync(ct);
return true;
}