diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2018-09-28 13:41:24 +0200 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2018-09-28 13:41:24 +0200 |
commit | 3e399899ed7d5d9a30e7ec60f7d5406b81299b7e (patch) | |
tree | a27d7748f1ee3f8df296ceb075f256ed15db4d6a /lib/webfinger.php | |
parent | edee5f2746c507797b6f168e222be03b14afed7d (diff) |
mark before cleaning
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/webfinger.php')
-rw-r--r-- | lib/webfinger.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/webfinger.php b/lib/webfinger.php new file mode 100644 index 00000000..8973ee19 --- /dev/null +++ b/lib/webfinger.php @@ -0,0 +1,66 @@ +<?php +declare(strict_types=1); + +/** + * Nextcloud - Social Support + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Maxence Lange <maxence@artificial-owl.com> + * @copyright 2018, Maxence Lange <maxence@artificial-owl.com> + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Social; + +require_once __DIR__ . '/../appinfo/autoload.php'; +require_once(__DIR__ . '/../lib/autoload.php'); + +if (!array_key_exists('resource', $_GET)) { + echo 'missing resource'; + exit(); +} + +$subject = $_GET['resource']; + +$urlGenerator = \OC::$server->getURLGenerator(); + +list($type, $account) = explode(':', $subject, 2); +if ($type !== 'acct') { + echo 'no acct'; + exit(); +} + + +$username = substr($account, 0, strrpos($account, '@')); +$finger = [ + 'subject' => $subject, + 'links' => [ + [ + 'rel' => 'self', + 'type' => 'application/activity+json', + // 'href' => 'https://test.artificial-owl.com/apps/social/@' . $username + 'href' => $urlGenerator->linkToRouteAbsolute( + 'social.ActivityPub.aliasactor', ['username' => $username] + ) + ] + ] +]; + +header('Content-type: application/json'); +echo json_encode($finger); |