diff --git a/app/Util/ActivityPub/Helpers.php b/app/Util/ActivityPub/Helpers.php index 3a73c1a95..d0f1296f0 100644 --- a/app/Util/ActivityPub/Helpers.php +++ b/app/Util/ActivityPub/Helpers.php @@ -30,7 +30,7 @@ class Helpers { public static function validateObject($data) { // todo: undo - $verbs = ['Create', 'Announce', 'Like', 'Follow', 'Delete', 'Accept', 'Reject']; + $verbs = ['Create', 'Announce', 'Like', 'Follow', 'Delete', 'Accept', 'Reject', 'Undo']; $valid = Validator::make($data, [ 'type' => [ @@ -41,7 +41,7 @@ class Helpers { 'actor' => 'required|string', 'object' => 'required', 'object.type' => 'required_if:type,Create', - 'object.attachment' => 'required_if:type,Create', + //'object.attachment' => 'required_if:type,Create', 'object.attributedTo' => 'required_if:type,Create', 'published' => 'required_if:type,Create|date' ])->passes(); @@ -136,7 +136,7 @@ class Helpers { '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)) { return false; @@ -232,8 +232,8 @@ class Helpers { $ts = is_array($res['published']) ? $res['published'][0] : $res['published']; $status = new Status; $status->profile_id = $profile->id; - $status->url = $url; - $status->uri = $url; + $status->url = isset($res['url']) ? $res['url'] : $url; + $status->uri = isset($res['url']) ? $res['url'] : $url; $status->caption = strip_tags($res['content']); $status->rendered = Purify::clean($res['content']); $status->created_at = Carbon::parse($ts); diff --git a/app/Util/ActivityPub/HttpSignature.php b/app/Util/ActivityPub/HttpSignature.php index 72a874f79..d6ed0040b 100644 --- a/app/Util/ActivityPub/HttpSignature.php +++ b/app/Util/ActivityPub/HttpSignature.php @@ -108,7 +108,8 @@ class HttpSignature { '(request-target)' => 'post '.parse_url($url, PHP_URL_PATH), 'Date' => $date->format('D, d M Y H:i:s \G\M\T'), '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) {