using System; using System.Threading; using System.Threading.Tasks; using MimeKit; using Wino.Core.Domain.Models.MailItem; using Wino.Core.Domain.Models.Reader; namespace Wino.Core.Domain.Interfaces; public interface IMimeFileService { /// /// Finds the EML file for the given mail id for address, parses and returns MimeMessage. /// /// Cancellation token /// Mime message information Task GetMimeMessageInformationAsync(Guid fileId, Guid accountId, CancellationToken cancellationToken = default); /// /// Gets the mime message information for the given EML file bytes. /// This override is used when EML file association launch is used /// because we may not have the access to the file path. /// /// Byte array of the file. /// Cancellation token /// Mime message information Task GetMimeMessageInformationAsync(byte[] fileBytes, string emlFilePath, CancellationToken cancellationToken = default); /// /// Saves EML file to the disk. /// /// MailCopy of the native message. /// MimeMessage that is parsed from native message. /// Which account Id to save this file for. Task SaveMimeMessageAsync(Guid fileId, MimeMessage mimeMessage, Guid accountId); /// /// Returns a path that all Mime resources (including eml) is stored for this MailCopyId /// This is useful for storing previously rendered attachments as well. /// /// Account address /// Resource mail copy id Task GetMimeResourcePathAsync(Guid accountId, Guid fileId); /// /// Returns whether mime file exists locally or not. /// Task IsMimeExistAsync(Guid accountId, Guid fileId); /// /// Creates HtmlPreviewVisitor for the given MimeMessage. /// /// Mime /// File path that mime is located to load resources. HtmlPreviewVisitor CreateHTMLPreviewVisitor(MimeMessage message, string mimeLocalPath); /// /// Deletes the given mime file from the disk. /// Task DeleteMimeMessageAsync(Guid accountId, Guid fileId); /// /// Prepares the final model containing rendering details. /// /// Message to render. /// File path that physical MimeMessage is located. /// Rendering options MailRenderModel GetMailRenderModel(MimeMessage message, string mimeLocalPath, MailRenderingOptions options = null); /// /// Deletes every file in the mime cache for the given account. /// /// Account id. Task DeleteUserMimeCacheAsync(Guid accountId); }