1
0
Fork 0

Update upload endpoints with MediaBlocklist checks

This commit is contained in:
Daniel Supernault 2020-07-26 22:17:00 -06:00
parent 5d0a24a779
commit 597378bfb4
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
2 changed files with 8 additions and 1 deletions

View File

@ -48,9 +48,11 @@ use App\Jobs\VideoPipeline\{
use App\Services\{ use App\Services\{
NotificationService, NotificationService,
MediaPathService, MediaPathService,
SearchApiV2Service SearchApiV2Service,
MediaBlocklistService
}; };
class ApiV1Controller extends Controller class ApiV1Controller extends Controller
{ {
protected $fractal; protected $fractal;
@ -1046,6 +1048,8 @@ class ApiV1Controller extends Controller
$path = $photo->store($storagePath); $path = $photo->store($storagePath);
$hash = \hash_file('sha256', $photo); $hash = \hash_file('sha256', $photo);
abort_if(MediaBlocklistService::exists($hash) == true, 451);
$media = new Media(); $media = new Media();
$media->status_id = null; $media->status_id = null;
$media->profile_id = $profile->id; $media->profile_id = $profile->id;

View File

@ -36,6 +36,7 @@ use App\Jobs\VideoPipeline\{
}; };
use App\Services\NotificationService; use App\Services\NotificationService;
use App\Services\MediaPathService; use App\Services\MediaPathService;
use App\Services\MediaBlocklistService;
class BaseApiController extends Controller class BaseApiController extends Controller
{ {
@ -247,6 +248,8 @@ class BaseApiController extends Controller
$path = $photo->store($storagePath); $path = $photo->store($storagePath);
$hash = \hash_file('sha256', $photo); $hash = \hash_file('sha256', $photo);
abort_if(MediaBlocklistService::exists($hash) == true, 451);
$media = new Media(); $media = new Media();
$media->status_id = null; $media->status_id = null;
$media->profile_id = $profile->id; $media->profile_id = $profile->id;