public async Task <bool> Handle(MarkAsFakeCommand request, CancellationToken cancellationToken) { var uri = new Uri(request.UrlToMark.Contains("\"") ? request.UrlToMark.Replace("\"", string.Empty) : request.UrlToMark); if (await dbService.IsVerifiedDomainAsync(uri.Host)) { return(false); // can not be added as fake becouse domain is verified } var formatted = HtmlHelper.FormatHtml(request.InnerHtml, "div"); if (formatted.Length == 0) { formatted = request.InnerHtml; } var result = await dbService.AddFakeUrlAsync(uri.AbsoluteUri, formatted, request.FakeReasons); await esService.InsertToIndexAsync(new FakeNewsCovidIndex { Id = result.Id, Fakebility = result.Fakebility, Body = formatted, Url = uri.AbsoluteUri }); return(true); }
public async Task <FakebilityQueryResult> Handle(FakebilityQuery request, CancellationToken cancellationToken) { var uri = new Uri(request.UrlAddress.Contains("\"") ? request.UrlAddress.Replace("\"", string.Empty) : request.UrlAddress); if (await dbService.IsVerifiedDomainAsync(uri.Host)) { return(new FakebilityQueryResult { Fakebility = FakebilityEnum.Verified }); } var result = await dbService.CheckUrlFakebilityAsync(uri.AbsoluteUri); if (result.Item1 == FakebilityEnum.None) { await CheckElastic(result, request); } return(new FakebilityQueryResult { Fakebility = result.Item1, FakeReasons = result.Item2 != null?result.Item2.Select(x => x.ReasonNotFake) : null }); }