exit(1);
}
-require_once INSTALLDIR . '/lib/apiauth.php';
-
/**
* Show a list of direct messages from or to the authenticating user
*
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
-
class ApiDirectMessageAction extends ApiAuthAction
{
var $messages = null;
* @param array $args $_REQUEST args
*
* @return boolean success flag
- *
*/
-
function prepare($args)
{
parent::prepare($args);
$this->user = $this->auth_user;
if (empty($this->user)) {
+ // TRANS: Client error given when a user was not found (404).
$this->clientError(_('No such user.'), 404, $this->format);
return;
}
// Action was called by /api/direct_messages/sent.format
$this->title = sprintf(
+ // TRANS: Title. %s is a user nickname.
_("Direct messages from %s"),
$this->user->nickname
);
$this->subtitle = sprintf(
+ // TRANS: Subtitle. %s is a user nickname.
_("All the direct messages sent from %s"),
$this->user->nickname
);
$this->id = "tag:$taguribase:SentDirectMessages:" . $this->user->id;
} else {
$this->title = sprintf(
+ // TRANS: Title. %s is a user nickname.
_("Direct messages to %s"),
$this->user->nickname
);
$this->subtitle = sprintf(
+ // TRANS: Subtitle. %s is a user nickname.
_("All the direct messages sent to %s"),
$this->user->nickname
);
*
* @return void
*/
-
function handle($args)
{
parent::handle($args);
*
* @return void
*/
-
function showMessages()
{
switch($this->format) {
$this->showJsonDirectMessages();
break;
default:
+ // TRANS: Client error displayed when coming across a non-supported API method.
$this->clientError(_('API method not found.'), $code = 404);
break;
}
*
* @return array notices
*/
-
function getMessages()
{
$message = new Message();
$message->whereAdd('id > ' . $this->since_id);
}
- if (!empty($since)) {
- $d = date('Y-m-d H:i:s', $this->since);
- $message->whereAdd("created > '$d'");
- }
-
$message->orderBy('created DESC, id DESC');
$message->limit((($this->page - 1) * $this->count), $this->count);
$message->find();
*
* @return boolean true
*/
-
function isReadOnly($args)
{
return true;
*
* @return string datestamp of the latest notice in the stream
*/
-
function lastModified()
{
if (!empty($this->messages)) {
*
* @return void
*/
-
function showXmlDirectMessages()
{
$this->initDocument('xml');
- $this->elementStart('direct-messages', array('type' => 'array'));
+ $this->elementStart('direct-messages', array('type' => 'array',
+ 'xmlns:statusnet' => 'http://status.net/schema/api/1/'));
foreach ($this->messages as $m) {
$dm_array = $this->directMessageArray($m);
*
* @return void
*/
-
function showJsonDirectMessages()
{
$this->initDocument('json');
*
* @return void
*/
-
function showRssDirectMessages()
{
$this->initDocument('rss');
*
* @return void
*/
-
function showAtomDirectMessages()
{
$this->initDocument('atom');
*
* @return string etag
*/
-
function etag()
{
if (!empty($this->messages)) {
return '"' . implode(
':',
array($this->arg('action'),
+ common_user_cache_hash($this->auth_user),
common_language(),
strtotime($this->messages[0]->created),
strtotime($this->messages[$last]->created)
return null;
}
-
}