]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Fix: Events on Diaspora now should look fine
[friendica.git] / src / Protocol / Diaspora.php
index 9da41b1b36c3a734029a87696c484ce090e2115c..cc4b230831de489328c8d3ff6bc1b93b97726526 100644 (file)
@@ -29,6 +29,7 @@ use Friendica\Util\Crypto;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\XML;
+use Friendica\Util\Map;
 use dba;
 use SimpleXMLElement;
 
@@ -3618,10 +3619,18 @@ class Diaspora
                        $eventdata['description'] = html_entity_decode(bb2diaspora($event['desc']));
                }
                if ($event['location']) {
+                       $event['location'] = preg_replace("/\[map\](.*?)\[\/map\]/ism", '$1', $event['location']);
+                       $coord = Map::getCoordinates($event['location']);
+
                        $location = [];
                        $location["address"] = html_entity_decode(bb2diaspora($event['location']));
-                       $location["lat"] = 0;
-                       $location["lng"] = 0;
+                       if (!empty($coord['lat']) && !empty($coord['lon'])) {
+                               $location["lat"] = $coord['lat'];
+                               $location["lng"] = $coord['lon'];
+                       } else {
+                               $location["lat"] = 0;
+                               $location["lng"] = 0;
+                       }
                        $eventdata['location'] = $location;
                }
 
@@ -3715,7 +3724,13 @@ class Diaspora
                                if (count($event)) {
                                        $message['event'] = $event;
 
-                                       /// @todo Once Diaspora supports it, we will remove the body
+                                       if (!empty($event['location']['address']) &&
+                                               !empty($event['location']['lat']) &&
+                                               !empty($event['location']['lng'])) {
+                                               $message['location'] = $event['location'];
+                                       }
+
+                                       /// @todo Once Diaspora supports it, we will remove the body and the location hack above
                                        // $message['text'] = '';
                                }
                        }