public async void Handle(SpfEntityState state, Message message) { if (message is SpfRecordsEvaluated evaluated) { List <SpfRecord> currentRecords = await Process(state.SpfRecords); List <SpfRecord> newRecords = await Process(evaluated.Records); if (!currentRecords.CollectionEqual(newRecords, new SpfRecordsReferencedEqualityComparer())) { List <string> currentReferencedRecords = currentRecords.SelectMany(x => x.RecordsStrings).ToList(); List <string> newReferencedRecords = newRecords.SelectMany(x => x.RecordsStrings).ToList(); List <string> removedRecords = currentReferencedRecords.Except(newReferencedRecords).ToList(); List <string> addedRecords = newReferencedRecords.Except(currentReferencedRecords).ToList(); if (addedRecords.Any()) { _dispatcher.Dispatch(new SpfReferencedRecordAdded(state.Id, addedRecords), _spfEntityConfig.SnsTopicArn); } if (removedRecords.Any()) { _dispatcher.Dispatch(new SpfReferencedRecordRemoved(state.Id, removedRecords), _spfEntityConfig.SnsTopicArn); } } } }
public void Handle(TlsEntityState state, Message message, List <string> domains) { if (message is TlsResultsEvaluated evaluationResult) { List <TlsEvaluatedResult> currentMessages = GetAdvisoryMessages(state.TlsRecords); List <TlsEvaluatedResult> newMessages = GetAdvisoryMessages(evaluationResult.TlsRecords); _logger.LogInformation( $"Evaluation Result messages count: {newMessages.Count}"); List <TlsEvaluatedResult> addedMessages = newMessages.Except(currentMessages).ToList(); if (addedMessages.Any()) { foreach (string domain in domains) { TlsAdvisoryAdded advisoryAdded = new TlsAdvisoryAdded(domain, state.Id, addedMessages.Select(x => new AdvisoryMessage(GetMessageType(x.Result.Value), x.Description)) .ToList()); _dispatcher.Dispatch(advisoryAdded, _tlsEntityConfig.SnsTopicArn); _logger.LogInformation( $"TlsAdvisoryAdded message dispatched to {_tlsEntityConfig.SnsTopicArn} for domain: {domain} and host: {message.Id}"); } } else { _logger.LogInformation($"No new TlsAdvisoryAdded found for host: {message.Id}"); } List <TlsEvaluatedResult> removedMessages = currentMessages.Except(newMessages).ToList(); if (removedMessages.Any()) { foreach (string domain in domains) { TlsAdvisoryRemoved advisoryRemoved = new TlsAdvisoryRemoved(domain, state.Id, removedMessages.Select(x => new AdvisoryMessage(GetMessageType(x.Result.Value), x.Description)) .ToList()); _dispatcher.Dispatch(advisoryRemoved, _tlsEntityConfig.SnsTopicArn); _logger.LogInformation( $"TlsAdvisoryRemoved message dispatched to {_tlsEntityConfig.SnsTopicArn} for domain: {domain} and host: {message.Id}"); } } else { _logger.LogInformation($"No new TlsAdvisoryRemoved found for host: {message.Id}"); } } }
public async Task Handle(TlsRptRecordExpired message) { string messageId = message.Id.ToLower(); TlsRptEntityState state = await LoadState(messageId, nameof(message)); Message updatePollPending = state.UpdatePollPending(); state.Version++; await _dao.Save(state); _dispatcher.Dispatch(updatePollPending, _tlsRptEntityConfig.SnsTopicArn); }
public async Task Handle(TlsRptRecordsEvaluated message) { string messageId = message.Id.ToLower(); TlsRptEntityState state = await LoadState(messageId, nameof(message)); _changeNotifiersComposite.Handle(state, message); Message updateTlsRptEvaluation = state.UpdateTlsRptEvaluation(message.Records, message.Messages, message.Timestamp); state.Version++; await _dao.Save(state); _dispatcher.Dispatch(updateTlsRptEvaluation, _tlsRptEntityConfig.SnsTopicArn); }
public void Handle(SpfEntityState state, Message message) { if (message is SpfRecordsEvaluated evaluated) { List <string> currentRecords = state.SpfRecords?.Records.SelectMany(x => x.RecordsStrings).ToList() ?? new List <string>(); List <string> newRecords = evaluated.Records?.Records.SelectMany(x => x.RecordsStrings).ToList() ?? new List <string>(); List <string> removedRecords = currentRecords.Except(newRecords).ToList(); List <string> addedRecords = newRecords.Except(currentRecords).ToList(); if (addedRecords.Any()) { _dispatcher.Dispatch(new SpfRecordAdded(state.Id, addedRecords), _spfEntityConfig.SnsTopicArn); } if (removedRecords.Any()) { _dispatcher.Dispatch(new SpfRecordRemoved(state.Id, removedRecords), _spfEntityConfig.SnsTopicArn); } } }