From d8c93c0d13133d336e2cc3dbf3c48e0a6350c2d6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 17 Jul 2017 22:17:40 -0700 Subject: activitypub, cont. --- Zotlabs/Lib/ActivityStreams2.php | 2 +- Zotlabs/Module/Ap_probe.php | 33 +++++++++++++++++++++++++++++++++ include/feedutils.php | 40 ++++++++++++++++++++++++++-------------- 3 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 Zotlabs/Module/Ap_probe.php diff --git a/Zotlabs/Lib/ActivityStreams2.php b/Zotlabs/Lib/ActivityStreams2.php index 46852886b..904782bf7 100644 --- a/Zotlabs/Lib/ActivityStreams2.php +++ b/Zotlabs/Lib/ActivityStreams2.php @@ -43,7 +43,7 @@ class ActivityStreams2 { function fetch_property($url) { $redirects = 0; $x = z_fetch_url($url,true,$redirects, - ['headers' => [ 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); + ['headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); if($x['success']) return json_decode($x['body'],true); return null; diff --git a/Zotlabs/Module/Ap_probe.php b/Zotlabs/Module/Ap_probe.php new file mode 100644 index 000000000..4649914d5 --- /dev/null +++ b/Zotlabs/Module/Ap_probe.php @@ -0,0 +1,33 @@ +ActivityPub Probe Diagnostic'; + + $o .= '
'; + $o .= 'Lookup URI: '; + $o .= '
'; + + $o .= '

'; + + if(x($_GET,'addr')) { + $addr = $_GET['addr']; + + $redirects = 0; + $x = z_fetch_url($addr,true,$redirects, + [ 'headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); +logger('fetch: ' . print_r($x,true)); + + if($x['success']) + $o .= '
' . str_replace('\\','',jindent($x['body'])) . '
'; + } + return $o; + } + +} diff --git a/include/feedutils.php b/include/feedutils.php index 5f2a06029..b31448d81 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -1937,22 +1937,34 @@ function asencode_note($i) { function asencode_person($p) { - $ret = array(); - $ret['type'] = 'Person'; - $ret['id'] = $p['xchan_url']; - $ret['name'] = $p['xchan_name']; - $ret['image'] = array( - 'type' => 'Link', + $ret = []; + $ret['type'] = 'Person'; + $ret['id'] = $p['xchan_url']; + $ret['name'] = $p['xchan_name']; + $ret['icon'] = [ $p['xchan_photo_l'] ]; + $ret['image'] = [ + 'type' => 'Link', 'mediaType' => $p['xchan_photo_mimetype'], - 'href' => $p['xchan_photo_l'], - 'height' => 300, - 'width' => 300 - ); - $ret['url'] = array( - 'type' => 'Link', + 'href' => $p['xchan_photo_l'], + 'height' => 300, + 'width' => 300 + ]; + $ret['url'] = [ + 'type' => 'Link', 'mediaType' => 'text/html', - 'href' => $p['xchan_url'] - ); + 'href' => $p['xchan_url'] + ]; + + if(array_key_exists('channel_id',$p)) { + $ret['inbox'] = z_root() . '/inbox/' . $p['channel_address']; + $ret['outbox'] = z_root() . '/outbox/' . $p['channel_address']; + } + else { + $collections = get_xconfig($p['xchan_hash'],'activitystreams','collections',[]); + if($collections) { + $ret = array_merge($ret,$collections); + } + } return $ret; } -- cgit v1.2.3