X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ftwitapidirect_messages.php;h=d2dbdb619b180044a0388cd592382944eec4018a;hb=b4e649fe906a793cd5e62d6390065ea5d41c40db;hp=db55e8cd0220de6a01c68763af20d7ad5f45cb49;hpb=4b0cf99e56f965e10eeb8b8b19e7b405bda49eaf;p=quix0rs-gnu-social.git diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php index db55e8cd02..d2dbdb619b 100644 --- a/actions/twitapidirect_messages.php +++ b/actions/twitapidirect_messages.php @@ -38,13 +38,12 @@ class Twitapidirect_messagesAction extends TwitterapiAction function show_messages($args, $apidata, $type) { - $user = $apidata['user']; $count = $this->arg('count'); $since = $this->arg('since'); $since_id = $this->arg('since_id'); - $before_id = $this->arg('before_id'); + $max_id = $this->arg('max_id'); $page = $this->arg('page'); @@ -75,8 +74,8 @@ class Twitapidirect_messagesAction extends TwitterapiAction $link = $server . $user->nickname . '/outbox'; } - if ($before_id) { - $message->whereAdd("id < $before_id"); + if ($max_id) { + $message->whereAdd("id <= $max_id"); } if ($since_id) { @@ -102,7 +101,17 @@ class Twitapidirect_messagesAction extends TwitterapiAction $this->show_rss_dmsgs($message, $title, $link, $subtitle); break; case 'atom': - $this->show_atom_dmsgs($message, $title, $link, $subtitle); + $selfuri = common_root_url() . 'api/direct_messages'; + $selfuri .= ($type == 'received') ? '.atom' : '/sent.atom'; + $taguribase = common_config('integration', 'taguri'); + + if ($type == 'sent') { + $id = "tag:$taguribase:SentDirectMessages:" . $user->id; + } else { + $id = "tag:$taguribase:DirectMessages:" . $user->id; + } + + $this->show_atom_dmsgs($message, $title, $link, $subtitle, $selfuri, $id); break; case 'json': $this->show_json_dmsgs($message); @@ -190,7 +199,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction $this->init_document('xml'); $this->elementStart('direct-messages', array('type' => 'array')); - if (is_array($messages)) { + if (is_array($message)) { foreach ($message as $m) { $twitter_dm = $this->twitter_dmsg_array($m); $this->show_twitter_xml_dmsg($twitter_dm); @@ -261,16 +270,17 @@ class Twitapidirect_messagesAction extends TwitterapiAction } - function show_atom_dmsgs($message, $title, $link, $subtitle) + function show_atom_dmsgs($message, $title, $link, $subtitle, $selfuri, $id) { $this->init_document('atom'); $this->element('title', null, $title); - $siteserver = common_config('site', 'server'); - $this->element('id', null, "tag:$siteserver,2008:DirectMessage"); + $this->element('id', null, $id); $this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null); - $this->element('updated', null, common_date_iso8601(strftime('%c'))); + $this->element('link', array('href' => $selfuri, 'rel' => 'self', + 'type' => 'application/atom+xml'), null); + $this->element('updated', null, common_date_iso8601('now')); $this->element('subtitle', null, $subtitle); if (is_array($message)) {