X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ftwitapidirect_messages.php;h=a31d18a5cc50684f40ced2c250af65221922010d;hb=485247e9011e08a6ff0b9a2ff3d7a60bad515a26;hp=fcdf822e0465d814fe9d2c3a89bec64e7a1d6ec0;hpb=1c4f7722da90e8e8ce0489720ede223804885377;p=quix0rs-gnu-social.git diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php index fcdf822e04..a31d18a5cc 100644 --- a/actions/twitapidirect_messages.php +++ b/actions/twitapidirect_messages.php @@ -23,20 +23,6 @@ require_once(INSTALLDIR.'/lib/twitterapi.php'); class Twitapidirect_messagesAction extends TwitterapiAction { - function is_readonly() { - - static $write_methods = array( 'direct_messages', - 'sent'); - - $cmdtext = explode('.', $this->arg('method')); - - if (in_array($cmdtext[0], $write_methods)) { - return false; - } - - return true; - } - function direct_messages($args, $apidata) { parent::handle($args); return $this->show_messages($args, $apidata, 'received'); @@ -104,7 +90,6 @@ class Twitapidirect_messagesAction extends TwitterapiAction { common_user_error(_('API method not found!'), $code = 404); } - exit(); } // had to change this from "new" to "create" to avoid PHP reserved word @@ -113,7 +98,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction { if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']); - exit(); + return; } $user = $apidata['user']; @@ -130,32 +115,30 @@ class Twitapidirect_messagesAction extends TwitterapiAction { } else if (mb_strlen($status) > 140) { $this->client_error(_('That\'s too long. Max message size is 140 chars.'), $code = 406, $apidata['content-type']); - exit(); + return; } - common_debug($this->trimmed('user')); - $other = $this->get_user($this->trimmed('user')); if (!$other) { $this->client_error(_('Recipient user not found.'), $code = 403, $apidata['content-type']); - exit(); + return; } else if (!$user->mutuallySubscribed($other)) { $this->client_error(_('Can\'t send direct messages to users who aren\'t your friend.'), $code = 403, $apidata['content-type']); - exit(); + return; } else if ($user->id == $other->id) { // Sending msgs to yourself is allowed by Twitter $this->client_error(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'), $code = 403, $apidata['content-type']); - exit(); + return; } $message = Message::saveNew($user->id, $other->id, $content, $source); if (is_string($message)) { $this->server_error($message); - exit(); + return; } $this->notify($user, $other, $message); @@ -166,13 +149,11 @@ class Twitapidirect_messagesAction extends TwitterapiAction { $this->show_single_json_dmsg($message); } - exit(); } function destroy($args, $apidata) { parent::handle($args); common_server_error(_('API method under construction.'), $code=501); - exit(); } function show_xml_dmsgs($message) {