]> git.mxchange.org Git - friendica.git/blobdiff - mod/_well_known.php
Merge pull request #1810 from annando/issue-1739
[friendica.git] / mod / _well_known.php
index 5c8a3380fdb7561aeab4f08a49b03a734ed882c9..33070a1ecdf4dc071d65aabd94b67f530be47efe 100644 (file)
@@ -1,5 +1,6 @@
 <?php\r
 require_once("mod/hostxrd.php");\r
+require_once("mod/nodeinfo.php");\r
 \r
 function _well_known_init(&$a){\r
        if ($a->argc > 1) {\r
@@ -10,6 +11,9 @@ function _well_known_init(&$a){
                        case "x-social-relay":\r
                                wk_social_relay($a);\r
                                break;\r
+                       case "nodeinfo":\r
+                               nodeinfo_wellknown($a);\r
+                               break;\r
                }\r
        }\r
        http_status_exit(404);\r
@@ -21,26 +25,42 @@ function wk_social_relay(&$a) {
        define('SR_SCOPE_ALL', 'all');\r
        define('SR_SCOPE_TAGS', 'tags');\r
 \r
-       $subscribe = (bool)true;\r
-       $scope = SR_SCOPE_ALL;\r
-       //$scope = SR_SCOPE_TAGS;\r
+       $subscribe = (bool)get_config('system', 'relay_subscribe');\r
+\r
+       if ($subscribe)\r
+               $scope = get_config('system', 'relay_scope');\r
+       else\r
+               $scope = "";\r
 \r
        $tags = array();\r
 \r
        if ($scope == SR_SCOPE_TAGS) {\r
-               $terms = q("SELECT DISTINCT(`term`) FROM `search`");\r
 \r
-               foreach($terms AS $term) {\r
-                       $tag = trim($term["term"], "#");\r
-                       $tags[] = $tag;\r
+               $server_tags = get_config('system', 'relay_server_tags');\r
+               $tagitems = explode(",", $server_tags);\r
+\r
+               foreach($tagitems AS $tag)\r
+                       $tags[trim($tag, "# ")] = trim($tag, "# ");\r
+\r
+               if (get_config('system', 'relay_user_tags')) {\r
+                       $terms = q("SELECT DISTINCT(`term`) FROM `search`");\r
+\r
+                       foreach($terms AS $term) {\r
+                               $tag = trim($term["term"], "#");\r
+                               $tags[$tag] = $tag;\r
+                       }\r
                }\r
        }\r
 \r
+       $taglist = array();\r
+       foreach($tags AS $tag)\r
+               $taglist[] = $tag;\r
+\r
        $relay = array("subscribe" => $subscribe,\r
                        "scope" => $scope,\r
-                       "tags" => array_unique($tags));\r
+                       "tags" => $taglist);\r
 \r
        header('Content-type: application/json; charset=utf-8');\r
-       echo json_encode($relay, true);\r
+       echo json_encode($relay, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);\r
        exit;\r
 }\r