diff --git a/mod/display.php b/mod/display.php index 907bf8ebba..21e28d5617 100644 --- a/mod/display.php +++ b/mod/display.php @@ -17,6 +17,7 @@ use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\Profile; use Friendica\Protocol\DFRN; +use Friendica\Protocol\ActivityPub; function display_init(App $a) { @@ -43,7 +44,7 @@ function display_init(App $a) $item = null; - $fields = ['id', 'parent', 'author-id', 'body', 'uid']; + $fields = ['id', 'parent', 'author-id', 'body', 'uid', 'guid']; // If there is only one parameter, then check if this parameter could be a guid if ($a->argc == 2) { @@ -76,6 +77,14 @@ function display_init(App $a) displayShowFeed($item["id"], false); } + if (stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/activity+json')) { + $wall_item = Item::selectFirst(['id', 'uid'], ['guid' => $item['guid'], 'wall' => true]); + if ($wall_item['uid'] == 180) { + $data = ActivityPub::createActivityFromItem($wall_item['id']); + echo json_encode($data); + exit(); + } + } if ($item["id"] != $item["parent"]) { $item = Item::selectFirstForUser(local_user(), $fields, ['id' => $item["parent"]]); } diff --git a/mod/profile.php b/mod/profile.php index 2e3ccd28c5..fd23964e41 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -20,6 +20,7 @@ use Friendica\Model\Profile; use Friendica\Module\Login; use Friendica\Protocol\DFRN; use Friendica\Util\DateTimeFormat; +use Friendica\Protocol\ActivityPub; function profile_init(App $a) { @@ -49,6 +50,15 @@ function profile_init(App $a) DFRN::autoRedir($a, $which); } + if (stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/activity+json')) { + $user = DBA::selectFirst('user', ['uid'], ['nickname' => $which]); + if ($user['uid'] == 180) { + $data = ActivityPub::profile($user['uid']); + echo json_encode($data); + exit(); + } + } + Profile::load($a, $which, $profile); $blocked = !local_user() && !remote_user() && Config::get('system', 'block_public'); diff --git a/mod/xrd.php b/mod/xrd.php index 61505f2996..87766ca26e 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -92,6 +92,10 @@ 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(); }