mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-30 17:03:16 +00:00
41 lines
No EOL
830 B
PHP
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;
|
|
}
|
|
} |