public virtual async Task <Guid> Edit(Guid currentUserId, Guid chatId, Guid messageId, TChatMessageInfo messageInfo, Guid?archivedMessageId) { await ChatMessagesPermissionValidator.ValidateEdit(currentUserId, chatId, messageId, messageInfo, ServiceName) .ConfigureAwait(false); var command = ChatMessagesCommandBuilder.BuildEditChatMessageCommand(currentUserId, chatId, messageId, messageInfo, archivedMessageId); await ChatCommandSender.Send(command).ConfigureAwait(false); return(command.ArchivedMessageId); }
public virtual async Task Handle(IEditChatMessageCommand <TChatInfo, TChatUser, TChatMessageInfo, TTextMessage, TQuoteMessage, TMessageAttachmentCollection, TMessageAttachment, TChatRefMessageCollection, TChatRefMessage, TContactMessageCollection, TContactMessage> command, IChatBusContext chatEventPublisher) { var currentMessage = await ChatMessageStore.Retrieve(command.ChatId, command.MessageId).ConfigureAwait(false); if (!currentMessage.IsSystem) { await ChatMessagesPermissionValidator.ValidateEdit(command.InitiatorUserId, command.ChatId, command.MessageId, command.MessageInfo, WorkerName).ConfigureAwait(false); } if (currentMessage.Immutable) { throw new DotChatEditImmutableMessageException(command.MessageId, command.ChatId, command.InitiatorUserId); } var message = await ChatMessageStore.Update(command.ChatId, command.MessageId, command.MessageInfo, command.InitiatorUserId).ConfigureAwait(false); await ChatMessageStore.Archive(command.ChatId, currentMessage.MessageId, command.ArchivedMessageId, currentMessage, command.InitiatorUserId).ConfigureAwait(false); var @event = ChatMessagesEventBuilder.BuildChatMessageEditedEvent(command.InitiatorUserId, command.ChatId, message); await chatEventPublisher.EventPublisher.Publish(@event).ConfigureAwait(false); }