@@ -240,10 +240,13 @@ public class FileUploadServiceImpl implements FileUploadService {
|
|||||||
.fileExtension(session.getExtension())
|
.fileExtension(session.getExtension())
|
||||||
.checksum(checksum)
|
.checksum(checksum)
|
||||||
.uploadSessionId(session.getUploadId())
|
.uploadSessionId(session.getUploadId())
|
||||||
.protectionStatus(ProtectionStatus.PROCESSING)
|
|
||||||
.status(status)
|
.status(status)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
if (status != FileStatus.TEMP) {
|
||||||
|
fileEntity.setProtectionStatus(ProtectionStatus.PROCESSING);
|
||||||
|
}
|
||||||
|
|
||||||
FileEntity saved = fileEntityRepository.save(fileEntity);
|
FileEntity saved = fileEntityRepository.save(fileEntity);
|
||||||
|
|
||||||
if (session.getFileType().equals("image") && status != FileStatus.PRIVATE) {
|
if (session.getFileType().equals("image") && status != FileStatus.PRIVATE) {
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public class MonitoringSearchService {
|
|||||||
|
|
||||||
MonitoringType monitoringType = monitoring.getMonitoringType();
|
MonitoringType monitoringType = monitoring.getMonitoringType();
|
||||||
TariffDTO tariffMonitoring = tariffService.getTariffByType(TariffType.valueOf(monitoringType.name()));
|
TariffDTO tariffMonitoring = tariffService.getTariffByType(TariffType.valueOf(monitoringType.name()));
|
||||||
|
User user = userRepository.findById(monitoring.getUserId()).orElseThrow();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tariffInfoService.writeOffTokens(monitoring.getUserId(), tariffMonitoring.getTokens(), OperationType.MONITORING);
|
tariffInfoService.writeOffTokens(monitoring.getUserId(), tariffMonitoring.getTokens(), OperationType.MONITORING);
|
||||||
@@ -89,10 +90,14 @@ public class MonitoringSearchService {
|
|||||||
allResults.addAll(yandexImages);
|
allResults.addAll(yandexImages);
|
||||||
log.info("Yandex search found {} results", yandexImages.size());
|
log.info("Yandex search found {} results", yandexImages.size());
|
||||||
|
|
||||||
} catch (TimeoutException e) {
|
} catch (TimeoutException | IOException e) {
|
||||||
log.warn("Yandex search timeout for monitoring file {}", monitoring.getFile().getId());
|
log.error("Error processing monitoring search", e);
|
||||||
} catch (IOException e) {
|
monitoring.setLastRunStatus("ERROR: " + e.getMessage());
|
||||||
log.error("Yandex search failed for monitoring file {}", monitoring.getFile().getId(), e);
|
updateNextRun(monitoring);
|
||||||
|
|
||||||
|
monitoringRepository.save(monitoring);
|
||||||
|
|
||||||
|
notificationService.addNotification(NotificationType.SEARCH_OPERATION_FAILED, user.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info("Yandex search is disabled by settings");
|
log.info("Yandex search is disabled by settings");
|
||||||
@@ -109,10 +114,14 @@ public class MonitoringSearchService {
|
|||||||
allResults.addAll(googleImages);
|
allResults.addAll(googleImages);
|
||||||
log.info("Google search found {} results", googleImages.size());
|
log.info("Google search found {} results", googleImages.size());
|
||||||
|
|
||||||
} catch (TimeoutException e) {
|
} catch (TimeoutException | IOException e) {
|
||||||
log.warn("Google search timeout for monitoring file {}", monitoring.getFile().getId());
|
log.error("Error processing monitoring search", e);
|
||||||
} catch (IOException e) {
|
monitoring.setLastRunStatus("ERROR: " + e.getMessage());
|
||||||
log.error("Google search failed for monitoring file {}", monitoring.getFile().getId(), e);
|
updateNextRun(monitoring);
|
||||||
|
|
||||||
|
monitoringRepository.save(monitoring);
|
||||||
|
|
||||||
|
notificationService.addNotification(NotificationType.SEARCH_OPERATION_FAILED, user.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info("Google search is disabled by settings");
|
log.info("Google search is disabled by settings");
|
||||||
@@ -139,7 +148,6 @@ public class MonitoringSearchService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (TariffNotFoundException e) {
|
} catch (TariffNotFoundException e) {
|
||||||
User user = userRepository.findById(monitoring.getUserId()).orElseThrow();
|
|
||||||
TariffInfo activeTariffInfo = user.getActiveTariffInfo();
|
TariffInfo activeTariffInfo = user.getActiveTariffInfo();
|
||||||
int currentTokens = activeTariffInfo.getTokens() + activeTariffInfo.getBoughtTokens();
|
int currentTokens = activeTariffInfo.getTokens() + activeTariffInfo.getBoughtTokens();
|
||||||
|
|
||||||
@@ -154,7 +162,6 @@ public class MonitoringSearchService {
|
|||||||
notificationService.addNotification(NotificationType.TOKEN_NOT_FOUND, user.getId(),
|
notificationService.addNotification(NotificationType.TOKEN_NOT_FOUND, user.getId(),
|
||||||
NotificationMessage.FILE_SEARCH.getMessageKey());
|
NotificationMessage.FILE_SEARCH.getMessageKey());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
User user = userRepository.findById(monitoring.getUserId()).orElseThrow();
|
|
||||||
log.error("Error processing monitoring search", e);
|
log.error("Error processing monitoring search", e);
|
||||||
monitoring.setLastRunStatus("ERROR: " + e.getMessage());
|
monitoring.setLastRunStatus("ERROR: " + e.getMessage());
|
||||||
updateNextRun(monitoring);
|
updateNextRun(monitoring);
|
||||||
|
|||||||
Reference in New Issue
Block a user