@@ -1,6 +1,7 @@
|
||||
package ru.soune.nocopy.service.violation;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -27,8 +28,9 @@ public class ViolationService {
|
||||
public void processViolation(YandexSearchResponse.ImageResult imageResult, FileEntity file,
|
||||
GlobalSearchResult result) {
|
||||
String url = imageResult.getUrl();
|
||||
String urlHash = DigestUtils.sha256Hex(url);
|
||||
|
||||
if (!violationRepository.existsByUrl(url)) {
|
||||
if (!violationRepository.existsByUrlHash(urlHash)) {
|
||||
Violation violation = new Violation();
|
||||
|
||||
if (result != null) {
|
||||
@@ -37,6 +39,7 @@ public class ViolationService {
|
||||
|
||||
violation.setHost(imageResult.getHost());
|
||||
violation.setUrl(url);
|
||||
violation.setUrlHash(urlHash);
|
||||
violation.setPageUrl(imageResult.getPageUrl());
|
||||
violation.setPageTitle(imageResult.getPageTitle());
|
||||
violation.setFileEntity(file);
|
||||
|
||||
Reference in New Issue
Block a user