X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ftwitapistatuses.php;h=0c97ada0b115b8327725b864fff495b3a36b8d75;hb=575f70545171f6f5c94214ce88e5b07a1f517810;hp=670aaebf0ec0a6e6cfe6babb49df4a320f97ae50;hpb=93ac0bcae3a600733045ad7a5bafabcdfd49d9e5;p=quix0rs-gnu-social.git diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php index 670aaebf0e..0c97ada0b1 100644 --- a/actions/twitapistatuses.php +++ b/actions/twitapistatuses.php @@ -27,26 +27,41 @@ require_once(INSTALLDIR.'/lib/twitterapi.php'); */ class TwitapistatusesAction extends TwitterapiAction { + function is_readonly() { + + 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); $id = "tag:$siteserver:Statuses"; $link = common_root_url(); - $subtitle = sprintf(_("%s updates from everyone!"), $sitemap); + $subtitle = sprintf(_("%s updates from everyone!"), $sitename); // Number of public statuses to return by default -- Twitter sends 20 $MAX_PUBSTATUSES = 20; - $notice = DB_DataObject::factory('notice'); + $notice = new Notice(); // FIXME: To really live up to the spec we need to build a list // of notices by users who have custom avatars, so fix this SQL -- Zach - # FIXME: bad performance - $notice->whereAdd('EXISTS (SELECT user.id from user where user.id = notice.profile_id)'); + # XXX: sub-optimal performance + + $notice->is_local = 1; $notice->orderBy('created DESC, notice.id DESC'); $notice->limit($MAX_PUBSTATUSES); $cnt = $notice->find(); @@ -222,21 +237,7 @@ class TwitapistatusesAction extends TwitterapiAction { $link = common_local_url('all', array('nickname' => $user->nickname)); $subtitle = sprintf(_("Updates from %s and friends on %s!"), $user->nickname, $sitename); - $notice = new Notice(); - - # XXX: chokety and bad - - $notice->whereAdd('EXISTS (SELECT subscribed from subscription where subscriber = '.$profile->id.' and subscribed = notice.profile_id)', 'OR'); - $notice->whereAdd('profile_id = ' . $profile->id, 'OR'); - - # XXX: since - # XXX: since_id - - $notice->orderBy('created DESC, notice.id DESC'); - - $notice->limit((($page-1)*20), $count); - - $cnt = $notice->find(); + $notice = $user->noticesWithFriends(($page-1)*20, $count); switch($apidata['content-type']) { case 'xml': @@ -374,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 @@ -400,7 +404,8 @@ class TwitapistatusesAction extends TwitterapiAction { } $notice->rendered = common_render_content($notice->content, $notice); - + $notice->is_local = 1; + $id = $notice->insert(); if (!$id) {