Commit 7285e3a8 authored by hannes's avatar hannes

set api format so client errors work

parent e1554be5
......@@ -57,6 +57,8 @@ class ApiAccountUpdateProfileBannerAction extends ApiAuthAction
{
parent::prepare($args);
$this->format = 'json';
$this->user = $this->auth_user;
$this->cropW = $this->trimmed('width');
......
......@@ -46,6 +46,8 @@ class ApiExternalUserShowAction extends ApiPrivateAuthAction
{
parent::prepare($args);
$this->format = 'json';
$profileurl = urldecode($this->arg('profileurl'));
$nickname = urldecode($this->arg('nickname'));
......
......@@ -46,14 +46,15 @@ class ApiFavsAndRepeatsAction extends ApiPrivateAuthAction
{
parent::prepare($args);
$this->format = 'json';
$this->notice_id = $this->trimmed('notice_id');
$this->original = Notice::getKV('id', $this->notice_id);
if (empty($this->original)) {
// TRANS: Client error displayed trying to display redents of a non-exiting notice.
$this->clientError(_('No such notice.'),
400, $this->format);
$this->clientError(_('No such notice.'), 400);
return false;
}
......
......@@ -62,6 +62,8 @@ class ApiQvitterAllFollowingAction extends ApiBareAuthAction
{
parent::prepare($args);
$this->format = 'json';
$this->count = 5000; // max 5000, completely arbitrary...
$this->target = $this->getTargetProfile($this->arg('id'));
......
......@@ -43,7 +43,7 @@ if (!defined('STATUSNET')) {
}
class ApiQvitterBlocksAction extends ApiBareAuthAction
class ApiQvitterBlocksAction extends ApiPrivateAuthAction
{
var $profiles = null;
......@@ -58,15 +58,20 @@ class ApiQvitterBlocksAction extends ApiBareAuthAction
{
parent::prepare($args);
// If called as a social graph method, show 5000 per page, otherwise 100
$this->format = 'json';
$this->count = (int)$this->arg('count', 100);
$this->target = $this->getTargetProfile($this->arg('id'));
$arg_user = $this->getTargetUser($this->arg('id'));
$this->target = ($this->auth_user) ? $this->auth_user->getProfile() : null;
if (!($this->target instanceof Profile)) {
// TRANS: Client error displayed when requesting a list of followers for a non-existing user.
$this->clientError(_('No such user.'), 404);
} else if($this->auth_user->id != $arg_user->id) {
$this->clientError(_('You are only allowed to view your own blocks.'), 403);
}
$this->profiles = $this->getProfiles();
......
......@@ -39,6 +39,8 @@ class ApiQvitterCheckEmailAction extends ApiAction
{
parent::prepare($args);
$this->format = 'json';
$this->email = $this->trimmed('email');
if(!Validate::email($this->email, common_config('email', 'check_domain'))) {
......
......@@ -61,19 +61,16 @@ class ApiQvitterCheckLoginAction extends ApiAction
{
parent::handle();
$this->format = 'json';
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
$this->clientError(
// TRANS: Client error. POST is a HTTP command. It should not be translated.
_('This method requires a POST.'),
400,
$this->format
);
$this->clientError(_('This method requires a POST.'), 400);
return;
}
$user = common_check_user($this->arg('username'),
$this->arg('password'));
$this->arg('password'));
if($user) {
$user = true;
}
......
......@@ -65,6 +65,8 @@ class ApiQvitterListMembersAction extends ApiPrivateAuthAction
{
parent::prepare($args);
$this->format = 'json';
$this->list = $this->getTargetList($this->arg('nickname'), $this->arg('id'));
if (!$this->list instanceof Profile_list) {
// TRANS: Client error displayed trying to show list membership on a non-existing list.
......
......@@ -65,6 +65,8 @@ class ApiQvitterListSubscribersAction extends ApiPrivateAuthAction
{
parent::prepare($args);
$this->format = 'json';
$this->list = $this->getTargetList($this->arg('nickname'), $this->arg('id'));
if (!$this->list instanceof Profile_list) {
// TRANS: Client error displayed trying to show list membership on a non-existing list.
......
......@@ -55,6 +55,8 @@ class ApiQvitterNotificationsAction extends ApiPrivateAuthAction
{
parent::prepare($args);
$this->format = 'json';
$this->notifications = $this->getNotifications();
return true;
......
......@@ -199,12 +199,12 @@ class ApiQvitterStatusesUpdateAction extends ApiAuthAction
'The server was unable to handle that much POST data (%s bytes) due to its current configuration.',
intval($_SERVER['CONTENT_LENGTH']));
$this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
$this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']), 400);
}
if (empty($this->status)) {
// TRANS: Client error displayed when the parameter "status" is missing.
$this->clientError(_('Client must provide a \'status\' parameter with a value.'));
$this->clientError(_('Client must provide a \'status\' parameter with a value.'), 400);
}
if (is_null($this->scoped)) {
......
......@@ -58,6 +58,8 @@ class ApiQvitterTimelineListAction extends ApiBareAuthAction
{
parent::prepare($args);
$this->format = 'json';
$this->list = $this->getTargetList($this->arg('nickname'), $this->arg('id'));
if (!($this->list instanceof Profile_list)) {
// TRANS: Client error displayed when requesting a non existing list
......
......@@ -53,6 +53,8 @@ class ApiQvitterUpdateBackgroundColorAction extends ApiAuthAction
{
parent::prepare($args);
$this->format = 'json';
$this->backgroundcolor = $this->trimmed('backgroundcolor');
return true;
}
......
......@@ -58,6 +58,8 @@ class ApiQvitterUpdateBookmarksAction extends ApiAuthAction
{
parent::prepare($args);
$this->format = 'json';
$this->bookmarks = $this->trimmed('bookmarks');
return true;
......
......@@ -54,6 +54,8 @@ class ApiQvitterUpdateLinkColorAction extends ApiAuthAction
{
parent::prepare($args);
$this->format = 'json';
$this->linkcolor = $this->trimmed('linkcolor');
return true;
......
......@@ -56,6 +56,8 @@ class ApiSavedSearchesListAction extends ApiAuthAction
{
parent::prepare($args);
$this->format = 'json';
return true;
}
......
......@@ -56,6 +56,8 @@ class ApiTrendsPlaceAction extends ApiAuthAction
{
parent::prepare($args);
$this->format = 'json';
return true;
}
......
......@@ -57,6 +57,8 @@ class ApiUpdateAvatarAction extends ApiAuthAction
{
parent::prepare($args);
$this->format = 'json';
$this->user = $this->auth_user;
$this->cropW = $this->trimmed('cropW');
......
......@@ -57,6 +57,8 @@ class ApiUpdateBackgroundImageAction extends ApiAuthAction
{
parent::prepare($args);
$this->format = 'json';
$this->user = $this->auth_user;
$this->cropW = $this->trimmed('cropW');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment