X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=actions%2Fapiaccountupdatedeliverydevice.php;h=a3cbb418b65d60c899ca865fbbe9a34efcbc69e1;hb=c95f74018d8e997fabc07a42afb75e39c769531f;hp=ec87c4c953b74e5fedcdcb44e0a09d1b58622b3d;hpb=8d0c014ced78b3b6328105e2a82e3776059b600a;p=quix0rs-gnu-social.git diff --git a/actions/apiaccountupdatedeliverydevice.php b/actions/apiaccountupdatedeliverydevice.php index ec87c4c953..a3cbb418b6 100644 --- a/actions/apiaccountupdatedeliverydevice.php +++ b/actions/apiaccountupdatedeliverydevice.php @@ -32,8 +32,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/apiauth.php'; - /** * Sets which channel (device) StatusNet delivers updates to for * the authenticating user. Sending none as the device parameter @@ -47,6 +45,8 @@ require_once INSTALLDIR . '/lib/apiauth.php'; */ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction { + protected $needPost = true; + /** * Take arguments for running * @@ -77,23 +77,13 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction { parent::handle($args); - if ($_SERVER['REQUEST_METHOD'] != 'POST') { - $this->clientError( - // TRANS: Client error message. POST is a HTTP command. It should not be translated. - _('This method requires a POST.'), - 400, $this->format - ); - return; - } - if (!in_array($this->format, array('xml', 'json'))) { $this->clientError( - // TRANS: Client error displayed handling a non-existing API method. + // TRANS: Client error displayed when coming across a non-supported API method. _('API method not found.'), 404, $this->format ); - return; } // Note: Twitter no longer supports IM @@ -102,13 +92,11 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction // TRANS: Client error displayed when no valid device parameter is provided for a user's delivery device setting. $this->clientError(_( 'You must specify a parameter named ' . '\'device\' with a value of one of: sms, im, none.' )); - return; } if (empty($this->user)) { // TRANS: Client error displayed when no existing user is provided for a user's delivery device setting. - $this->clientError(_('No such user.'), 404, $this->format); - return; + $this->clientError(_('No such user.'), 404); } $original = clone($this->user); @@ -116,10 +104,16 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction if (strtolower($this->device) == 'sms') { $this->user->smsnotify = true; } elseif (strtolower($this->device) == 'im') { - $this->user->jabbernotify = true; + //TODO IM is pluginized now, so what should we do? + //Enable notifications for all IM plugins? + //For now, don't do anything + //$this->user->jabbernotify = true; } elseif (strtolower($this->device == 'none')) { $this->user->smsnotify = false; - $this->user->jabbernotify = false; + //TODO IM is pluginized now, so what should we do? + //Disable notifications for all IM plugins? + //For now, don't do anything + //$this->user->jabbernotify = false; } $result = $this->user->update($original); @@ -128,7 +122,6 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction common_log_db_error($this->user, 'UPDATE', __FILE__); // TRANS: Server error displayed when a user's delivery device cannot be updated. $this->serverError(_('Could not update user.')); - return; } $profile = $this->user->getProfile(); @@ -143,7 +136,7 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction if ($this->format == 'xml') { $this->initDocument('xml'); - $this->showTwitterXmlUser($twitter_user); + $this->showTwitterXmlUser($twitter_user, 'user', true); $this->endDocument('xml'); } elseif ($this->format == 'json') { $this->initDocument('json');