friendica/src/Module/WellKnown/XSocialRelay.php

83 lines
2.3 KiB
PHP
Raw Normal View History

<?php
2020-02-09 15:45:36 +01:00
/**
2022-01-02 08:27:47 +01:00
* @copyright Copyright (C) 2010-2022, the Friendica project
2020-02-09 15:45:36 +01: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/>.
*
*/
namespace Friendica\Module\WellKnown;
use Friendica\BaseModule;
2022-04-09 13:58:01 +02:00
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Search;
use Friendica\Protocol\Relay;
/**
* Node subscription preferences for social realy systems
* @see https://git.feneas.org/jaywink/social-relay/blob/master/docs/relays.md
*/
class XSocialRelay extends BaseModule
{
protected function rawContent(array $request = [])
{
$config = DI::config();
$scope = $config->get('system', 'relay_scope');
$systemTags = [];
$userTags = [];
if ($scope == Relay::SCOPE_TAGS) {
$server_tags = $config->get('system', 'relay_server_tags');
$tagitems = explode(',', $server_tags);
/// @todo Check if it was better to use "strtolower" on the tags
2021-10-03 12:34:41 +02:00
foreach ($tagitems as $tag) {
2019-05-01 19:48:49 +02:00
$systemTags[] = trim($tag, '# ');
}
if ($config->get('system', 'relay_user_tags')) {
$userTags = Search::getUserTags();
}
}
$tagList = array_unique(array_merge($systemTags, $userTags));
$relay = [
'subscribe' => ($scope != Relay::SCOPE_NONE),
'scope' => $scope,
'tags' => $tagList,
'protocols' => [
'activitypub' => [
'actor' => DI::baseUrl()->get() . '/friendica',
'receive' => DI::baseUrl()->get() . '/inbox'
],
'dfrn' => [
'receive' => DI::baseUrl()->get() . '/dfrn_notify'
]
]
];
if (DI::config()->get("system", "diaspora_enabled")) {
$relay['protocols']['diaspora'] = ['receive' => DI::baseUrl()->get() . '/receive/public'];
}
2022-04-09 13:58:01 +02:00
System::jsonExit($relay);
}
}