feat: много запланированного
- клонирование коллекции - добавление паблик-коллекций - регенерация паблик-ссылок
This commit is contained in:
+7
-8
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user