. * * @category Plugin * @package GNUsocial * @author Daniel Supernault * @copyright 2015 Free Software Foundaction, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link https://gnu.io/social */ if (!defined('GNUSOCIAL')) { exit(1); } class ActivityPubActorAction extends ManagedAction { protected $needLogin = false; protected $canPost = true; protected function handle() { $user = User::getByID($this->trimmed('id')); $profile = $user->getProfile(); $url = $profile->profileurl; try { $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE)->displayUrl(); } catch (NoAvatarException $e) { // TODO: fallback to current theme default avatar $avatar = null; } $res = [ '@context' => [ "https://www.w3.org/ns/activitystreams", [ "@language" => "en" ] ], 'id' => $url, 'type' => 'Person', 'following' => "{$url}/subscriptions", 'followers' => "{$url}/subscribers", 'inbox' => null, 'outbox' => null, 'liked' => "{$url}/favorites", 'preferredUsername' => $user->nickname, 'name' => $user->nickname, 'summary' => $profile->bio, 'url' => $url, 'icon' => [ 'type' => 'Image', 'width' => 96, 'height' => 96, 'url' => $avatar ] ]; header('Content-Type: application/json'); echo json_encode($res, JSON_PRETTY_PRINT); } }