From d2823e64fa108a00ed03fafde1d1f3b73057bce4 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 25 Feb 2019 14:23:54 -0700 Subject: [PATCH] Update ActivityPub --- app/Util/ActivityPub/Helpers.php | 10 +++++----- app/Util/ActivityPub/HttpSignature.php | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Util/ActivityPub/Helpers.php b/app/Util/ActivityPub/Helpers.php index 3a73c1a9..d0f1296f 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 72a874f7..d6ed0040 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) {