2019-05-01 00:14:06 +02:00
|
|
|
<?php
|
2024-08-24 15:27:00 +02:00
|
|
|
|
|
|
|
// Copyright (C) 2010-2024, the Friendica project
|
|
|
|
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
2019-05-01 00:14:06 +02:00
|
|
|
|
|
|
|
namespace Friendica\Module\WellKnown;
|
|
|
|
|
|
|
|
use Friendica\BaseModule;
|
2019-12-15 22:34:11 +01:00
|
|
|
use Friendica\DI;
|
2019-05-01 00:14:06 +02:00
|
|
|
use Friendica\Model\Search;
|
2021-11-04 20:29:59 +00:00
|
|
|
use Friendica\Protocol\Relay;
|
2024-01-28 06:32:55 +00:00
|
|
|
use Friendica\Util\Strings;
|
2019-05-01 00:14:06 +02:00
|
|
|
|
|
|
|
/**
|
2023-03-26 18:41:31 -04:00
|
|
|
* Node subscription preferences for social relay systems
|
2019-05-01 00:14:06 +02:00
|
|
|
* @see https://git.feneas.org/jaywink/social-relay/blob/master/docs/relays.md
|
|
|
|
*/
|
|
|
|
class XSocialRelay extends BaseModule
|
|
|
|
{
|
2021-11-20 15:38:03 +01:00
|
|
|
protected function rawContent(array $request = [])
|
2019-05-01 00:14:06 +02:00
|
|
|
{
|
2019-12-15 23:44:33 +01:00
|
|
|
$config = DI::config();
|
2019-05-01 00:14:06 +02:00
|
|
|
|
2021-06-13 11:15:04 +00:00
|
|
|
$scope = $config->get('system', 'relay_scope');
|
2019-05-01 00:14:06 +02:00
|
|
|
|
|
|
|
$systemTags = [];
|
|
|
|
$userTags = [];
|
|
|
|
|
2021-11-04 20:29:59 +00:00
|
|
|
if ($scope == Relay::SCOPE_TAGS) {
|
2024-01-28 06:32:55 +00:00
|
|
|
$systemTags = Strings::getTagArrayByString($config->get('system', 'relay_server_tags'));
|
2019-05-01 00:14:06 +02: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-05-01 00:14:06 +02:00
|
|
|
'scope' => $scope,
|
|
|
|
'tags' => $tagList,
|
2019-05-01 19:17:52 +02:00
|
|
|
'protocols' => [
|
2020-11-15 23:28:05 +00:00
|
|
|
'activitypub' => [
|
2023-02-18 20:57:30 +01:00
|
|
|
'actor' => DI::baseUrl() . '/friendica',
|
|
|
|
'receive' => DI::baseUrl() . '/inbox'
|
2019-05-01 19:17:52 +02:00
|
|
|
],
|
|
|
|
'dfrn' => [
|
2023-02-18 20:57:30 +01:00
|
|
|
'receive' => DI::baseUrl() . '/dfrn_notify'
|
2019-05-01 19:17:52 +02:00
|
|
|
]
|
|
|
|
]
|
2019-05-01 00:14:06 +02:00
|
|
|
];
|
|
|
|
|
2020-11-15 23:28:05 +00:00
|
|
|
if (DI::config()->get("system", "diaspora_enabled")) {
|
2023-02-18 20:57:30 +01:00
|
|
|
$relay['protocols']['diaspora'] = ['receive' => DI::baseUrl() . '/receive/public'];
|
2020-11-15 23:28:05 +00:00
|
|
|
}
|
|
|
|
|
2023-09-21 12:16:17 -04:00
|
|
|
$this->jsonExit($relay);
|
2019-05-01 00:14:06 +02:00
|
|
|
}
|
|
|
|
}
|