2017-02-10 15:45:22 -05:00
|
|
|
<?php
|
|
|
|
|
2017-04-30 00:07:00 -04:00
|
|
|
use Friendica\App;
|
2017-04-30 00:01:26 -04:00
|
|
|
use Friendica\Core\Config;
|
2018-01-27 11:59:10 -05:00
|
|
|
use Friendica\Core\System;
|
2019-04-22 08:00:17 -04:00
|
|
|
use Friendica\Module\Nodeinfo;
|
2017-02-10 15:45:22 -05:00
|
|
|
|
2018-01-26 23:37:55 -05:00
|
|
|
require_once 'mod/hostxrd.php';
|
|
|
|
require_once 'mod/xrd.php';
|
2017-02-10 15:45:22 -05:00
|
|
|
|
2018-01-04 19:42:48 -05:00
|
|
|
function _well_known_init(App $a)
|
|
|
|
{
|
2017-02-10 15:45:22 -05:00
|
|
|
if ($a->argc > 1) {
|
2018-01-04 19:42:48 -05:00
|
|
|
switch ($a->argv[1]) {
|
2017-02-10 15:45:22 -05:00
|
|
|
case "host-meta":
|
|
|
|
hostxrd_init($a);
|
|
|
|
break;
|
|
|
|
case "x-social-relay":
|
2018-01-04 19:42:48 -05:00
|
|
|
wk_social_relay();
|
2017-02-10 15:45:22 -05:00
|
|
|
break;
|
|
|
|
case "nodeinfo":
|
2019-04-22 08:00:17 -04:00
|
|
|
Nodeinfo::printWellKnown($a);
|
2017-02-10 15:45:22 -05:00
|
|
|
break;
|
2017-08-22 06:18:07 -04:00
|
|
|
case "webfinger":
|
|
|
|
xrd_init($a);
|
|
|
|
break;
|
2017-02-10 15:45:22 -05:00
|
|
|
}
|
|
|
|
}
|
2018-01-27 11:59:10 -05:00
|
|
|
System::httpExit(404);
|
2017-02-10 15:45:22 -05:00
|
|
|
}
|
|
|
|
|
2018-01-04 19:42:48 -05:00
|
|
|
function wk_social_relay()
|
|
|
|
{
|
|
|
|
$subscribe = (bool) Config::get('system', 'relay_subscribe', false);
|
2017-02-10 15:45:22 -05:00
|
|
|
|
|
|
|
if ($subscribe) {
|
|
|
|
$scope = Config::get('system', 'relay_scope', SR_SCOPE_ALL);
|
|
|
|
} else {
|
|
|
|
$scope = SR_SCOPE_NONE;
|
|
|
|
}
|
|
|
|
|
2018-01-15 08:05:12 -05:00
|
|
|
$tags = [];
|
2017-02-10 15:45:22 -05:00
|
|
|
|
|
|
|
if ($scope == SR_SCOPE_TAGS) {
|
|
|
|
$server_tags = Config::get('system', 'relay_server_tags');
|
|
|
|
$tagitems = explode(",", $server_tags);
|
|
|
|
|
2018-04-09 01:53:23 -04:00
|
|
|
/// @todo Check if it was better to use "strtolower" on the tags
|
2018-01-04 19:42:48 -05:00
|
|
|
foreach ($tagitems AS $tag) {
|
2018-04-09 01:53:23 -04:00
|
|
|
$tag = trim($tag, "# ");
|
|
|
|
$tags[$tag] = $tag;
|
2017-02-10 15:45:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Config::get('system', 'relay_user_tags')) {
|
|
|
|
$terms = q("SELECT DISTINCT(`term`) FROM `search`");
|
|
|
|
|
2018-01-04 19:42:48 -05:00
|
|
|
foreach ($terms AS $term) {
|
2017-02-10 15:45:22 -05:00
|
|
|
$tag = trim($term["term"], "#");
|
|
|
|
$tags[$tag] = $tag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-15 08:05:12 -05:00
|
|
|
$taglist = [];
|
2018-01-04 19:42:48 -05:00
|
|
|
foreach ($tags AS $tag) {
|
2018-04-09 01:53:23 -04:00
|
|
|
if (!empty($tag)) {
|
|
|
|
$taglist[] = $tag;
|
|
|
|
}
|
2017-02-10 15:45:22 -05:00
|
|
|
}
|
|
|
|
|
2018-01-15 08:05:12 -05:00
|
|
|
$relay = [
|
2018-04-30 00:01:04 -04:00
|
|
|
'subscribe' => $subscribe,
|
|
|
|
'scope' => $scope,
|
|
|
|
'tags' => $taglist,
|
2018-05-10 07:04:18 -04:00
|
|
|
'protocols' => ['diaspora' => ['receive' => System::baseUrl() . '/receive/public'],
|
|
|
|
'dfrn' => ['receive' => System::baseUrl() . '/dfrn_notify']]
|
2018-01-15 08:05:12 -05:00
|
|
|
];
|
2017-02-10 15:45:22 -05:00
|
|
|
|
|
|
|
header('Content-type: application/json; charset=utf-8');
|
2018-01-04 19:42:48 -05:00
|
|
|
echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
2017-02-10 15:45:22 -05:00
|
|
|
exit;
|
|
|
|
}
|