Various $this->scoped fixes and protected prepare/handle in API actions
This commit is contained in:
parent
6cdedf6049
commit
282f4d6a89
@ -29,9 +29,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows the authenticating users to follow (subscribe) the user specified in
|
* Allows the authenticating users to follow (subscribe) the user specified in
|
||||||
@ -90,7 +88,7 @@ class ApiFriendshipsCreateAction extends ApiAuthAction
|
|||||||
$this->clientError(_('Could not follow user: profile not found.'), 403);
|
$this->clientError(_('Could not follow user: profile not found.'), 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->user->isSubscribed($this->other)) {
|
if ($this->scoped->isSubscribed($this->other)) {
|
||||||
$errmsg = sprintf(
|
$errmsg = sprintf(
|
||||||
// TRANS: Client error displayed when trying to follow a user that's already being followed.
|
// TRANS: Client error displayed when trying to follow a user that's already being followed.
|
||||||
// TRANS: %s is the nickname of the user that is already being followed.
|
// TRANS: %s is the nickname of the user that is already being followed.
|
||||||
@ -101,7 +99,7 @@ class ApiFriendshipsCreateAction extends ApiAuthAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Subscription::start($this->user->getProfile(), $this->other);
|
Subscription::start($this->scoped, $this->other);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->clientError($e->getMessage(), 403);
|
$this->clientError($e->getMessage(), 403);
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the existence of friendship between two users. Will return true if
|
* Tests for the existence of friendship between two users. Will return true if
|
||||||
@ -57,7 +55,7 @@ class ApiFriendshipsExistsAction extends ApiPrivateAuthAction
|
|||||||
*
|
*
|
||||||
* @return boolean success flag
|
* @return boolean success flag
|
||||||
*/
|
*/
|
||||||
function prepare($args)
|
protected function prepare(array $args=array())
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
@ -72,22 +70,18 @@ class ApiFriendshipsExistsAction extends ApiPrivateAuthAction
|
|||||||
*
|
*
|
||||||
* Check the format and show the user info
|
* Check the format and show the user info
|
||||||
*
|
*
|
||||||
* @param array $args $_REQUEST data (unused)
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function handle($args)
|
protected function handle()
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle();
|
||||||
|
|
||||||
if (empty($this->profile_a) || empty($this->profile_b)) {
|
if (empty($this->profile_a) || empty($this->profile_b)) {
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
// TRANS: Client error displayed when supplying invalid parameters to an API call checking if a friendship exists.
|
// TRANS: Client error displayed when supplying invalid parameters to an API call checking if a friendship exists.
|
||||||
_('Two valid IDs or nick names must be supplied.'),
|
_('Two valid IDs or nick names must be supplied.'),
|
||||||
400,
|
400
|
||||||
$this->format
|
|
||||||
);
|
);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = Subscription::exists($this->profile_a, $this->profile_b);
|
$result = Subscription::exists($this->profile_a, $this->profile_b);
|
||||||
|
@ -29,9 +29,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Outputs detailed information about the relationship between two users
|
* Outputs detailed information about the relationship between two users
|
||||||
@ -56,7 +54,7 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction
|
|||||||
*
|
*
|
||||||
* @return boolean success flag
|
* @return boolean success flag
|
||||||
*/
|
*/
|
||||||
function prepare($args)
|
protected function prepare(array $args=array())
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
@ -109,13 +107,11 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction
|
|||||||
*
|
*
|
||||||
* Check the format and show the user info
|
* Check the format and show the user info
|
||||||
*
|
*
|
||||||
* @param array $args $_REQUEST data (unused)
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function handle($args)
|
protected function handle()
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle();
|
||||||
|
|
||||||
if (!in_array($this->format, array('xml', 'json'))) {
|
if (!in_array($this->format, array('xml', 'json'))) {
|
||||||
// TRANS: Client error displayed when coming across a non-supported API method.
|
// TRANS: Client error displayed when coming across a non-supported API method.
|
||||||
|
Loading…
Reference in New Issue
Block a user