Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return vision.safeSearchDetection(image).then((batchAnnotateImagesResponse) => {
console.log('SafeSearch results on image', batchAnnotateImagesResponse);
const safeSearchResult = batchAnnotateImagesResponse[0].safeSearchAnnotation;
const Likelihood = Vision.types.Likelihood;
if (Likelihood[safeSearchResult.adult] >= Likelihood.LIKELY ||
Likelihood[safeSearchResult.violence] >= Likelihood.LIKELY) {
return blurImage(object.name, object.bucket, object.metadata).then(() => {
const filePathSplit = object.name.split(path.sep);
const uid = filePathSplit[0];
const size = filePathSplit[1]; // 'thumb' or 'full'
const postId = filePathSplit[2];
return refreshImages(uid, postId, size);
});
}
console.log('The image', object.name, 'has been detected as OK.');
});
});
return vision.safeSearchDetection(image).then(batchAnnotateImagesResponse => {
const safeSearchResult = batchAnnotateImagesResponse[0].safeSearchAnnotation;
const Likelihood = Vision.types.Likelihood;
if (Likelihood[safeSearchResult.adult] >= Likelihood.LIKELY ||
Likelihood[safeSearchResult.violence] >= Likelihood.LIKELY) {
console.log('The image', object.name, 'has been detected as inappropriate.');
return blurImage(object.name, object.bucket);
} else {
console.log('The image', object.name,'has been detected as OK.');
}
});
});