From 532def024443ee3679072f5e91c03950bc3717f8 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 15 Aug 2019 23:53:02 -0700 Subject: [PATCH] bearcaps and other stuff --- Zotlabs/Lib/Activity.php | 19 +++++++++++++++++++ Zotlabs/Lib/Libprofile.php | 16 ++++++++++++---- boot.php | 3 +++ include/network.php | 1 + 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index af8a4a9db..48e7aa4ba 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -54,12 +54,31 @@ class Activity { } else { $m = parse_url($url); + + // handle bearcaps + if ($m['scheme'] === 'bear' && $m['query']) { + $params = explode('&',$m['query']); + if ($params) { + foreach ($params as $p) { + if (substr($p,0,2) === 'u=') { + $url = substr($p,2); + } + if (substr($p,0,2) === 't=') { + $token = substr($p,2); + } + } + } + } + $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' ]; + 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 ] ); } diff --git a/Zotlabs/Lib/Libprofile.php b/Zotlabs/Lib/Libprofile.php index dcae3b228..73ea5cabc 100644 --- a/Zotlabs/Lib/Libprofile.php +++ b/Zotlabs/Lib/Libprofile.php @@ -61,11 +61,19 @@ class Libprofile { if ($profile) { $p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile - LEFT JOIN channel ON profile.uid = channel.channel_id - WHERE channel.channel_address = '%s' AND profile.profile_guid = '%s' LIMIT 1", - dbesc($nickname), - dbesc($profile) + LEFT JOIN channel ON profile.uid = channel.channel_id + WHERE channel.channel_address = '%s' AND profile.profile_guid = '%s' LIMIT 1", + dbesc($nickname), + dbesc($profile) ); + if (! $p) { + $p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile + LEFT JOIN channel ON profile.uid = channel.channel_id + WHERE channel.channel_address = '%s' AND profile.id = %d LIMIT 1", + dbesc($nickname), + intval($profile) + ); + } } if (! $p) { diff --git a/boot.php b/boot.php index b774e2ef4..998762909 100755 --- a/boot.php +++ b/boot.php @@ -22,6 +22,9 @@ require_once('vendor/autoload.php'); if (file_exists('addon/vendor/autoload.php')) { require_once('addon/vendor/autoload.php'); } +if (file_exists('addon/version.php')) { + require_once('addon/version.php'); +} require_once('include/config.php'); require_once('include/network.php'); diff --git a/include/network.php b/include/network.php index cc99ff4ca..b6fc32f7d 100644 --- a/include/network.php +++ b/include/network.php @@ -1684,6 +1684,7 @@ function get_site_info() { 'site_name' => (($site_name) ? $site_name : ''), 'version' => $version, 'version_tag' => $tag, + 'addon_version' => defined('ADDON_VERSION') ? ADDON_VERSION : 'unknown', 'server_role' => System::get_server_role(), 'commit' => $commit, 'plugins' => $visible_plugins,