X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapistatusesupdate.php;h=f8bf7cf874d0a811b2e600030cd57d4f173b4d19;hb=7ef6c9da437b504f949dc3d7d8c05f8abe36baae;hp=7ddf7703bb70364acc8ffaf204e1c3d0698fd563;hpb=27e6a3f36fb9a41d316bdd4fccd5e98c7a3e9ddc;p=quix0rs-gnu-social.git diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 7ddf7703bb..f8bf7cf874 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -85,7 +85,12 @@ class ApiStatusesUpdateAction extends ApiAuthAction $this->lat = $this->trimmed('lat'); $this->lon = $this->trimmed('long'); - if (empty($this->source) || in_array($source, self::$reserved_sources)) { + // try to set the source attr from OAuth app + if (empty($this->source)) { + $this->source = $this->oauth_source; + } + + if (empty($this->source) || in_array($this->source, self::$reserved_sources)) { $this->source = 'api'; } @@ -203,12 +208,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction } } - $location = null; - - if (!empty($this->lat) && !empty($this->lon)) { - $location = Location::fromLatLon($this->lat, $this->lon); - } - $upload = null; try { @@ -231,19 +230,26 @@ 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, - null, - null, - empty($location) ? null : $location->lat, - empty($location) ? null : $location->lon, - empty($location) ? null : $location->location_id, - empty($location) ? null : $location->location_ns - ); + $content = html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8'); + + $options = array('reply_to' => $reply_to); + + if ($this->user->shareLocation()) { + + $locOptions = Notice::locationOptions($this->lat, + $this->lon, + null, + null, + $this->user->getProfile()); + + $options = array_merge($options, $locOptions); + } + + $this->notice = + Notice::saveNew($this->user->id, + $content, + $this->source, + $options); if (isset($upload)) { $upload->attachToNotice($this->notice);