aboutsummaryrefslogtreecommitdiff
path: root/lib/activitypub-webfinger.php
blob: 15177cb7d552bb2643a58ca5d6d5cdbbdebfd684 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

	if(!$config['activitypub']) exit();

	// todo: handle empty usernames

	$actor = ltrim($config['microblog_account'], '@');
	$url = parse_url($config['url']);
	$domain = $url['host'];
	if(!empty($url['path'])) $domain .= rtrim($url['path'], '/');

	$data = [
		'subject' => 'acct:'.$actor.'@'.$domain,
		'links' => [
			[
				'rel' => 'self',
				'type' => 'application/activity+json',
				'href' => $config['url'].'/actor'
			]
		]
	];

	header('Content-Type: application/jrd+json');
	echo(json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));