]> git.mxchange.org Git - friendica.git/commitdiff
First steps for a public relay for posts.
authorMichael Vogel <icarus@dabo.de>
Sun, 9 Aug 2015 06:31:42 +0000 (08:31 +0200)
committerMichael Vogel <icarus@dabo.de>
Sun, 9 Aug 2015 06:31:42 +0000 (08:31 +0200)
mod/_well_known.php

index 6792d36fe0fcfeaa09e1caf868679c1a37f3540e..5c8a3380fdb7561aeab4f08a49b03a734ed882c9 100644 (file)
@@ -2,13 +2,45 @@
 require_once("mod/hostxrd.php");\r
 \r
 function _well_known_init(&$a){\r
-    if ($a->argc > 1) {\r
-        switch($a->argv[1]) {\r
-            case "host-meta":\r
-                hostxrd_init($a);\r
-                break;\r
-        }\r
-    }\r
-    http_status_exit(404);\r
-    killme();\r
+       if ($a->argc > 1) {\r
+               switch($a->argv[1]) {\r
+                       case "host-meta":\r
+                               hostxrd_init($a);\r
+                               break;\r
+                       case "x-social-relay":\r
+                               wk_social_relay($a);\r
+                               break;\r
+               }\r
+       }\r
+       http_status_exit(404);\r
+       killme();\r
+}\r
+\r
+function wk_social_relay(&$a) {\r
+\r
+       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
+\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
+               }\r
+       }\r
+\r
+       $relay = array("subscribe" => $subscribe,\r
+                       "scope" => $scope,\r
+                       "tags" => array_unique($tags));\r
+\r
+       header('Content-type: application/json; charset=utf-8');\r
+       echo json_encode($relay, true);\r
+       exit;\r
 }\r