2019-04-30 22:14:06 +00:00
|
|
|
<?php
|
2020-02-09 14:45:36 +00:00
|
|
|
/**
|
2022-01-02 07:27:47 +00:00
|
|
|
* @copyright Copyright (C) 2010-2022, the Friendica project
|
2020-02-09 14:45:36 +00:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2019-04-30 22:14:06 +00:00
|
|
|
|
|
|
|
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;
|
2021-11-04 20:29:59 +00:00
|
|
|
use Friendica\Protocol\Relay;
|
2019-04-30 22:14:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Node subscription preferences for social realy systems
|
|
|
|
* @see https://git.feneas.org/jaywink/social-relay/blob/master/docs/relays.md
|
|
|
|
*/
|
|
|
|
class XSocialRelay extends BaseModule
|
|
|
|
{
|
2021-11-20 14:38:03 +00:00
|
|
|
protected function rawContent(array $request = [])
|
2019-04-30 22:14:06 +00:00
|
|
|
{
|
2019-12-15 22:44:33 +00:00
|
|
|
$config = DI::config();
|
2019-04-30 22:14:06 +00:00
|
|
|
|
2021-06-13 11:15:04 +00:00
|
|
|
$scope = $config->get('system', 'relay_scope');
|
2019-04-30 22:14:06 +00:00
|
|
|
|
|
|
|
$systemTags = [];
|
|
|
|
$userTags = [];
|
|
|
|
|
2021-11-04 20:29:59 +00:00
|
|
|
if ($scope == Relay::SCOPE_TAGS) {
|
2019-04-30 22:14:06 +00:00
|
|
|
$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
|
2021-10-03 10:34:41 +00:00
|
|
|
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 = [
|
2021-11-04 20:29:59 +00:00
|
|
|
'subscribe' => ($scope != Relay::SCOPE_NONE),
|
2019-04-30 22:14:06 +00:00
|
|
|
'scope' => $scope,
|
|
|
|
'tags' => $tagList,
|
2019-05-01 17:17:52 +00:00
|
|
|
'protocols' => [
|
2020-11-15 23:28:05 +00:00
|
|
|
'activitypub' => [
|
|
|
|
'actor' => DI::baseUrl()->get() . '/friendica',
|
|
|
|
'receive' => DI::baseUrl()->get() . '/inbox'
|
2019-05-01 17:17:52 +00:00
|
|
|
],
|
|
|
|
'dfrn' => [
|
2019-12-16 00:05:15 +00:00
|
|
|
'receive' => DI::baseUrl()->get() . '/dfrn_notify'
|
2019-05-01 17:17:52 +00:00
|
|
|
]
|
|
|
|
]
|
2019-04-30 22:14:06 +00:00
|
|
|
];
|
|
|
|
|
2020-11-15 23:28:05 +00:00
|
|
|
if (DI::config()->get("system", "diaspora_enabled")) {
|
|
|
|
$relay['protocols']['diaspora'] = ['receive' => DI::baseUrl()->get() . '/receive/public'];
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|