private DmarcConfigReadModelEntity Process(DmarcConfig dmarcConfig)
        {
            Dmarc.Domain.DmarcConfig    parsedConfig = _dmarcConfigParser.Parse(dmarcConfig);
            Dmarc.ReadModel.DmarcConfig mappedConfig = parsedConfig.ToDmarcConfig();
            string spfConfigSerialized = JsonConvert.SerializeObject(mappedConfig, _serializerSettings);

            return(new DmarcConfigReadModelEntity(dmarcConfig.Domain.Id, mappedConfig.TotalErrorCount, (ErrorType?)mappedConfig.MaxErrorSeverity, spfConfigSerialized));
        }
Exemplo n.º 2
0
        public static DmarcConfig ToDmarcConfig(this DomainDmarcConfig domainDmarcConfig)
        {
            List <DmarcRecord> dmarcRecords = domainDmarcConfig.Records.Select(ToDmarcRecord).ToList();

            List <Error> errors = domainDmarcConfig.Errors.Select(_ => _.ToError("Global"))
                                  .Concat(domainDmarcConfig.Records.SelectMany((v, i) => v.AllErrors.Select(_ => _.ToError($"Record {i + 1}"))))
                                  .ToList();

            ErrorType?maxErrorSeverity = errors.Any()
                ? errors.Min(_ => _.ErrorType)
                : (ErrorType?)null;

            return(new DmarcConfig(dmarcRecords, errors, domainDmarcConfig.AllErrorCount, maxErrorSeverity, domainDmarcConfig.LastChecked));
        }