@@ -18,7 +18,10 @@ import ru.soune.nocopy.service.search.GoogleVisionSearchService;
|
||||
import ru.soune.nocopy.service.tariff.TariffConstants;
|
||||
import ru.soune.nocopy.service.tariff.TariffInfoService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -58,7 +61,24 @@ public class ImageFoundRequestHandler implements RequestHandler {
|
||||
//TODO uncommited when add billing
|
||||
// GoogleVisionSearchResponse googleVisionSearchResponse = googleVisionSearchService.searchByFileEntity(fileId);
|
||||
|
||||
String yandexReverseSearchResponse = yandexSearchService.searchReverseByPublicUrl(fileEntity);
|
||||
String yandexReverseSearchResponse;
|
||||
try {
|
||||
yandexReverseSearchResponse = yandexSearchService.searchReverseByPublicUrlWithTimeout(fileEntity, 20);
|
||||
} catch (TimeoutException e) {
|
||||
log.warn("Search timeout for file {}, returning empty results", fileId);
|
||||
return new BaseResponse(request.getMsgId(), MessageCode.SUCCESS.getCode(),
|
||||
"Search completed (partial)", Map.of(
|
||||
"results", List.of(),
|
||||
"total", 0,
|
||||
"searchStatus", "timeout"
|
||||
));
|
||||
} catch (IOException e) {
|
||||
log.error("Search failed for file {}", fileId, e);
|
||||
return new BaseResponse(request.getMsgId(), 20007,
|
||||
"Search service temporarily unavailable",
|
||||
Map.of("fileId", fileId));
|
||||
}
|
||||
|
||||
int page = imageSearchRequest.getPage() != null ? imageSearchRequest.getPage() : 1;
|
||||
int pageSize = imageSearchRequest.getPageSize() != null ? imageSearchRequest.getPageSize() : 10;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user