X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ftwitapiblocks.php;h=8135adef3c2827ed17150082782f547339801b66;hb=b4e649fe906a793cd5e62d6390065ea5d41c40db;hp=a498d2038d56889e1aaf2433bdf77ae96c8f4781;hpb=3df358a9e98328de4d865b91a5900f834a1f195a;p=quix0rs-gnu-social.git diff --git a/actions/twitapiblocks.php b/actions/twitapiblocks.php index a498d2038d..8135adef3c 100644 --- a/actions/twitapiblocks.php +++ b/actions/twitapiblocks.php @@ -21,18 +21,52 @@ if (!defined('LACONICA')) { exit(1); } 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); - exit(); - } - - function destroy($args, $apidata) { - parent::handle($args); - common_server_error("API method under construction.", $code=501); - exit(); - } - +class TwitapiblocksAction extends TwitterapiAction +{ + + function create($args, $apidata) + { + + parent::handle($args); + + $blockee = $this->get_user($apidata['api_arg'], $apidata); + + if (!$blockee) { + $this->clientError('Not Found', 404, $apidata['content-type']); + return; + } + + $user = $apidata['user']; + + if ($user->hasBlocked($blockee) || $user->block($blockee)) { + $type = $apidata['content-type']; + $this->init_document($type); + $this->show_profile($blockee, $type); + $this->end_document($type); + } else { + $this->serverError(_('Block user failed.')); + } + } + + function destroy($args, $apidata) + { + parent::handle($args); + $blockee = $this->get_user($apidata['api_arg'], $apidata); + + if (!$blockee) { + $this->clientError('Not Found', 404, $apidata['content-type']); + return; + } + + $user = $apidata['user']; + + if (!$user->hasBlocked($blockee) || $user->unblock($blockee)) { + $type = $apidata['content-type']; + $this->init_document($type); + $this->show_profile($blockee, $type); + $this->end_document($type); + } else { + $this->serverError(_('Unblock user failed.')); + } + } } \ No newline at end of file