Update ApiV1Dot1Controller, add story report support

pull/6134/head
Daniel Supernault 3 months ago
parent 35424ccb4d
commit f5dced0f7a
No known key found for this signature in database
GPG Key ID: 23740873EE6F76A1

@ -35,6 +35,7 @@ use App\Services\StatusService;
use App\Services\UserStorageService;
use App\Status;
use App\StatusArchived;
use App\Story;
use App\User;
use App\UserSetting;
use App\Util\Lexer\RestrictedNames;
@ -145,6 +146,26 @@ class ApiV1Dot1Controller extends Controller
$rpid = $object->id;
break;
case 'story':
$object = Story::whereActive(true)->find($object_id);
if (! $object) {
return $this->error('Invalid object id', 400, ['error_code' => 'ERROR_INVALID_OBJECT_ID']);
}
if ($object->profile_id == $user->profile_id) {
return $this->error('Cannot self report', 400, ['error_code' => 'ERROR_NO_SELF_REPORTS']);
}
if (! FollowerService::follows($user->profile_id, $object->profile_id)) {
return $this->error('Invalid object id', 400, ['error_code' => 'ERROR_INVALID_OBJECT_ID']);
}
$object_type = 'App\Story';
$exists = Report::whereUserId($user->id)
->whereObjectId($object->id)
->whereObjectType('App\Story')
->count();
$rpid = $object->profile_id;
break;
default:
return $this->error('Invalid report type', 400, ['error_code' => 'ERROR_REPORT_OBJECT_TYPE_INVALID']);
break;

Loading…
Cancel
Save