Exemplo n.º 1
0
        private async Task <(string, bool)> ExecuteAuthenticatedUserActions()
        {
            var(user, password) = _options.AccountOptions.account;

            if (await _imapConnection.AuthenticateAsync(user, password))
            {
                if (_options.FolderOptions.checkFolder)
                {
                    return(await CheckConfiguredImapFolder());
                }

                return(string.Empty, true);
            }
            else
            {
                return($"Login on server {_options.Host} failed with configured user", false);
            }


            async Task <(string, bool)> CheckConfiguredImapFolder()
            {
                return(await _imapConnection.SelectFolder(_options.FolderOptions.folderName) ?
                       (string.Empty, true) :
                       ($"Folder {_options.FolderOptions.folderName} check failed", false));
            }
        }
Exemplo n.º 2
0
        private async Task <LivenessResult> ExecuteAuthenticatedUserActions()
        {
            var(User, Password) = _options.AccountOptions.Account;

            if (await _imapConnection.AuthenticateAsync(User, Password))
            {
                if (_options.FolderOptions.CheckFolder &&
                    !await _imapConnection.SelectFolder(_options.FolderOptions.FolderName))
                {
                    _logger?.LogWarning($"{nameof(ImapLiveness)} fail connect to server {_options.Host}- SSL Enabled : {_options.ConnectionType} and open folder {_options.FolderOptions.FolderName}.");

                    return(LivenessResult.UnHealthy($"Folder {_options.FolderOptions.FolderName} check failed."));
                }

                _logger?.LogInformation($"The {nameof(ImapLiveness)} check success.");

                return(LivenessResult.Healthy());
            }
            else
            {
                _logger?.LogWarning($"{nameof(ImapLiveness)} fail connect to server {_options.Host}- SSL Enabled : {_options.ConnectionType}.");

                return(LivenessResult.UnHealthy($"Login on server {_options.Host} failed with configured user"));
            }
        }
        private async Task <HealthCheckResult> ExecuteAuthenticatedUserActions(HealthCheckContext context)
        {
            var(User, Password) = _options.AccountOptions.Account;

            if (await _imapConnection.AuthenticateAsync(User, Password))
            {
                if (_options.FolderOptions.CheckFolder &&
                    !await _imapConnection.SelectFolder(_options.FolderOptions.FolderName))
                {
                    return(new HealthCheckResult(context.Registration.FailureStatus, description: $"Folder {_options.FolderOptions.FolderName} check failed."));
                }

                return(HealthCheckResult.Healthy());
            }
            else
            {
                return(new HealthCheckResult(context.Registration.FailureStatus, description: $"Login on server {_options.Host} failed with configured user"));
            }
        }