]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/twitapistatuses.php
fix format string, again again
[quix0rs-gnu-social.git] / actions / twitapistatuses.php
index 6a63dd03778e07da23fa36497d56509c033701d5..3041240dded4dd59fdff76e5da2f49f0f0637672 100644 (file)
@@ -61,7 +61,10 @@ class TwitapistatusesAction extends TwitterapiAction {
 
                # XXX: sub-optimal performance
 
-               $notice->is_local = 1;
+               if (common_config('public', 'localonly')) {
+                       $notice->is_local = 1;
+               }
+
                $notice->orderBy('created DESC, notice.id DESC');
                $notice->limit($MAX_PUBSTATUSES);
                $cnt = $notice->find();
@@ -374,6 +377,11 @@ class TwitapistatusesAction extends TwitterapiAction {
 
                parent::handle($args);
 
+               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+                       $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
+                       exit();
+               }
+
                $user = $apidata['user'];
                $status = $this->trimmed('status');
                $source = $this->trimmed('source');
@@ -530,6 +538,25 @@ class TwitapistatusesAction extends TwitterapiAction {
 
        }
 
+       function show($args, $apidata) {
+               parent::handle($args);
+               
+               $notice_id = $apidata['api_arg'];               
+               $notice = Notice::staticGet($notice_id);
+
+               if ($notice) {
+                       if ($apidata['content-type'] == 'xml') { 
+                               $this->show_single_xml_status($notice);
+                       } elseif ($apidata['content-type'] == 'json') {
+                               $this->show_single_json_status($notice);
+                       }
+               } else {
+                       // XXX: Twitter just sets a 404 header and doens't bother to return an err msg
+                       $this->client_error(_('No status with that ID found.'), 404, $apidata['content-type']);
+               }
+               
+               exit();
+       }
 
 
        /*
@@ -550,7 +577,42 @@ class TwitapistatusesAction extends TwitterapiAction {
        function destroy($args, $apidata) {
        
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+
+               common_debug($_SERVER['REQUEST_METHOD']);
+               
+               // Check for RESTfulness  
+               if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
+                       // XXX: Twitter just prints the err msg, no XML / JSON.
+                       $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
+                       exit();
+               } 
+               
+               $user = $apidata['user'];                               
+               $notice_id = $apidata['api_arg'];               
+               $notice = Notice::staticGet($notice_id);
+               
+               if (!$notice) {
+                       $this->client_error(_('No status found with that ID.'), 404, $apidata['content-type']);
+                       exit();
+               }
+                               
+               if ($user->id == $notice->profile_id) {
+                       $replies = new Reply;
+                       $replies->get('notice_id', $notice_id);
+                       common_dequeue_notice($notice);
+                       $replies->delete();
+                       $notice->delete();
+                       
+                       if ($apidata['content-type'] == 'xml') { 
+                               $this->show_single_xml_status($notice);
+                       } elseif ($apidata['content-type'] == 'json') {
+                               $this->show_single_json_status($notice);
+                       }       
+               } else {
+                       $this->client_error(_('You may not delete another user\'s status.'), 403, $apidata['content-type']);
+               }
+               
+               exit();
        }
 
        # User Methods