1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-23 16:24:29 +00:00
pixelfed/app/Util/ActivityPub/Validator/Add.php

41 lines
830 B
PHP
Raw Normal View History

2020-11-18 21:19:02 +00:00
<?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;
}
}