2019-04-30 22:14:06 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Module\WellKnown;
|
|
|
|
|
|
|
|
use Friendica\BaseModule;
|
2019-12-15 21:34:11 +00:00
|
|
|
use Friendica\DI;
|
2019-04-30 22:14:06 +00:00
|
|
|
use Friendica\Model\Search;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Node subscription preferences for social realy systems
|
|
|
|
* @see https://git.feneas.org/jaywink/social-relay/blob/master/docs/relays.md
|
|
|
|
*/
|
|
|
|
class XSocialRelay extends BaseModule
|
|
|
|
{
|
2019-11-05 21:48:54 +00:00
|
|
|
public static function rawContent(array $parameters = [])
|
2019-04-30 22:14:06 +00:00
|
|
|
{
|
2019-12-15 21:34:11 +00:00
|
|
|
$app = DI::app();
|
2019-12-15 22:44:33 +00:00
|
|
|
$config = DI::config();
|
2019-04-30 22:14:06 +00:00
|
|
|
|
|
|
|
$subscribe = $config->get('system', 'relay_subscribe', false);
|
|
|
|
|
|
|
|
if ($subscribe) {
|
|
|
|
$scope = $config->get('system', 'relay_scope', SR_SCOPE_ALL);
|
|
|
|
} else {
|
|
|
|
$scope = SR_SCOPE_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
$systemTags = [];
|
|
|
|
$userTags = [];
|
|
|
|
|
|
|
|
if ($scope == SR_SCOPE_TAGS) {
|
|
|
|
$server_tags = $config->get('system', 'relay_server_tags');
|
2019-05-01 17:17:52 +00:00
|
|
|
$tagitems = explode(',', $server_tags);
|
2019-04-30 22:14:06 +00:00
|
|
|
|
|
|
|
/// @todo Check if it was better to use "strtolower" on the tags
|
|
|
|
foreach ($tagitems AS $tag) {
|
2019-05-01 17:48:49 +00:00
|
|
|
$systemTags[] = trim($tag, '# ');
|
2019-04-30 22:14:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($config->get('system', 'relay_user_tags')) {
|
|
|
|
$userTags = Search::getUserTags();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$tagList = array_unique(array_merge($systemTags, $userTags));
|
|
|
|
|
|
|
|
$relay = [
|
|
|
|
'subscribe' => $subscribe,
|
|
|
|
'scope' => $scope,
|
|
|
|
'tags' => $tagList,
|
2019-05-01 17:17:52 +00:00
|
|
|
'protocols' => [
|
|
|
|
'diaspora' => [
|
|
|
|
'receive' => $app->getBaseURL() . '/receive/public'
|
|
|
|
],
|
|
|
|
'dfrn' => [
|
|
|
|
'receive' => $app->getBaseURL() . '/dfrn_notify'
|
|
|
|
]
|
|
|
|
]
|
2019-04-30 22:14:06 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
header('Content-type: application/json; charset=utf-8');
|
|
|
|
echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|