]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apistatusesupdate.php
Initial representation for repeated notice
[quix0rs-gnu-social.git] / actions / apistatusesupdate.php
index 5c23acccae7958e01d71395fceafc6d85b5e27dc..dabbea92f5246c747b913a16bd70a8c3308c7a9d 100644 (file)
@@ -61,6 +61,9 @@ class ApiStatusesUpdateAction extends ApiAuthAction
     var $source                = null;
     var $status                = null;
     var $in_reply_to_status_id = null;
+    var $lat                   = null;
+    var $lon                   = null;
+
     static $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api');
 
     /**
@@ -79,8 +82,10 @@ class ApiStatusesUpdateAction extends ApiAuthAction
         $this->user   = $this->auth_user;
         $this->status = $this->trimmed('status');
         $this->source = $this->trimmed('source');
+        $this->lat    = $this->trimmed('lat');
+        $this->lon    = $this->trimmed('long');
 
-        if (empty($this->source) || in_array($source, self::$reserved_sources)) {
+        if (empty($this->source) || in_array($this->source, self::$reserved_sources)) {
             $this->source = 'api';
         }
 
@@ -198,6 +203,12 @@ class ApiStatusesUpdateAction extends ApiAuthAction
                 }
             }
 
+            $location = null;
+
+            if (!empty($this->lat) && !empty($this->lon)) {
+                $location = Location::fromLatLon($this->lat, $this->lon);
+            }
+
             $upload = null;
 
             try {
@@ -220,13 +231,22 @@ class ApiStatusesUpdateAction extends ApiAuthAction
                 }
             }
 
-            $this->notice = Notice::saveNew(
-                $this->user->id,
-                html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8'),
-                $this->source,
-                1,
-                $reply_to
-            );
+            $content = html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8');
+
+            $options = array('reply_to' => $reply_to);
+
+            if (!empty($location)) {
+                $options['lat'] = $location->lat;
+                $options['lon'] = $location->lon;
+                $options['location_id'] = $location->location_id;
+                $options['location_ns'] = $location->location_ns;
+            }
+
+            $this->notice =
+              Notice::saveNew($this->user->id,
+                              $content,
+                              $this->source,
+                              $options);
 
             if (isset($upload)) {
                 $upload->attachToNotice($this->notice);