]> git.mxchange.org Git - friendica.git/blob - src/Module/WellKnown/XSocialRelay.php
Group selection: Respect "pubmail" and ignore atchived or blocked contacts
[friendica.git] / src / Module / WellKnown / XSocialRelay.php
1 <?php
2
3 namespace Friendica\Module\WellKnown;
4
5 use Friendica\BaseModule;
6 use Friendica\Model\Search;
7
8 /**
9  * Node subscription preferences for social realy systems
10  * @see https://git.feneas.org/jaywink/social-relay/blob/master/docs/relays.md
11  */
12 class XSocialRelay extends BaseModule
13 {
14         public static function rawContent(array $parameters = [])
15         {
16                 $app = self::getApp();
17                 $config = $app->getConfig();
18
19                 $subscribe = $config->get('system', 'relay_subscribe', false);
20
21                 if ($subscribe) {
22                         $scope = $config->get('system', 'relay_scope', SR_SCOPE_ALL);
23                 } else {
24                         $scope = SR_SCOPE_NONE;
25                 }
26
27                 $systemTags = [];
28                 $userTags = [];
29
30                 if ($scope == SR_SCOPE_TAGS) {
31                         $server_tags = $config->get('system', 'relay_server_tags');
32                         $tagitems = explode(',', $server_tags);
33
34                         /// @todo Check if it was better to use "strtolower" on the tags
35                         foreach ($tagitems AS $tag) {
36                                 $systemTags[] = trim($tag, '# ');
37                         }
38
39                         if ($config->get('system', 'relay_user_tags')) {
40                                 $userTags = Search::getUserTags();
41                         }
42                 }
43
44                 $tagList = array_unique(array_merge($systemTags, $userTags));
45
46                 $relay = [
47                         'subscribe' => $subscribe,
48                         'scope'     => $scope,
49                         'tags'      => $tagList,
50                         'protocols' => [
51                                 'diaspora' => [
52                                         'receive' => $app->getBaseURL() . '/receive/public'
53                                 ],
54                                 'dfrn'     => [
55                                         'receive' => $app->getBaseURL() . '/dfrn_notify'
56                                 ]
57                         ]
58                 ];
59
60                 header('Content-type: application/json; charset=utf-8');
61                 echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
62                 exit;
63         }
64 }