]> git.mxchange.org Git - friendica.git/commitdiff
Just some more centralised functionality
authorMichael Vogel <icarus@dabo.de>
Thu, 30 Jun 2016 05:46:00 +0000 (07:46 +0200)
committerMichael Vogel <icarus@dabo.de>
Thu, 30 Jun 2016 05:46:00 +0000 (07:46 +0200)
include/diaspora.php
mod/fetch.php
mod/p.php

index 8e206533d013e181aceb417d7341cde3aafff70b..1e8d586c788e53658086e81a15e507b0d1e651e5 100644 (file)
@@ -2532,6 +2532,20 @@ class diaspora {
        }
 
 
+       /**
+        * @brief Build the post xml
+        *
+        * @param string $type The message type
+        * @param array $message The message data
+        *
+        * @return string The post XML
+        */
+       public static function build_post_xml($type, $message) {
+
+               $data = array("XML" => array("post" => array($type => $message)));
+               return xml::from_array($data, $xml);
+       }
+
        /**
         * @brief Builds and transmit messages
         *
@@ -2547,9 +2561,7 @@ class diaspora {
         */
        private function build_and_transmit($owner, $contact, $type, $message, $public_batch = false, $guid = "", $spool = false) {
 
-               $data = array("XML" => array("post" => array($type => $message)));
-
-               $msg = xml::from_array($data, $xml);
+               $msg = build_post_xml($type, $message);
 
                logger('message: '.$msg, LOGGER_DATA);
                logger('send guid '.$guid, LOGGER_DEBUG);
index 5db6250a214143d7c502f62e0df11cef4b5cbfd2..70766e8e5e7c56b01caed6dd3b8ae0747e7dadff 100644 (file)
@@ -35,16 +35,11 @@ function fetch_init($a){
        $user = $r[0];
 
        $status = diaspora::build_status($item[0], $user);
-       $data = array("XML" => array("post" => array($status["type"] => $status["message"])));
-       $xml = xml::from_array($data, $xmlobj);
+       $xml = diaspora::build_post_xml($status["type"], $status["message"]);
 
        // Send the envelope
        header("Content-Type: application/magic-envelope+xml; charset=utf-8");
        echo diaspora::build_magic_envelope($xml, $user);
 
-       //header("Content-Type: application/xml; charset=utf-8");
-       //echo $xml;
-       //killme();
-
        killme();
 }
index ae25a0889eeb3ecc68923860d43ff153b950a09c..80333ef21ee8f622243aac4d93aa0f8605bda4a8 100644 (file)
--- a/mod/p.php
+++ b/mod/p.php
@@ -39,8 +39,7 @@ function p_init($a){
        $user = $r[0];
 
        $status = diaspora::build_status($item[0], $user);
-       $data = array("XML" => array("post" => array($status["type"] => $status["message"])));
-       $xml = xml::from_array($data, $xmlobj);
+       $xml = diaspora::build_post_xml($status["type"], $status["message"]);
 
        header("Content-Type: application/xml; charset=utf-8");
        echo $xml;