using System; using System.Threading; using System.Threading.Tasks; using Wino.Core.Domain.Interfaces; using Wino.Core.Domain.Models.Server; using Wino.Messaging.Server; using Wino.Server.Core; namespace Wino.Server.MessageHandlers { public class SingleMimeDownloadHandler : ServerMessageHandler { public override WinoServerResponse FailureDefaultResponse(Exception ex) => WinoServerResponse.CreateErrorResponse(ex.Message); private readonly ISynchronizerFactory _synchronizerFactory; public SingleMimeDownloadHandler(ISynchronizerFactory synchronizerFactory) { _synchronizerFactory = synchronizerFactory; } protected override async Task> HandleAsync(DownloadMissingMessageRequested message, CancellationToken cancellationToken = default) { var synchronizer = await _synchronizerFactory.GetAccountSynchronizerAsync(message.AccountId); // TODO: ITransferProgress support is lost. await synchronizer.DownloadMissingMimeMessageAsync(message.MailItem, null, cancellationToken); return WinoServerResponse.CreateSuccessResponse(true); } } }