2024-06-21 23:48:03 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using CommunityToolkit.Mvvm.Messaging;
|
2024-11-10 23:28:25 +01:00
|
|
|
|
using Wino.Core.Domain.Entities.Mail;
|
2024-06-21 23:48:03 +02:00
|
|
|
|
using Wino.Core.Domain.Enums;
|
|
|
|
|
|
using Wino.Core.Domain.Interfaces;
|
|
|
|
|
|
using Wino.Core.Domain.Models.Requests;
|
2024-08-05 00:36:26 +02:00
|
|
|
|
using Wino.Messaging.UI;
|
2024-06-21 23:48:03 +02:00
|
|
|
|
|
2024-11-26 20:03:10 +01:00
|
|
|
|
namespace Wino.Core.Requests.Mail
|
2024-06-21 23:48:03 +02:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Archive message request.
|
|
|
|
|
|
/// By default, the message will be moved to the Archive folder.
|
|
|
|
|
|
/// For Gmail, 'Archive' label will be removed from the message.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="IsArchiving">Whether are archiving or unarchiving</param>
|
|
|
|
|
|
/// <param name="Item">Mail to archive</param>
|
|
|
|
|
|
/// <param name="FromFolder">Source folder.</param>
|
|
|
|
|
|
/// <param name="ToFolder">Optional Target folder. Required for ImapSynchronizer and OutlookSynchronizer.</param>
|
2024-11-26 20:03:10 +01:00
|
|
|
|
public record ArchiveRequest(bool IsArchiving, MailCopy Item, MailItemFolder FromFolder, MailItemFolder ToFolder = null)
|
|
|
|
|
|
: MailRequestBase(Item), ICustomFolderSynchronizationRequest
|
2024-06-21 23:48:03 +02:00
|
|
|
|
{
|
2025-02-15 12:53:32 +01:00
|
|
|
|
public bool ExcludeMustHaveFolders => false;
|
2024-06-21 23:48:03 +02:00
|
|
|
|
public List<Guid> SynchronizationFolderIds
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var folderIds = new List<Guid> { FromFolder.Id };
|
|
|
|
|
|
|
|
|
|
|
|
if (ToFolder != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
folderIds.Add(ToFolder.Id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return folderIds;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-26 20:03:10 +01:00
|
|
|
|
public override MailSynchronizerOperation Operation => MailSynchronizerOperation.Archive;
|
2024-06-21 23:48:03 +02:00
|
|
|
|
|
|
|
|
|
|
public override void ApplyUIChanges()
|
|
|
|
|
|
{
|
|
|
|
|
|
WeakReferenceMessenger.Default.Send(new MailRemovedMessage(Item));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void RevertUIChanges()
|
|
|
|
|
|
{
|
|
|
|
|
|
WeakReferenceMessenger.Default.Send(new MailAddedMessage(Item));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-26 20:03:10 +01:00
|
|
|
|
public class BatchArchiveRequest : BatchCollection<ArchiveRequest>
|
2024-06-21 23:48:03 +02:00
|
|
|
|
{
|
2024-11-26 20:03:10 +01:00
|
|
|
|
public BatchArchiveRequest(IEnumerable<ArchiveRequest> collection) : base(collection)
|
2024-06-21 23:48:03 +02:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|