@@ -1,24 +1,25 @@
|
||||
using System.IO;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
|
||||
namespace Wino.Core.Domain.Models.Connectivity;
|
||||
|
||||
public class ImapClientPoolOptions
|
||||
namespace Wino.Core.Domain.Models.Connectivity
|
||||
{
|
||||
public Stream ProtocolLog { get; }
|
||||
public CustomServerInformation ServerInformation { get; }
|
||||
public bool IsTestPool { get; }
|
||||
|
||||
protected ImapClientPoolOptions(CustomServerInformation serverInformation, Stream protocolLog, bool isTestPool)
|
||||
public class ImapClientPoolOptions
|
||||
{
|
||||
ServerInformation = serverInformation;
|
||||
ProtocolLog = protocolLog;
|
||||
IsTestPool = isTestPool;
|
||||
public Stream ProtocolLog { get; }
|
||||
public CustomServerInformation ServerInformation { get; }
|
||||
public bool IsTestPool { get; }
|
||||
|
||||
protected ImapClientPoolOptions(CustomServerInformation serverInformation, Stream protocolLog, bool isTestPool)
|
||||
{
|
||||
ServerInformation = serverInformation;
|
||||
ProtocolLog = protocolLog;
|
||||
IsTestPool = isTestPool;
|
||||
}
|
||||
|
||||
public static ImapClientPoolOptions CreateDefault(CustomServerInformation serverInformation, Stream protocolLog)
|
||||
=> new(serverInformation, protocolLog, false);
|
||||
|
||||
public static ImapClientPoolOptions CreateTestPool(CustomServerInformation serverInformation, Stream protocolLog)
|
||||
=> new(serverInformation, protocolLog, true);
|
||||
}
|
||||
|
||||
public static ImapClientPoolOptions CreateDefault(CustomServerInformation serverInformation, Stream protocolLog)
|
||||
=> new(serverInformation, protocolLog, false);
|
||||
|
||||
public static ImapClientPoolOptions CreateTestPool(CustomServerInformation serverInformation, Stream protocolLog)
|
||||
=> new(serverInformation, protocolLog, true);
|
||||
}
|
||||
|
||||
@@ -3,45 +3,46 @@ using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using Wino.Core.Domain.Extensions;
|
||||
|
||||
namespace Wino.Core.Domain.Models.Connectivity;
|
||||
|
||||
/// <summary>
|
||||
/// Contains validation of the IMAP server connectivity during account setup.
|
||||
/// </summary>
|
||||
public class ImapConnectivityTestResults
|
||||
namespace Wino.Core.Domain.Models.Connectivity
|
||||
{
|
||||
[JsonConstructor]
|
||||
protected ImapConnectivityTestResults() { }
|
||||
|
||||
public bool IsSuccess { get; set; }
|
||||
|
||||
public bool IsCertificateUIRequired { get; set; }
|
||||
|
||||
public string FailedReason { get; set; }
|
||||
public string FailureProtocolLog { get; set; }
|
||||
|
||||
public static ImapConnectivityTestResults Success() => new ImapConnectivityTestResults() { IsSuccess = true };
|
||||
public static ImapConnectivityTestResults Failure(Exception ex, string failureProtocolLog) => new ImapConnectivityTestResults()
|
||||
/// <summary>
|
||||
/// Contains validation of the IMAP server connectivity during account setup.
|
||||
/// </summary>
|
||||
public class ImapConnectivityTestResults
|
||||
{
|
||||
FailedReason = string.Join(Environment.NewLine, ex.GetInnerExceptions().Select(e => e.Message)),
|
||||
FailureProtocolLog = failureProtocolLog
|
||||
};
|
||||
[JsonConstructor]
|
||||
protected ImapConnectivityTestResults() { }
|
||||
|
||||
public static ImapConnectivityTestResults CertificateUIRequired(string issuer,
|
||||
string expirationString,
|
||||
string validFromString)
|
||||
{
|
||||
return new ImapConnectivityTestResults()
|
||||
public bool IsSuccess { get; set; }
|
||||
|
||||
public bool IsCertificateUIRequired { get; set; }
|
||||
|
||||
public string FailedReason { get; set; }
|
||||
public string FailureProtocolLog { get; set; }
|
||||
|
||||
public static ImapConnectivityTestResults Success() => new ImapConnectivityTestResults() { IsSuccess = true };
|
||||
public static ImapConnectivityTestResults Failure(Exception ex, string failureProtocolLog) => new ImapConnectivityTestResults()
|
||||
{
|
||||
IsSuccess = false,
|
||||
IsCertificateUIRequired = true,
|
||||
CertificateIssuer = issuer,
|
||||
CertificateExpirationDateString = expirationString,
|
||||
CertificateValidFromDateString = validFromString
|
||||
FailedReason = string.Join(Environment.NewLine, ex.GetInnerExceptions().Select(e => e.Message)),
|
||||
FailureProtocolLog = failureProtocolLog
|
||||
};
|
||||
}
|
||||
|
||||
public string CertificateIssuer { get; set; }
|
||||
public string CertificateValidFromDateString { get; set; }
|
||||
public string CertificateExpirationDateString { get; set; }
|
||||
public static ImapConnectivityTestResults CertificateUIRequired(string issuer,
|
||||
string expirationString,
|
||||
string validFromString)
|
||||
{
|
||||
return new ImapConnectivityTestResults()
|
||||
{
|
||||
IsSuccess = false,
|
||||
IsCertificateUIRequired = true,
|
||||
CertificateIssuer = issuer,
|
||||
CertificateExpirationDateString = expirationString,
|
||||
CertificateValidFromDateString = validFromString
|
||||
};
|
||||
}
|
||||
|
||||
public string CertificateIssuer { get; set; }
|
||||
public string CertificateValidFromDateString { get; set; }
|
||||
public string CertificateExpirationDateString { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user