]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/twitapidirect_messages.php
Merge branch '0.8.x' of git@gitorious.org:+laconica-developers/laconica/dev into...
[quix0rs-gnu-social.git] / actions / twitapidirect_messages.php
index db55e8cd0220de6a01c68763af20d7ad5f45cb49..d2dbdb619b180044a0388cd592382944eec4018a 100644 (file)
@@ -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)) {