mirror of
https://github.com/MAKS-IT-COM/maksit-postclient.git
synced 2026-11-13 21:56:11 +01:00
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
namespace MaksIT.PostClient.Shared;
|
|
|
|
|
|
public static class MailDrop {
|
|
public static bool AcceptsFolders(string? incomingProtocol) =>
|
|
!MailProtocol.IsPop3(incomingProtocol);
|
|
|
|
public static bool CanDropMessages(
|
|
string? destProtocol,
|
|
string destMailboxId,
|
|
string? destFolder,
|
|
string sourceMailboxId,
|
|
string sourceFolder) {
|
|
if (!AcceptsFolders(destProtocol)
|
|
|| string.IsNullOrWhiteSpace(destMailboxId)
|
|
|| string.IsNullOrWhiteSpace(sourceMailboxId)
|
|
|| string.IsNullOrWhiteSpace(sourceFolder))
|
|
return false;
|
|
if (string.IsNullOrWhiteSpace(destFolder))
|
|
return true;
|
|
return !destMailboxId.Equals(sourceMailboxId, StringComparison.OrdinalIgnoreCase)
|
|
|| !MailFolderPath.Normalize(destFolder)
|
|
.Equals(MailFolderPath.Normalize(sourceFolder), StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
public static bool CanDropFolder(
|
|
string? destProtocol,
|
|
string destMailboxId,
|
|
string? destParent,
|
|
string sourceMailboxId,
|
|
string sourceFolder,
|
|
bool sourceIsCustom) {
|
|
if (!sourceIsCustom
|
|
|| !AcceptsFolders(destProtocol)
|
|
|| string.IsNullOrWhiteSpace(destMailboxId)
|
|
|| string.IsNullOrWhiteSpace(sourceMailboxId)
|
|
|| string.IsNullOrWhiteSpace(sourceFolder))
|
|
return false;
|
|
if (MailFolderPath.IsSelfOrUnder(destParent, sourceFolder))
|
|
return false;
|
|
return !destMailboxId.Equals(sourceMailboxId, StringComparison.OrdinalIgnoreCase)
|
|
|| !MailFolderPath.SameParent(sourceFolder, destParent);
|
|
}
|
|
}
|