class SetMessagesUpdateProcessor implements SetMessagesProcessor {

    @Override
    public SetMessagesResponse process(SetMessagesRequest request, MailboxSession mailboxSession) {
        TimeMetric timeMetric = metricFactory.timer(JMAP_PREFIX + "SetMessagesUpdateProcessor");
        SetMessagesResponse.Builder responseBuilder = SetMessagesResponse.builder();
        Try.ofCallable(() -> listMailboxIdsForRole(mailboxSession, Role.OUTBOX))
            .map(outboxes -> {
                prepareResponse(request, mailboxSession, responseBuilder, outboxes);
                return null;
            })
            .onFailure(e -> request.buildUpdatePatches(updatePatchConverter)
                .forEach((id, patch) -> prepareResponseIfCantReadOutboxes(responseBuilder, e, id, patch)));

        timeMetric.stopAndPublish();
        return responseBuilder.build();
    }

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

}