]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Twitter-compatible API: made is_readonly() method smarter
authorzach <zach@copley.name>
Tue, 22 Jul 2008 18:29:19 +0000 (14:29 -0400)
committerzach <zach@copley.name>
Tue, 22 Jul 2008 18:29:19 +0000 (14:29 -0400)
darcs-hash:20080722182919-ca946-dce04d84290711066154567458da2dd3253dd957.gz

actions/twitapiaccount.php
actions/twitapifriendships.php
actions/twitapistatuses.php

index a43d1edbada0f5927064a9af5756d9f8b7972161..0a57ad91c3c759ecb909174dee4f01082a7d5521 100644 (file)
@@ -24,7 +24,17 @@ require_once(INSTALLDIR.'/lib/twitterapi.php');
 class TwitapiaccountAction extends TwitterapiAction {
 
        function is_readonly() {
-               return false;
+               
+               static $write_methods = array(  'update_location',
+                                                                               'update_delivery_device');
+               
+               $cmdtext = explode('.', $this->arg('method'));          
+               
+               if (in_array($cmdtext[0], $write_methods)) {                    
+                       return false;
+               }
+                               
+               return true;
        }
 
        function verify_credentials($args, $apidata) {
index 19bc71b7af0a8e3c20f9aa9a2c14c1894c144f0e..05c192ea6fc8bc46938c64d5a60b2dac2539a9bf 100644 (file)
@@ -23,6 +23,20 @@ require_once(INSTALLDIR.'/lib/twitterapi.php');
 
 class TwitapifriendshipsAction extends TwitterapiAction {
 
+       function is_readonly() {
+               
+               static $write_methods = array(  'create',
+                                                                               'destroy');
+               
+               $cmdtext = explode('.', $this->arg('method'));          
+               
+               if (in_array($cmdtext[0], $write_methods)) {                    
+                       return false;
+               }
+                               
+               return true;
+       }
+
        function create($args, $apidata) {
                parent::handle($args);
 
index 3a06d146c7b674ae3c2cf955599bd0ad7757ca9f..30f2e514aff68d7041a53e7b0c000b6b36cd7833 100644 (file)
@@ -28,12 +28,22 @@ require_once(INSTALLDIR.'/lib/twitterapi.php');
 class TwitapistatusesAction extends TwitterapiAction {
        
        function is_readonly() {
-               return false;
+               
+               static $write_methods = array(  'update',
+                                                                               'destroy');
+               
+               $cmdtext = explode('.', $this->arg('method'));          
+               
+               if (in_array($cmdtext[0], $write_methods)) {                    
+                       return false;
+               }
+                               
+               return true;
        }
        
        function public_timeline($args, $apidata) {
                parent::handle($args);
-
+               
                $sitename = common_config('site', 'name');
                $siteserver = common_config('site', 'server'); 
                $title = sprintf(_("%s public timeline"), $sitename);
@@ -365,6 +375,9 @@ class TwitapistatusesAction extends TwitterapiAction {
                
                $user = $apidata['user'];
                                
+               $this->is_readonly();
+               
+                               
                $notice = DB_DataObject::factory('notice');             
                
                $notice->profile_id = $user->id; # user id *is* profile id