1
0
Fork 0
forked from mirror/pixelfed

Update ActivityPub

This commit is contained in:
Daniel Supernault 2019-02-25 14:23:54 -07:00
parent e2707ba174
commit d2823e64fa
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 7 additions and 6 deletions

View file

@ -30,7 +30,7 @@ class Helpers {
public static function validateObject($data) public static function validateObject($data)
{ {
// todo: undo // todo: undo
$verbs = ['Create', 'Announce', 'Like', 'Follow', 'Delete', 'Accept', 'Reject']; $verbs = ['Create', 'Announce', 'Like', 'Follow', 'Delete', 'Accept', 'Reject', 'Undo'];
$valid = Validator::make($data, [ $valid = Validator::make($data, [
'type' => [ 'type' => [
@ -41,7 +41,7 @@ class Helpers {
'actor' => 'required|string', 'actor' => 'required|string',
'object' => 'required', 'object' => 'required',
'object.type' => 'required_if:type,Create', 'object.type' => 'required_if:type,Create',
'object.attachment' => 'required_if:type,Create', //'object.attachment' => 'required_if:type,Create',
'object.attributedTo' => 'required_if:type,Create', 'object.attributedTo' => 'required_if:type,Create',
'published' => 'required_if:type,Create|date' 'published' => 'required_if:type,Create|date'
])->passes(); ])->passes();
@ -136,7 +136,7 @@ class Helpers {
'127.0.0.1', 'localhost', '::1' '127.0.0.1', 'localhost', '::1'
]; ];
$valid = filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED|FILTER_FLAG_HOST_REQUIRED); $valid = filter_var($url, FILTER_VALIDATE_URL);
if(in_array(parse_url($valid, PHP_URL_HOST), $localhosts)) { if(in_array(parse_url($valid, PHP_URL_HOST), $localhosts)) {
return false; return false;
@ -232,8 +232,8 @@ class Helpers {
$ts = is_array($res['published']) ? $res['published'][0] : $res['published']; $ts = is_array($res['published']) ? $res['published'][0] : $res['published'];
$status = new Status; $status = new Status;
$status->profile_id = $profile->id; $status->profile_id = $profile->id;
$status->url = $url; $status->url = isset($res['url']) ? $res['url'] : $url;
$status->uri = $url; $status->uri = isset($res['url']) ? $res['url'] : $url;
$status->caption = strip_tags($res['content']); $status->caption = strip_tags($res['content']);
$status->rendered = Purify::clean($res['content']); $status->rendered = Purify::clean($res['content']);
$status->created_at = Carbon::parse($ts); $status->created_at = Carbon::parse($ts);

View file

@ -108,7 +108,8 @@ class HttpSignature {
'(request-target)' => 'post '.parse_url($url, PHP_URL_PATH), '(request-target)' => 'post '.parse_url($url, PHP_URL_PATH),
'Date' => $date->format('D, d M Y H:i:s \G\M\T'), 'Date' => $date->format('D, d M Y H:i:s \G\M\T'),
'Host' => parse_url($url, PHP_URL_HOST), 'Host' => parse_url($url, PHP_URL_HOST),
'Content-Type' => 'application/activity+json', 'Accept' => 'application/activity+json, application/json',
'Content-Type' => 'application/activity+json'
]; ];
if($digest) { if($digest) {