MailSharp / MailSharp.MailClient / Models / MessageIndexModels.cs
Code · 37 lines · 1661 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37namespace MailSharp.MailClient.Models;

// One row per message, kept up to date by IImapService.EnsureFolderIndexedAsync (full rebuild on
// UIDVALIDITY change, incremental fetch of new UIDs, UID-diff reconciliation when the message
// count doesn't match) - this is what GetMessagesAsync/GetFoldersAsync (sizes)/
// SearchByAddressAsync/GetSentContactsAsync read from instead of re-scanning IMAP live, for any
// folder whose FolderSyncMode isn't NotSynchronized.
public class IndexedMessage
{
	public string Id { get; set; } = "";
	public string Key { get; set; } = "";
	public int AccountId { get; set; }
	public string Folder { get; set; } = "";
	public uint Uid { get; set; }
	public string Subject { get; set; } = "";
	public string From { get; set; } = "";
	public string To { get; set; } = "";
	public string Cc { get; set; } = "";
	public DateTimeOffset Date { get; set; }
	public long SizeBytes { get; set; }
	public bool IsRead { get; set; }
	public bool IsFlagged { get; set; }
	public bool HasAttachments { get; set; }
	public MessagePriority Priority { get; set; } = MessagePriority.Normal;
}

// Per-(account, folder) sync checkpoint - see IImapService.EnsureFolderIndexedAsync. UidValidity
// changing means the server considers the whole mailbox rebuilt (rare); UidNext advancing means
// new mail arrived; MessageCount not matching the index's own row count is the cheap signal that
// something was removed (deleted or moved elsewhere) since the last check.
public class FolderSyncState
{
	public string Id { get; set; } = "";
	public uint UidValidity { get; set; }
	public uint UidNext { get; set; }
	public int MessageCount { get; set; }
}