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