X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ftwitapidirect_messages.php;h=535795ca4321d6351edca4dbe6d2d2e3ced8ef2b;hb=2abe10b8ea4b5d69fc7f6513bf465541454ca2cf;hp=d6eaf844e9120ba1f9e0bddf6b210769fc603b48;hpb=e0c3bf5a75094937315aa09dd9635833f9eb2925;p=quix0rs-gnu-social.git diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php index d6eaf844e9..535795ca43 100644 --- a/actions/twitapidirect_messages.php +++ b/actions/twitapidirect_messages.php @@ -40,6 +40,8 @@ class Twitapidirect_messagesAction extends TwitterapiAction { $count = $this->arg('count'); $since = $this->arg('since'); $since_id = $this->arg('since_id'); + $before_id = $this->arg('before_id'); + $page = $this->arg('page'); if (!$page) { @@ -69,6 +71,21 @@ class Twitapidirect_messagesAction extends TwitterapiAction { $link = $server . $user->nickname . '/outbox'; } + if ($before_id) { + $message->whereAdd("id < $before_id"); + } + + if ($since_id) { + $message->whereAdd("id > $since_id"); + } + + $since = strtotime($this->arg('since')); + + if ($since) { + $d = date('Y-m-d H:i:s', $since); + $message->whereAdd("created > '$d'"); + } + $message->orderBy('created DESC, id DESC'); $message->limit((($page-1)*20), $count); $message->find(); @@ -102,9 +119,10 @@ class Twitapidirect_messagesAction extends TwitterapiAction { } $user = $apidata['user']; - $source = $this->trimmed('source'); // Not supported by Twitter. + $source = $this->trimmed('source'); // Not supported by Twitter. - if (!$source) { + $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api'); + if (!$source || in_array($source, $reserved_sources)) { $source = 'api'; } @@ -112,10 +130,13 @@ class Twitapidirect_messagesAction extends TwitterapiAction { if (!$content) { $this->client_error(_('No message text!'), $code = 406, $apidata['content-type']); - } else if (mb_strlen($status) > 140) { - $this->client_error(_('That\'s too long. Max message size is 140 chars.'), - $code = 406, $apidata['content-type']); - return; + } else { + $content_shortened = common_shorten_links($content); + if (mb_strlen($content_shortened) > 140) { + $this->client_error(_('That\'s too long. Max message size is 140 chars.'), + $code = 406, $apidata['content-type']); + return; + } } $other = $this->get_user($this->trimmed('user')); @@ -133,8 +154,8 @@ class Twitapidirect_messagesAction extends TwitterapiAction { $code = 403, $apidata['content-type']); return; } - - $message = Message::saveNew($user->id, $other->id, + + $message = Message::saveNew($user->id, $other->id, html_entity_decode($content, ENT_NOQUOTES, 'UTF-8'), $source); if (is_string($message)) { @@ -263,4 +284,4 @@ class Twitapidirect_messagesAction extends TwitterapiAction { # XXX: Jabber, SMS notifications... probably queued } -} \ No newline at end of file +}