]> git.mxchange.org Git - friendica.git/commitdiff
Directly serve atom+xml if requested
authorMichael <heluecht@pirati.ca>
Tue, 19 Sep 2017 11:53:19 +0000 (11:53 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 19 Sep 2017 11:53:19 +0000 (11:53 +0000)
include/ostatus.php
mod/display.php

index 9472c56e03b175973552ba838adaaa87a7032b8f..19392b91731a8f8024c9b86aa950c086ce33430d 100644 (file)
@@ -674,7 +674,7 @@ class ostatus {
 
                self::$conv_list[$conversation] = true;
 
-               $conversation_data = z_fetch_url($conversation);
+               $conversation_data = z_fetch_url($conversation, false, $redirects, array('accept_content' => 'application/atom+xml'));
 
                if (!$conversation_data['success']) {
                        return;
@@ -855,7 +855,7 @@ class ostatus {
                }
 
                $stored = false;
-               $related_data = z_fetch_url($related);
+               $related_data = z_fetch_url($related, false, $redirects, array('accept_content' => 'application/atom+xml'));
 
                if (!$related_data['success']) {
                        return;
index d8cdf658a680e9e348779e9342c291b50016bf5b..37d3a123a88d5ba3f0f172bc238475e217515ac1 100644 (file)
@@ -17,13 +17,7 @@ function display_init(App $a) {
        if ($a->argc == 3) {
                if (substr($a->argv[2], -5) == '.atom') {
                        $item_id = substr($a->argv[2], 0, -5);
-                       $xml = dfrn::itemFeed($item_id);
-                       if ($xml == '') {
-                               http_status_exit(500);
-                       }
-                       header("Content-type: application/atom+xml");
-                       echo $xml;
-                       killme();
+                       displayShowFeed($item_id);
                }
        }
 
@@ -70,6 +64,12 @@ function display_init(App $a) {
                                        AND `item`.`guid` = ? LIMIT 1", $a->argv[1]);
                }
                if (dbm::is_result($r)) {
+
+                       if (strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
+                               logger('Directly serving XML for id '.$r["id"], LOGGER_DEBUG);
+                               displayShowFeed($r["id"]);
+                       }
+
                        if ($r["id"] != $r["parent"]) {
                                $r = dba::fetch_first("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
                                        WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
@@ -499,3 +499,12 @@ function display_content(App $a, $update = 0) {
        return $o;
 }
 
+function displayShowFeed($item_id) {
+       $xml = dfrn::itemFeed($item_id);
+       if ($xml == '') {
+               http_status_exit(500);
+       }
+       header("Content-type: application/atom+xml");
+       echo $xml;
+       killme();
+}