Merge branch 'dev' of ../p3 into dev

This commit is contained in:
nobody 2021-08-24 23:00:45 -07:00
commit 7a575eb506
3 changed files with 83 additions and 1 deletions

View file

@ -14,6 +14,7 @@ use Zotlabs\Lib\LibBlock;
use Zotlabs\Lib\Markdown;
use Zotlabs\Lib\Libzotdir;
use Zotlabs\Lib\Nodeinfo;
use Zotlabs\Lib\System;
use Emoji;
require_once('include/html2bbcode.php');
@ -1705,6 +1706,53 @@ class Activity {
}
static function encode_site() {
$ret = [];
$ret['type'] = 'Service';
$ret['id'] = z_root();
$auto_follow = false;
$sys = get_sys_channel();
$ret['preferredUsername'] = System::get_site_name();
$ret['name'] = System::get_site_name();
$ret['icon'] = [
'type' => 'Image',
'url' => System::get_site_icon(),
];
$ret['url'] = z_root();
$ret['inbox'] = z_root() . '/sysinbox';
// $ret['discoverable'] = ((1 - intval($p['xchan_hidden'])) ? true : false);
$ret['publicKey'] = [
'id' => z_root() . '?operation=getkey',
'owner' => z_root(),
'publicKeyPem' => get_config('system','pubkey')
];
// $ret['manuallyApprovesFollowers'] = (($auto_follow) ? false : true);
$cp = get_cover_photo($sys['channel_id'],'array');
if ($cp) {
$ret['image'] = [
'type' => 'Image',
'mediaType' => $cp['type'],
'url' => $cp['url']
];
}
$ret['summary'] = bbcode(get_config('system','siteinfo',''),['export' => true ]);
return $ret;
}
static function activity_mapper($verb) {
if (strpos($verb,'/') === false) {

View file

@ -3,6 +3,9 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\ActivityStreams;
use Zotlabs\Lib\Activity;
use Zotlabs\Lib\LDSignatures;
use Zotlabs\Web\HTTPSig;
use Zotlabs\Web\Controller;
@ -12,10 +15,36 @@ class Home extends Controller {
function init() {
$ret = [];
call_hooks('home_init',$ret);
if (ActivityStreams::is_as_request()) {
$x = array_merge(['@context' => [
ACTIVITYSTREAMS_JSONLD_REV,
'https://w3id.org/security/v1',
Activity::ap_schema()
]], Activity::encode_site() );
$headers = [];
$headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ;
$x['signature'] = LDSignatures::sign($x,[ 'channel_address' => z_root(), 'channel_prvkey' => get_config('system','prvkey') ]);
$ret = json_encode($x, JSON_UNESCAPED_SLASHES);
logger('data: ' . jindent($ret), LOGGER_DATA);
$headers['Date'] = datetime_convert('UTC','UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T');
$headers['Digest'] = HTTPSig::generate_digest_header($ret);
$headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI'];
$h = HTTPSig::create_sig($headers,get_config('system','prvkey'),z_root());
HTTPSig::set_headers($h);
echo $ret;
killme();
}
if (Libzot::is_zot_request()) {
$key = get_config('system','prvkey');

View file

@ -2389,9 +2389,14 @@ function anon_identity_init($reqvars) {
function channel_url($channel) {
// data validation - if this is wrong, log the call stack so we can find the issue
if (! is_array($channel)) {
btlogger('not a channel array: ' . print_r($channel,true));
}
if ($channel['channel_address'] === z_root()) {
return z_root();
}
return (($channel) ? z_root() . '/channel/' . $channel['channel_address'] : z_root());
}