aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Activity.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2019-02-18 18:16:50 -0800
committerzotlabs <mike@macgirvin.com>2019-02-18 18:16:50 -0800
commit175f78fa844ca196a02a441c9270c5b1e34c6c27 (patch)
tree621e3bf477d1d358b8a21a5e5a6f692f593b4f48 /Zotlabs/Lib/Activity.php
parentb5109d2a1ae6056ec845c66ad89ccb02b4de0a05 (diff)
downloadvolse-hubzilla-175f78fa844ca196a02a441c9270c5b1e34c6c27.tar.gz
volse-hubzilla-175f78fa844ca196a02a441c9270c5b1e34c6c27.tar.bz2
volse-hubzilla-175f78fa844ca196a02a441c9270c5b1e34c6c27.zip
support zot location independent urls
Diffstat (limited to 'Zotlabs/Lib/Activity.php')
-rw-r--r--Zotlabs/Lib/Activity.php45
1 files changed, 41 insertions, 4 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index bcbe53df7..9aaf6d866 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -2,10 +2,7 @@
namespace Zotlabs\Lib;
-use Zotlabs\Lib\Libzot;
-use Zotlabs\Lib\Libsync;
-use Zotlabs\Lib\ActivityStreams;
-use Zotlabs\Lib\Group;
+use Zotlabs\Zot6\HTTPSig;
class Activity {
@@ -43,6 +40,46 @@ class Activity {
}
+ static function fetch($url,$channel = null) {
+ $redirects = 0;
+ if(! check_siteallowed($url)) {
+ logger('blacklisted: ' . $url);
+ return null;
+ }
+ if(! $channel) {
+ $channel = get_sys_channel();
+ }
+
+ logger('fetch: ' . $url, LOGGER_DEBUG);
+
+ if(strpos($url,'x-zot:') === 0) {
+ $x = ZotURL::fetch($url,$channel);
+ }
+ else {
+ $m = parse_url($url);
+ $headers = [
+ 'Accept' => 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
+ 'Host' => $m['host'],
+ '(request-target)' => 'get ' . get_request_string($url),
+ 'Date' => datetime_convert('UTC','UTC','now','D, d M Y H:i:s') . ' UTC'
+ ];
+ $h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel),false);
+ $x = z_fetch_url($url, true, $redirects, [ 'headers' => $h ] );
+ }
+
+ if($x['success']) {
+ $y = json_decode($x['body'],true);
+ logger('returned: ' . json_encode($y,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));
+ return json_decode($x['body'], true);
+ }
+ else {
+ logger('fetch failed: ' . $url);
+ }
+ return null;
+ }
+
+
+
static function fetch_person($x) {
return self::fetch_profile($x);