set api format so client errors work
This commit is contained in:
parent
e1554be53b
commit
7285e3a8b4
|
@ -57,6 +57,8 @@ class ApiAccountUpdateProfileBannerAction extends ApiAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->user = $this->auth_user;
|
$this->user = $this->auth_user;
|
||||||
|
|
||||||
$this->cropW = $this->trimmed('width');
|
$this->cropW = $this->trimmed('width');
|
||||||
|
|
|
@ -46,6 +46,8 @@ class ApiExternalUserShowAction extends ApiPrivateAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$profileurl = urldecode($this->arg('profileurl'));
|
$profileurl = urldecode($this->arg('profileurl'));
|
||||||
$nickname = urldecode($this->arg('nickname'));
|
$nickname = urldecode($this->arg('nickname'));
|
||||||
|
|
||||||
|
|
|
@ -46,14 +46,15 @@ class ApiFavsAndRepeatsAction extends ApiPrivateAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->notice_id = $this->trimmed('notice_id');
|
$this->notice_id = $this->trimmed('notice_id');
|
||||||
|
|
||||||
$this->original = Notice::getKV('id', $this->notice_id);
|
$this->original = Notice::getKV('id', $this->notice_id);
|
||||||
|
|
||||||
if (empty($this->original)) {
|
if (empty($this->original)) {
|
||||||
// TRANS: Client error displayed trying to display redents of a non-exiting notice.
|
// TRANS: Client error displayed trying to display redents of a non-exiting notice.
|
||||||
$this->clientError(_('No such notice.'),
|
$this->clientError(_('No such notice.'), 400);
|
||||||
400, $this->format);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ class ApiQvitterAllFollowingAction extends ApiBareAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->count = 5000; // max 5000, completely arbitrary...
|
$this->count = 5000; // max 5000, completely arbitrary...
|
||||||
|
|
||||||
$this->target = $this->getTargetProfile($this->arg('id'));
|
$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;
|
var $profiles = null;
|
||||||
|
|
||||||
|
@ -58,15 +58,20 @@ class ApiQvitterBlocksAction extends ApiBareAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
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->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)) {
|
if (!($this->target instanceof Profile)) {
|
||||||
// TRANS: Client error displayed when requesting a list of followers for a non-existing user.
|
// TRANS: Client error displayed when requesting a list of followers for a non-existing user.
|
||||||
$this->clientError(_('No such user.'), 404);
|
$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();
|
$this->profiles = $this->getProfiles();
|
||||||
|
|
|
@ -39,6 +39,8 @@ class ApiQvitterCheckEmailAction extends ApiAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->email = $this->trimmed('email');
|
$this->email = $this->trimmed('email');
|
||||||
|
|
||||||
if(!Validate::email($this->email, common_config('email', 'check_domain'))) {
|
if(!Validate::email($this->email, common_config('email', 'check_domain'))) {
|
||||||
|
|
|
@ -61,19 +61,16 @@ class ApiQvitterCheckLoginAction extends ApiAction
|
||||||
{
|
{
|
||||||
parent::handle();
|
parent::handle();
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||||
$this->clientError(
|
$this->clientError(_('This method requires a POST.'), 400);
|
||||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
|
||||||
_('This method requires a POST.'),
|
|
||||||
400,
|
|
||||||
$this->format
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = common_check_user($this->arg('username'),
|
$user = common_check_user($this->arg('username'),
|
||||||
$this->arg('password'));
|
$this->arg('password'));
|
||||||
|
|
||||||
if($user) {
|
if($user) {
|
||||||
$user = true;
|
$user = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,8 @@ class ApiQvitterListMembersAction extends ApiPrivateAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->list = $this->getTargetList($this->arg('nickname'), $this->arg('id'));
|
$this->list = $this->getTargetList($this->arg('nickname'), $this->arg('id'));
|
||||||
if (!$this->list instanceof Profile_list) {
|
if (!$this->list instanceof Profile_list) {
|
||||||
// TRANS: Client error displayed trying to show list membership on a non-existing 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);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->list = $this->getTargetList($this->arg('nickname'), $this->arg('id'));
|
$this->list = $this->getTargetList($this->arg('nickname'), $this->arg('id'));
|
||||||
if (!$this->list instanceof Profile_list) {
|
if (!$this->list instanceof Profile_list) {
|
||||||
// TRANS: Client error displayed trying to show list membership on a non-existing 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);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->notifications = $this->getNotifications();
|
$this->notifications = $this->getNotifications();
|
||||||
|
|
||||||
return true;
|
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.',
|
'The server was unable to handle that much POST data (%s bytes) due to its current configuration.',
|
||||||
intval($_SERVER['CONTENT_LENGTH']));
|
intval($_SERVER['CONTENT_LENGTH']));
|
||||||
|
|
||||||
$this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
|
$this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']), 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->status)) {
|
if (empty($this->status)) {
|
||||||
// TRANS: Client error displayed when the parameter "status" is missing.
|
// 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)) {
|
if (is_null($this->scoped)) {
|
||||||
|
|
|
@ -58,6 +58,8 @@ class ApiQvitterTimelineListAction extends ApiBareAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->list = $this->getTargetList($this->arg('nickname'), $this->arg('id'));
|
$this->list = $this->getTargetList($this->arg('nickname'), $this->arg('id'));
|
||||||
if (!($this->list instanceof Profile_list)) {
|
if (!($this->list instanceof Profile_list)) {
|
||||||
// TRANS: Client error displayed when requesting a non existing list
|
// TRANS: Client error displayed when requesting a non existing list
|
||||||
|
|
|
@ -53,6 +53,8 @@ class ApiQvitterUpdateBackgroundColorAction extends ApiAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->backgroundcolor = $this->trimmed('backgroundcolor');
|
$this->backgroundcolor = $this->trimmed('backgroundcolor');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,8 @@ class ApiQvitterUpdateBookmarksAction extends ApiAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->bookmarks = $this->trimmed('bookmarks');
|
$this->bookmarks = $this->trimmed('bookmarks');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -54,6 +54,8 @@ class ApiQvitterUpdateLinkColorAction extends ApiAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->linkcolor = $this->trimmed('linkcolor');
|
$this->linkcolor = $this->trimmed('linkcolor');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -56,6 +56,8 @@ class ApiSavedSearchesListAction extends ApiAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,8 @@ class ApiTrendsPlaceAction extends ApiAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,8 @@ class ApiUpdateAvatarAction extends ApiAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->user = $this->auth_user;
|
$this->user = $this->auth_user;
|
||||||
|
|
||||||
$this->cropW = $this->trimmed('cropW');
|
$this->cropW = $this->trimmed('cropW');
|
||||||
|
|
|
@ -57,6 +57,8 @@ class ApiUpdateBackgroundImageAction extends ApiAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->format = 'json';
|
||||||
|
|
||||||
$this->user = $this->auth_user;
|
$this->user = $this->auth_user;
|
||||||
|
|
||||||
$this->cropW = $this->trimmed('cropW');
|
$this->cropW = $this->trimmed('cropW');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user