Files
Wino-Mail/Wino.Core.Domain/Entities/Mail/MailItemFolder.cs

75 lines
2.5 KiB
C#
Raw Normal View History

2024-04-18 01:44:37 +02:00
using System;
using System.Collections.Generic;
using System.Diagnostics;
using SQLite;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Models.Folders;
2025-02-16 11:54:23 +01:00
namespace Wino.Core.Domain.Entities.Mail;
[DebuggerDisplay("{FolderName} - {SpecialFolderType}")]
public class MailItemFolder : IMailItemFolder
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
[PrimaryKey]
public Guid Id { get; set; }
public string RemoteFolderId { get; set; }
public string ParentRemoteFolderId { get; set; }
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public Guid MailAccountId { get; set; }
public string FolderName { get; set; }
public SpecialFolderType SpecialFolderType { get; set; }
public bool IsSystemFolder { get; set; }
public bool IsSticky { get; set; }
public bool IsSynchronizationEnabled { get; set; }
public bool IsHidden { get; set; }
public bool ShowUnreadCount { get; set; }
public DateTime? LastSynchronizedDate { get; set; }
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// For IMAP
public uint UidValidity { get; set; }
public long HighestModeSeq { get; set; }
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
/// <summary>
/// Outlook shares delta changes per-folder. Gmail is for per-account.
/// This is only used for Outlook provider.
/// </summary>
public string DeltaToken { get; set; }
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// For GMail Labels
public string TextColorHex { get; set; }
public string BackgroundColorHex { get; set; }
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
[Ignore]
public List<IMailItemFolder> ChildFolders { get; set; } = [];
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Category and Move type folders are not valid move targets.
// These folders are virtual. They don't exist on the server.
public bool IsMoveTarget => !(SpecialFolderType == SpecialFolderType.More || SpecialFolderType == SpecialFolderType.Category);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public bool ContainsSpecialFolderType(SpecialFolderType type)
{
if (SpecialFolderType == type)
return true;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
foreach (var child in ChildFolders)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
if (child.SpecialFolderType == type)
{
2024-04-18 01:44:37 +02:00
return true;
2025-02-16 11:54:23 +01:00
}
else
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
return child.ContainsSpecialFolderType(type);
2024-04-18 01:44:37 +02:00
}
}
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
return false;
}
2025-02-16 11:54:23 +01:00
public static MailItemFolder CreateMoreFolder() => new MailItemFolder() { IsSticky = true, SpecialFolderType = SpecialFolderType.More, FolderName = Translator.MoreFolderNameOverride };
public static MailItemFolder CreateCategoriesFolder() => new MailItemFolder() { IsSticky = true, SpecialFolderType = SpecialFolderType.Category, FolderName = Translator.CategoriesFolderNameOverride };
public override string ToString() => FolderName;
2024-04-18 01:44:37 +02:00
}