X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapistatusesupdate.php;h=f8bf7cf874d0a811b2e600030cd57d4f173b4d19;hb=7ef6c9da437b504f949dc3d7d8c05f8abe36baae;hp=898a4bd723cef157ad3e768096ac5c1134db62ce;hpb=5f5413624d166a9b2116d266c7698dd6dcd2d8c4;p=quix0rs-gnu-social.git diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 898a4bd723..f8bf7cf874 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -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,15 @@ 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'); + + // try to set the source attr from OAuth app + if (empty($this->source)) { + $this->source = $this->oauth_source; + } - if (empty($this->source) || in_array($source, $this->reserved_sources)) { + if (empty($this->source) || in_array($this->source, self::$reserved_sources)) { $this->source = 'api'; } @@ -112,6 +122,20 @@ class ApiStatusesUpdateAction extends ApiAuthAction return; } + // Workaround for PHP returning empty $_POST and $_FILES when POST + // length > post_max_size in php.ini + + if (empty($_FILES) + && empty($_POST) + && ($_SERVER['CONTENT_LENGTH'] > 0) + ) { + $msg = _('The server was unable to handle that much POST ' . + 'data (%s bytes) due to its current configuration.'); + + $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH'])); + return; + } + if (empty($this->status)) { $this->clientError( 'Client must provide a \'status\' parameter with a value.', @@ -122,14 +146,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction } if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); - return; - } - - // Workaround for PHP returning empty $_FILES when POST length > PHP settings - - if (empty($_POST) && ($_SERVER['CONTENT_LENGTH'] > 0)) { - $this->clientError(_('Unable to handle that much POST data!')); + $this->clientError(_('No such user.'), 404, $this->format); return; } @@ -213,13 +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 - ); + $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);