diff --git a/src/main/java/ru/soune/nocopy/handler/ViolationHandler.java b/src/main/java/ru/soune/nocopy/handler/ViolationHandler.java index 00ed8fd..19c845b 100644 --- a/src/main/java/ru/soune/nocopy/handler/ViolationHandler.java +++ b/src/main/java/ru/soune/nocopy/handler/ViolationHandler.java @@ -176,10 +176,20 @@ public class ViolationHandler implements RequestHandler { for (Violation violation : content) { if (firstShowViolation != null && Objects.equals(firstShowViolation.getId(), violation.getId())) continue; + String country; + String countryCode; ViolationResponse.ViolationDto violationDto = ViolationResponse.ViolationDto.fromEntity(violation); - violationDto.setCountry(geoCountryService.getCountryName(violation.getPageUrl())); - violationDto.setCountryCode(geoCountryService.getCountryCode(violation.getPageUrl())); + try { + country = geoCountryService.getCountryName(violation.getHost()); + countryCode = geoCountryService.getCountryCode(violation.getHost()); + } catch (Exception e) { + country = geoCountryService.getCountryName(violation.getUrl()); + countryCode = geoCountryService.getCountryCode(violation.getUrl()); + } + + violationDto.setCountry(country); + violationDto.setCountryCode(countryCode); violationDtos.add(violationDto); }