/// <summary> /// The default constructor. /// </summary> /// <param name="piranha">The Piranha API</param> /// <param name="config">The configuration to use</param> /// <param name="httpClientFactory">The factory to use to get http client for requests</param> /// <param name="loggerFactory">The factory to use to get a logger</param> protected SpamDetectorService(IApi piranha, SpamDetectorConfigService config, IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory) { Piranha = piranha; HttpClientFactory = httpClientFactory; ConfigModel = config.Get(); if (loggerFactory != null) { Logger = loggerFactory.CreateLogger(this.GetType().FullName); } if (!ConfigModel.Enabled) { Logger.LogWarning("Module disabled by configuration: comments will not be reviewed/changed"); } if (string.IsNullOrEmpty(ConfigModel.SpamApiUrl)) { const string msg = "Module not configured properly, mandatory value missing: SpamApiUrl"; Logger.LogError(msg); throw new InvalidOperationException(msg); } if (string.IsNullOrEmpty(ConfigModel.SiteUrl)) { Logger.LogWarning("Option SiteUrl is missing: results may be wrong"); } if (ConfigModel.IsTest) { Logger.LogWarning("Option IsTest is true: no live requests will be made"); } }
public SpamDetectorConfigModel List() { return(_config.Get()); }