feat: много запланированного
- клонирование коллекции - добавление паблик-коллекций - регенерация паблик-ссылок
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
using MediatR;
|
||||
using MemeVault.Application.Common;
|
||||
using MemeVault.Domain.Exceptions;
|
||||
using MemeVault.Domain.Repositories;
|
||||
|
||||
namespace MemeVault.Application.Commands.UpdateCollection;
|
||||
|
||||
public sealed class UpdateCollectionCommandHandler(
|
||||
ICollectionRepository collections,
|
||||
IBotUserRepository users,
|
||||
IUnitOfWork unitOfWork)
|
||||
: IRequestHandler<UpdateCollectionCommand, bool>
|
||||
{
|
||||
@@ -17,6 +19,10 @@ public sealed class UpdateCollectionCommandHandler(
|
||||
if (collection is null || collection.GetRole(request.RequestingTelegramId) is null)
|
||||
return false;
|
||||
|
||||
var user = await users.GetByTelegramIdAsync(request.RequestingTelegramId, ct);
|
||||
if (user?.InboxCollectionId == collection.Id)
|
||||
throw new DomainException("Cannot rename the Inbox collection.");
|
||||
|
||||
collection.Rename(request.Name, request.RequestingTelegramId);
|
||||
await unitOfWork.SaveChangesAsync(ct);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user