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