]> git.mxchange.org Git - friendica.git/commitdiff
We now transmit event data as well
authorMichael <heluecht@pirati.ca>
Thu, 29 Dec 2016 03:13:57 +0000 (03:13 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 29 Dec 2016 03:13:57 +0000 (03:13 +0000)
include/diaspora.php

index 2bbd1f4ab03d2df173945e1cb9db4626bafe9c0a..d3038e62ced712a8ceccbaacb3343c18693662e8 100644 (file)
@@ -1914,18 +1914,18 @@ class Diaspora {
         *
         * @return string The XML
         */
-        private function construct_new_friend_object($contact) {
-                $objtype = ACTIVITY_OBJ_PERSON;
-                $link = '<link rel="alternate" type="text/html" href="'.$contact["url"].'" />'."\n".
-                        '<link rel="photo" type="image/jpeg" href="'.$contact["thumb"].'" />'."\n";
+       private function construct_new_friend_object($contact) {
+               $objtype = ACTIVITY_OBJ_PERSON;
+               $link = '<link rel="alternate" type="text/html" href="'.$contact["url"].'" />'."\n".
+                       '<link rel="photo" type="image/jpeg" href="'.$contact["thumb"].'" />'."\n";
 
-                $xmldata = array("object" => array("type" => $objtype,
-                                                "title" => $contact["name"],
-                                                "id" => $contact["url"]."/".$contact["name"],
-                                                "link" => $link));
+               $xmldata = array("object" => array("type" => $objtype,
+                                               "title" => $contact["name"],
+                                               "id" => $contact["url"]."/".$contact["name"],
+                                               "link" => $link));
 
-                return xml::from_array($xmldata, $xml, true);
-        }
+               return xml::from_array($xmldata, $xml, true);
+       }
 
        /**
         * @brief Processes incoming sharing notification
@@ -2939,6 +2939,52 @@ class Diaspora {
                return($ret);
        }
 
+       /**
+        * @brief Create an event array
+        *
+        * @param integer $event_id The id of the event
+        *
+        * @return array with event data
+        */
+       private static function build_event($event_id) {
+               $r = q("SELECT `start`, `finish`, `summary`, `desc`, `location`, `adjust` FROM `event` WHERE `id` = %d", intval($event_id));
+               if (!dbm::is_result($r)) {
+                       return array();
+               }
+
+               $eventdata = array();
+
+               /// @todo Timezone in start und end?
+
+               if ($r[0]['adjust']) {
+                       $eventdata['timezone'] = 'UTC';
+               } else {
+                       $eventdata['timezone'] = date_default_timezone_get();
+               }
+
+               if ($r[0]['start']) {
+                       $eventdata['start'] = datetime_convert("UTC", "UTC", $r[0]['start'], 'Y-m-d\TH:i:s\Z');
+               }
+               if ($r[0]['finish']) {
+                       $eventdata['end'] = datetime_convert("UTC", "UTC", $r[0]['finish'], 'Y-m-d\TH:i:s\Z');
+               }
+               if ($r[0]['summary']) {
+                       $eventdata['summary'] = html_entity_decode(bb2diaspora($r[0]['summary']));
+               }
+               if ($r[0]['desc']) {
+                       $eventdata['description'] = html_entity_decode(bb2diaspora($r[0]['desc']));
+               }
+               if ($r[0]['location']) {
+                       $location = array();
+                       $location["address"] = html_entity_decode(bb2diaspora($r[0]['location']));
+                       $location["lat"] = 0;
+                       $location["lng"] = 0;
+                       $eventdata['location'] = $location;
+               }
+
+               return $eventdata;
+       }
+
        /**
         * @brief Create a post (status message or reshare)
         *
@@ -3012,6 +3058,13 @@ class Diaspora {
                                unset($message["location"]);
                        }
 
+                       if ($item['event-id'] > 0) {
+                               $event = self::build_event($item['event-id']);
+                               if (count($event)) {
+                                       $message['event'] = $event;
+                               }
+                       }
+
                        $type = "status_message";
                }
                return array("type" => $type, "message" => $message);