class SetMessagesUpdateProcessor implements SetMessagesProcessor {

    @VisibleForTesting
    void assertUserCanSendFrom(Username connectedUser, Optional<Username> fromUser) throws MailboxSendingNotAllowedException {
        if (!fromUser.filter(from -> canSendFrom.userCanSendFrom(connectedUser, from))
            .isPresent()) {
            throw new MailboxSendingNotAllowedException(connectedUser, fromUser);
        } else {
            LOGGER.debug("{} is allowed to send a mail using {} identity", connectedUser.asString(), fromUser);
        }
    }

    @Inject @VisibleForTesting  SetMessagesUpdateProcessor(
            UpdateMessagePatchConverter updatePatchConverter,
            MessageIdManager messageIdManager,
            SystemMailboxesProvider systemMailboxesProvider,
            Factory mailboxIdFactory,
            MessageSender messageSender,
            MetricFactory metricFactory,
            ReferenceUpdater referenceUpdater,
            CanSendFrom canSendFrom);

}