From 8c2442eca5889a5ece659bdb456403b28285b26b Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 28 Jan 2021 14:57:37 +0000 Subject: AS channel discovery with custom access header --- Zotlabs/Module/Channel.php | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Module/Channel.php') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 11f4d3a52..5cfcb623b 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -4,10 +4,12 @@ namespace Zotlabs\Module; use App; -use Zotlabs\Web\Controller; +use Zotlabs\Lib\Activity; +use Zotlabs\Lib\ActivityStreams; +use Zotlabs\Lib\Libzot; use Zotlabs\Lib\PermissionDescription; +use Zotlabs\Web\Controller; use Zotlabs\Web\HTTPSig; -use Zotlabs\Lib\Libzot; require_once('include/items.php'); require_once('include/security.php'); @@ -25,7 +27,7 @@ class Channel extends Controller { function init() { - if(in_array(substr($_GET['search'],0,1),[ '@', '!', '?'])) + if(in_array(substr($_GET['search'],0,1),[ '@', '!', '?']) || strpos($_GET['search'], 'https://') === 0) goaway('search' . '?f=&search=' . $_GET['search']); $which = null; @@ -87,6 +89,38 @@ class Channel extends Controller { killme(); } + if (ActivityStreams::is_as_request($channel)) { + + // Somebody may attempt an ActivityStreams fetch on one of our message permalinks + // Make it do the right thing. + + $mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : ''); + if ($mid && strpos($mid,'b64.') === 0) { + $decoded = @base64url_decode(substr($mid,4)); + if ($decoded) { + $mid = $decoded; + } + } + if ($mid) { + $obj = null; + if (strpos($mid, z_root() . '/item/') === 0) { + App::$argc = 2; + App::$argv = [ 'item', basename($mid) ]; + $obj = new Item(); + } + if (strpos($mid, z_root() . '/activity/') === 0) { + App::$argc = 2; + App::$argv = [ 'activity', basename($mid) ]; + $obj = new Activity(); + } + if ($obj) { + $obj->init(); + } + } + + as_return_and_die(Activity::encode_person($channel,true),$channel); + } + if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) { $which = $channel['channel_address']; $profile = argv(1); -- cgit v1.2.3