1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-27 18:26:50 +00:00
pixelfed/app/Util/ActivityPub/Validator/Add.php
2020-11-18 14:19:02 -07:00

41 lines
No EOL
830 B
PHP

<?php
namespace App\Util\ActivityPub\Validator;
use Validator;
use Illuminate\Validation\Rule;
class Add {
public static function validate($payload)
{
$valid = Validator::make($payload, [
'@context' => 'required',
'id' => 'required|string',
'type' => [
'required',
Rule::in(['Add'])
],
'actor' => 'required|url',
'object' => 'required',
'object.id' => 'required|url',
'object.type' => [
'required',
Rule::in(['Story'])
],
'object.attributedTo' => 'required|url|same:actor',
'object.attachment' => 'required',
'object.attachment.type' => [
'required',
Rule::in(['Image'])
],
'object.attachment.url' => 'required|url',
'object.attachment.mediaType' => [
'required',
Rule::in(['image/jpeg', 'image/png'])
]
])->passes();
return $valid;
}
}