file scoped namespaces (#565)
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
namespace Wino.Core.Domain.Models.AutoDiscovery
|
||||
namespace Wino.Core.Domain.Models.AutoDiscovery;
|
||||
|
||||
public class AutoDiscoveryMinimalSettings
|
||||
{
|
||||
public class AutoDiscoveryMinimalSettings
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
public string DisplayName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Wino.Core.Domain.Models.AutoDiscovery
|
||||
namespace Wino.Core.Domain.Models.AutoDiscovery;
|
||||
|
||||
public class AutoDiscoveryProviderSetting
|
||||
{
|
||||
public class AutoDiscoveryProviderSetting
|
||||
{
|
||||
[JsonPropertyName("protocol")]
|
||||
public string Protocol { get; set; }
|
||||
[JsonPropertyName("protocol")]
|
||||
public string Protocol { get; set; }
|
||||
|
||||
[JsonPropertyName("address")]
|
||||
public string Address { get; set; }
|
||||
[JsonPropertyName("address")]
|
||||
public string Address { get; set; }
|
||||
|
||||
[JsonPropertyName("port")]
|
||||
public int Port { get; set; }
|
||||
[JsonPropertyName("port")]
|
||||
public int Port { get; set; }
|
||||
|
||||
[JsonPropertyName("secure")]
|
||||
public string Secure { get; set; }
|
||||
[JsonPropertyName("secure")]
|
||||
public string Secure { get; set; }
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public string Username { get; set; }
|
||||
}
|
||||
[JsonPropertyName("username")]
|
||||
public string Username { get; set; }
|
||||
}
|
||||
|
||||
@@ -3,70 +3,69 @@ using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
|
||||
namespace Wino.Core.Domain.Models.AutoDiscovery
|
||||
namespace Wino.Core.Domain.Models.AutoDiscovery;
|
||||
|
||||
public class AutoDiscoverySettings
|
||||
{
|
||||
public class AutoDiscoverySettings
|
||||
[JsonPropertyName("domain")]
|
||||
public string Domain { get; set; }
|
||||
|
||||
[JsonPropertyName("password")]
|
||||
public string Password { get; set; }
|
||||
|
||||
[JsonPropertyName("settings")]
|
||||
public List<AutoDiscoveryProviderSetting> Settings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this domain requires additional steps for password like app-specific password or sth.
|
||||
/// </summary>
|
||||
public bool IsPasswordSupportLinkAvailable => !string.IsNullOrEmpty(Password) && Uri.TryCreate(Password, UriKind.Absolute, out _);
|
||||
|
||||
public AutoDiscoveryMinimalSettings UserMinimalSettings { get; set; }
|
||||
|
||||
public CustomServerInformation ToServerInformation()
|
||||
{
|
||||
[JsonPropertyName("domain")]
|
||||
public string Domain { get; set; }
|
||||
var imapSettings = GetImapSettings();
|
||||
var smtpSettings = GetSmptpSettings();
|
||||
|
||||
[JsonPropertyName("password")]
|
||||
public string Password { get; set; }
|
||||
if (imapSettings == null || smtpSettings == null) return null;
|
||||
|
||||
[JsonPropertyName("settings")]
|
||||
public List<AutoDiscoveryProviderSetting> Settings { get; set; }
|
||||
string imapUrl = imapSettings.Address;
|
||||
string smtpUrl = smtpSettings.Address;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this domain requires additional steps for password like app-specific password or sth.
|
||||
/// </summary>
|
||||
public bool IsPasswordSupportLinkAvailable => !string.IsNullOrEmpty(Password) && Uri.TryCreate(Password, UriKind.Absolute, out _);
|
||||
string imapUsername = imapSettings.Username;
|
||||
string smtpUsername = smtpSettings.Username;
|
||||
|
||||
public AutoDiscoveryMinimalSettings UserMinimalSettings { get; set; }
|
||||
int imapPort = imapSettings.Port;
|
||||
int smtpPort = smtpSettings.Port;
|
||||
|
||||
public CustomServerInformation ToServerInformation()
|
||||
var serverInfo = new CustomServerInformation
|
||||
{
|
||||
var imapSettings = GetImapSettings();
|
||||
var smtpSettings = GetSmptpSettings();
|
||||
Id = Guid.NewGuid(),
|
||||
DisplayName = UserMinimalSettings.DisplayName,
|
||||
Address = UserMinimalSettings.Email,
|
||||
IncomingServerPassword = UserMinimalSettings.Password,
|
||||
OutgoingServerPassword = UserMinimalSettings.Password,
|
||||
IncomingAuthenticationMethod = Enums.ImapAuthenticationMethod.Auto,
|
||||
OutgoingAuthenticationMethod = Enums.ImapAuthenticationMethod.Auto,
|
||||
OutgoingServerSocketOption = Enums.ImapConnectionSecurity.Auto,
|
||||
IncomingServerSocketOption = Enums.ImapConnectionSecurity.Auto,
|
||||
IncomingServer = imapUrl,
|
||||
OutgoingServer = smtpUrl,
|
||||
IncomingServerPort = imapPort.ToString(),
|
||||
OutgoingServerPort = smtpPort.ToString(),
|
||||
IncomingServerType = Enums.CustomIncomingServerType.IMAP4,
|
||||
IncomingServerUsername = imapUsername,
|
||||
OutgoingServerUsername = smtpUsername,
|
||||
MaxConcurrentClients = 5
|
||||
};
|
||||
|
||||
if (imapSettings == null || smtpSettings == null) return null;
|
||||
|
||||
string imapUrl = imapSettings.Address;
|
||||
string smtpUrl = smtpSettings.Address;
|
||||
|
||||
string imapUsername = imapSettings.Username;
|
||||
string smtpUsername = smtpSettings.Username;
|
||||
|
||||
int imapPort = imapSettings.Port;
|
||||
int smtpPort = smtpSettings.Port;
|
||||
|
||||
var serverInfo = new CustomServerInformation
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
DisplayName = UserMinimalSettings.DisplayName,
|
||||
Address = UserMinimalSettings.Email,
|
||||
IncomingServerPassword = UserMinimalSettings.Password,
|
||||
OutgoingServerPassword = UserMinimalSettings.Password,
|
||||
IncomingAuthenticationMethod = Enums.ImapAuthenticationMethod.Auto,
|
||||
OutgoingAuthenticationMethod = Enums.ImapAuthenticationMethod.Auto,
|
||||
OutgoingServerSocketOption = Enums.ImapConnectionSecurity.Auto,
|
||||
IncomingServerSocketOption = Enums.ImapConnectionSecurity.Auto,
|
||||
IncomingServer = imapUrl,
|
||||
OutgoingServer = smtpUrl,
|
||||
IncomingServerPort = imapPort.ToString(),
|
||||
OutgoingServerPort = smtpPort.ToString(),
|
||||
IncomingServerType = Enums.CustomIncomingServerType.IMAP4,
|
||||
IncomingServerUsername = imapUsername,
|
||||
OutgoingServerUsername = smtpUsername,
|
||||
MaxConcurrentClients = 5
|
||||
};
|
||||
|
||||
return serverInfo;
|
||||
}
|
||||
|
||||
public AutoDiscoveryProviderSetting GetImapSettings()
|
||||
=> Settings?.Find(a => a.Protocol == "IMAP");
|
||||
|
||||
public AutoDiscoveryProviderSetting GetSmptpSettings()
|
||||
=> Settings?.Find(a => a.Protocol == "SMTP");
|
||||
return serverInfo;
|
||||
}
|
||||
|
||||
public AutoDiscoveryProviderSetting GetImapSettings()
|
||||
=> Settings?.Find(a => a.Protocol == "IMAP");
|
||||
|
||||
public AutoDiscoveryProviderSetting GetSmptpSettings()
|
||||
=> Settings?.Find(a => a.Protocol == "SMTP");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user