We now transmit event data as well

This commit is contained in:
Michael 2016-12-29 03:13:57 +00:00
parent ca0e6cba02
commit 483f34c4ce

View file

@ -2939,6 +2939,52 @@ class Diaspora {
return($ret); 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) * @brief Create a post (status message or reshare)
* *
@ -3012,6 +3058,13 @@ class Diaspora {
unset($message["location"]); unset($message["location"]);
} }
if ($item['event-id'] > 0) {
$event = self::build_event($item['event-id']);
if (count($event)) {
$message['event'] = $event;
}
}
$type = "status_message"; $type = "status_message";
} }
return array("type" => $type, "message" => $message); return array("type" => $type, "message" => $message);