From a56565fa99838b91198c0ff3a813ec27fe8f4f48 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 22 Sep 2018 23:49:27 +0000 Subject: [PATCH] AP is enabled for all users --- mod/display.php | 2 +- mod/follow.php | 3 +-- mod/profile.php | 2 +- mod/xrd.php | 4 +--- src/Network/Probe.php | 5 +++-- src/Protocol/ActivityPub.php | 13 +++++++------ 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/mod/display.php b/mod/display.php index 1b4508c18d..ff98e689d3 100644 --- a/mod/display.php +++ b/mod/display.php @@ -79,7 +79,7 @@ function display_init(App $a) if (ActivityPub::isRequest()) { $wall_item = Item::selectFirst(['id', 'uid'], ['guid' => $item['guid'], 'wall' => true]); - if ($wall_item['uid'] == 180) { + if (DBA::isResult($wall_item)) { $data = ActivityPub::createObjectFromItemID($wall_item['id']); echo json_encode($data); exit(); diff --git a/mod/follow.php b/mod/follow.php index 65028a70e0..627ab52033 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -31,8 +31,7 @@ function follow_post(App $a) // This is just a precaution if maybe this page is called somewhere directly via POST $_SESSION['fastlane'] = $url; - $result = Contact::createFromProbe($uid, $url, true, Protocol::ACTIVITYPUB); -// $result = Contact::createFromProbe($uid, $url, true); + $result = Contact::createFromProbe($uid, $url, true); if ($result['success'] == false) { if ($result['message']) { diff --git a/mod/profile.php b/mod/profile.php index a284e10f2d..0035ba26ad 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -52,7 +52,7 @@ function profile_init(App $a) if (ActivityPub::isRequest()) { $user = DBA::selectFirst('user', ['uid'], ['nickname' => $which]); - if ($user['uid'] == 180) { + if (DBM::isResult($user)) { $data = ActivityPub::profile($user['uid']); echo json_encode($data); exit(); diff --git a/mod/xrd.php b/mod/xrd.php index 87766ca26e..6a5fdbbdb9 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -80,6 +80,7 @@ function xrd_json($a, $uri, $alias, $profile_url, $r) ['rel' => NAMESPACE_DFRN, 'href' => $profile_url], ['rel' => NAMESPACE_FEED, 'type' => 'application/atom+xml', 'href' => System::baseUrl().'/dfrn_poll/'.$r['nickname']], ['rel' => 'http://webfinger.net/rel/profile-page', 'type' => 'text/html', 'href' => $profile_url], + ['rel' => 'self', 'type' => 'application/activity+json', 'href' => $profile_url], ['rel' => 'http://microformats.org/profile/hcard', 'type' => 'text/html', 'href' => System::baseUrl().'/hcard/'.$r['nickname']], ['rel' => NAMESPACE_POCO, 'href' => System::baseUrl().'/poco/'.$r['nickname']], ['rel' => 'http://webfinger.net/rel/avatar', 'type' => 'image/jpeg', 'href' => System::baseUrl().'/photo/profile/'.$r['uid'].'.jpg'], @@ -92,9 +93,6 @@ function xrd_json($a, $uri, $alias, $profile_url, $r) ['rel' => 'http://purl.org/openwebauth/v1', 'type' => 'application/x-dfrn+json', 'href' => System::baseUrl().'/owa'] ] ]; - if ($r['uid'] == 180) { - $json['links'][] = ['rel' => 'self', 'type' => 'application/activity+json', 'href' => $profile_url]; - } echo json_encode($json); killme(); diff --git a/src/Network/Probe.php b/src/Network/Probe.php index c0c627bfe9..b19f34b762 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -335,8 +335,9 @@ class Probe $data = null; } - if (in_array(defaults($data, 'network', ''), ['', Protocol::PHANTOM])) { - $ap_profile = ActivityPub::probeProfile($uri); + $ap_profile = ActivityPub::probeProfile($uri); + + if (!empty($ap_profile) && (defaults($data, 'network', '') != Protocol::DFRN)) { if (!empty($ap_profile) && ($ap_profile['network'] == Protocol::ACTIVITYPUB)) { $data = $ap_profile; } diff --git a/src/Protocol/ActivityPub.php b/src/Protocol/ActivityPub.php index 6c46da553d..415d714d9a 100644 --- a/src/Protocol/ActivityPub.php +++ b/src/Protocol/ActivityPub.php @@ -332,9 +332,9 @@ class ActivityPub } $data = ['@context' => ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1', - ['ostatus' => 'http://ostatus.org#', 'sensitive' => 'as:sensitive', - 'Hashtag' => 'as:Hashtag', 'atomUri' => 'ostatus:atomUri', - 'conversation' => 'ostatus:conversation', + ['ostatus' => 'http://ostatus.org#', 'uuid' => 'http://schema.org/identifier', + 'sensitive' => 'as:sensitive', 'Hashtag' => 'as:Hashtag', + 'atomUri' => 'ostatus:atomUri', 'conversation' => 'ostatus:conversation', 'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri']]]; $data['id'] = $item['uri'] . '#activity'; @@ -372,9 +372,9 @@ class ActivityPub } $data = ['@context' => ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1', - ['ostatus' => 'http://ostatus.org#', 'sensitive' => 'as:sensitive', - 'Hashtag' => 'as:Hashtag', 'atomUri' => 'ostatus:atomUri', - 'conversation' => 'ostatus:conversation', + ['ostatus' => 'http://ostatus.org#', 'uuid' => 'http://schema.org/identifier', + 'sensitive' => 'as:sensitive', 'Hashtag' => 'as:Hashtag', + 'atomUri' => 'ostatus:atomUri', 'conversation' => 'ostatus:conversation', 'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri']]]; $data = array_merge($data, self::CreateNote($item)); @@ -433,6 +433,7 @@ class ActivityPub $data['inReplyTo'] = null; } + $data['uuid'] = $item['guid']; $data['published'] = DateTimeFormat::utc($item["created"]."+00:00", DateTimeFormat::ATOM); if ($item["created"] != $item["edited"]) {