add Moderation.php #14
@@ -19,6 +19,9 @@ readonly class SightEngineImageSafetyService implements ImageSafetyServiceInterf
|
|||||||
public function isValid(File $file): bool
|
public function isValid(File $file): bool
|
||||||
{
|
{
|
||||||
$handle = fopen($file->getRealPath(), 'r');
|
$handle = fopen($file->getRealPath(), 'r');
|
||||||
|
if ($handle === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$response = $this->client->request('POST', 'https://api.sightengine.com/1.0/check.json', [
|
$response = $this->client->request('POST', 'https://api.sightengine.com/1.0/check.json', [
|
||||||
'body' => [
|
'body' => [
|
||||||
'media' => $handle,
|
'media' => $handle,
|
||||||
|
@@ -12,10 +12,13 @@ class ImageSafetyValidator extends ConstraintValidator
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate($value, Constraint $constraint): void
|
/**
|
||||||
|
* @param mixed $value
|
||||||
|
* @param ImageSafety $constraint
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function validate(mixed $value, Constraint $constraint): void
|
||||||
{
|
{
|
||||||
/* @var ImageSafety $constraint */
|
|
||||||
|
|
||||||
if (null === $value || '' === $value) {
|
if (null === $value || '' === $value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user