aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-01-28 14:57:37 +0000
committerMario <mario@mariovavti.com>2021-01-28 14:57:37 +0000
commit8c2442eca5889a5ece659bdb456403b28285b26b (patch)
tree83f0ca36be46f2aa775880572a24f1a62110217f /Zotlabs/Lib
parent8b78e18fb8ade1d04dbf2e5152288f6982a462df (diff)
downloadvolse-hubzilla-8c2442eca5889a5ece659bdb456403b28285b26b.tar.gz
volse-hubzilla-8c2442eca5889a5ece659bdb456403b28285b26b.tar.bz2
volse-hubzilla-8c2442eca5889a5ece659bdb456403b28285b26b.zip
AS channel discovery with custom access header
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php10
-rw-r--r--Zotlabs/Lib/ActivityStreams.php29
2 files changed, 29 insertions, 10 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 388d74d91..3bfdf722a 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -87,14 +87,16 @@ class Activity {
}
$headers = [
- 'Accept' => 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
+ 'Accept' => ActivityStreams::get_accept_header_string($channel),
'Host' => $m['host'],
'Date' => datetime_convert('UTC', 'UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T'),
'(request-target)' => 'get ' . get_request_string($url)
];
+
if (isset($token)) {
$headers['Authorization'] = 'Bearer ' . $token;
}
+
$h = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), false);
$x = z_fetch_url($url, true, $redirects, ['headers' => $h]);
}
@@ -302,7 +304,7 @@ class Activity {
$m = get_iconfig($i['id'], 'activitypub', 'rawmsg');
if ($m) {
if (is_string($m))
- $t = json_decode($m,true);
+ $t = json_decode($m, true);
else
$t = $m;
}
@@ -2563,7 +2565,7 @@ class Activity {
$allowed = true;
// reject public stream comments that weren't sent by the conversation owner
- if ($is_sys_channel && $pubstream && $item['owner_xchan'] !== $observer_hash && ! $fetch_parents) { // TODO: check why? This would make it impossible to fetch externals via zotfeed where $observer_hash = sys channel
+ if ($is_sys_channel && $pubstream && $item['owner_xchan'] !== $observer_hash && !$fetch_parents) {
$allowed = false;
}
}
@@ -2963,7 +2965,7 @@ class Activity {
break;
}
- array_unshift($p,[ $a, $item ]);
+ array_unshift($p, [$a, $item]);
if ($item['parent_mid'] === $item['mid']) {
break;
diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php
index f877fbb45..a1d780205 100644
--- a/Zotlabs/Lib/ActivityStreams.php
+++ b/Zotlabs/Lib/ActivityStreams.php
@@ -409,16 +409,33 @@ class ActivityStreams {
return $x;
}
- static function is_as_request() {
+ static function is_as_request($channel = null) {
- $x = getBestSupportedMimeType([
- 'application/ld+json;profile="https://www.w3.org/ns/activitystreams"',
- 'application/activity+json',
- 'application/ld+json;profile="http://www.w3.org/ns/activitystreams"'
- ]);
+ $hookdata = [];
+ if($channel)
+ $hookdata['channel'] = $channel;
+ $hookdata['data'] = ['application/x-zot-activity+json'];
+
+ call_hooks('is_as_request', $hookdata);
+
+ $x = getBestSupportedMimeType($hookdata['data']);
return(($x) ? true : false);
}
+ static function get_accept_header_string($channel = null) {
+
+ $hookdata = [];
+ if($channel)
+ $hookdata['channel'] = $channel;
+
+ $hookdata['data'] = 'application/x-zot-activity+json';
+
+ call_hooks('get_accept_header_string', $hookdata);
+
+ return $hookdata['data'];
+
+ }
+
}