From ef3d487ae02a6333b4e0f0714599ff1c3b7b729e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 8 Dec 2008 13:57:28 -0500 Subject: enable block API darcs-hash:20081208185728-5ed1f-8d5f6be6decfbb50deb4ca50bee13404d0c51b72.gz --- actions/twitapiblocks.php | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'actions/twitapiblocks.php') diff --git a/actions/twitapiblocks.php b/actions/twitapiblocks.php index 21d620dd3..6bfdec0d0 100644 --- a/actions/twitapiblocks.php +++ b/actions/twitapiblocks.php @@ -24,13 +24,40 @@ require_once(INSTALLDIR.'/lib/twitterapi.php'); class TwitapiblocksAction extends TwitterapiAction { function create($args, $apidata) { + parent::handle($args); - common_server_error(_('API method under construction.'), $code=501); + + $blockee = $this->get_user($apidata['api_arg'], $apidata); + + if (!$blockee) { + $this->client_error('Not Found', 404, $apidata['content-type']); + return; + } + + $user = $apidata['user']; + + if ($user->hasBlocked($blockee) || $user->block($blockee)) { + $this->show_profile($blockee, $apidata['content-type']); + } else { + common_server_error(_('Block user failed.')); + } } function destroy($args, $apidata) { parent::handle($args); - common_server_error(_('API method under construction.'), $code=501); - } + $blockee = $this->get_user($apidata['api_arg'], $apidata); + + if (!$blockee) { + $this->client_error('Not Found', 404, $apidata['content-type']); + return; + } + $user = $apidata['user']; + + if (!$user->hasBlocked($blockee) || $user->unblock($blockee)) { + $this->show_profile($blockee, $apidata['content-type']); + } else { + common_server_error(_('Unblock user failed.')); + } + } } \ No newline at end of file -- cgit v1.2.3-54-g00ecf