forked from GNUsocial/gnu-social
- Fix bugs with block and friendship API methods
- Friendship API methods now use a Profile instead of User for target
This commit is contained in:
parent
dcfe5b24f6
commit
923d9ef71c
@ -23,7 +23,7 @@
|
|||||||
* @package StatusNet
|
* @package StatusNet
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009-2010 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
@ -65,7 +65,7 @@ class ApiBlockCreateAction extends ApiAuthAction
|
|||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
$this->user = $this->auth_user;
|
$this->user = $this->auth_user;
|
||||||
$this->other = $this->getTargetUser($this->arg('id'));
|
$this->other = $this->getTargetProfile($this->arg('id'));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* @package StatusNet
|
* @package StatusNet
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009-2010 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
@ -64,7 +64,7 @@ class ApiBlockDestroyAction extends ApiAuthAction
|
|||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
$this->user = $this->auth_user;
|
$this->user = $this->auth_user;
|
||||||
$this->other = $this->getTargetUser($this->arg('id'));
|
$this->other = $this->getTargetProfile($this->arg('id'));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* @author Dan Moore <dan@moore.cx>
|
* @author Dan Moore <dan@moore.cx>
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009-2010 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
@ -67,7 +67,7 @@ class ApiFriendshipsCreateAction extends ApiAuthAction
|
|||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
$this->user = $this->auth_user;
|
$this->user = $this->auth_user;
|
||||||
$this->other = $this->getTargetUser($id);
|
$this->other = $this->getTargetProfile($this->arg('id'));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ class ApiFriendshipsCreateAction extends ApiAuthAction
|
|||||||
|
|
||||||
if (empty($this->other)) {
|
if (empty($this->other)) {
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
_('Could not follow user: User not found.'),
|
_('Could not follow user: profile not found.'),
|
||||||
403,
|
403,
|
||||||
$this->format
|
$this->format
|
||||||
);
|
);
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* @author Dan Moore <dan@moore.cx>
|
* @author Dan Moore <dan@moore.cx>
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009-2010 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
@ -67,7 +67,7 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction
|
|||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
$this->user = $this->auth_user;
|
$this->user = $this->auth_user;
|
||||||
$this->other = $this->getTargetUser($id);
|
$this->other = $this->getTargetProfile($this->arg('id'));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -125,8 +125,7 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
// throws an exception on error
|
// throws an exception on error
|
||||||
Subscription::cancel($this->user->getProfile(),
|
Subscription::cancel($this->user->getProfile(), $this->other);
|
||||||
$this->other->getProfile());
|
|
||||||
|
|
||||||
$this->initDocument($this->format);
|
$this->initDocument($this->format);
|
||||||
$this->showProfile($this->other, $this->format);
|
$this->showProfile($this->other, $this->format);
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* @author Dan Moore <dan@moore.cx>
|
* @author Dan Moore <dan@moore.cx>
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009-2010 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
@ -50,8 +50,8 @@ require_once INSTALLDIR . '/lib/apiprivateauth.php';
|
|||||||
|
|
||||||
class ApiFriendshipsExistsAction extends ApiPrivateAuthAction
|
class ApiFriendshipsExistsAction extends ApiPrivateAuthAction
|
||||||
{
|
{
|
||||||
var $user_a = null;
|
var $profile_a = null;
|
||||||
var $user_b = null;
|
var $profile_b = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take arguments for running
|
* Take arguments for running
|
||||||
@ -66,11 +66,8 @@ class ApiFriendshipsExistsAction extends ApiPrivateAuthAction
|
|||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
$user_a_id = $this->trimmed('user_a');
|
$this->profile_a = $this->getTargetProfile($this->trimmed('user_a'));
|
||||||
$user_b_id = $this->trimmed('user_b');
|
$this->profile_b = $this->getTargetProfile($this->trimmed('user_b'));
|
||||||
|
|
||||||
$this->user_a = $this->getTargetUser($user_a_id);
|
|
||||||
$this->user_b = $this->getTargetUser($user_b_id);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -89,16 +86,16 @@ class ApiFriendshipsExistsAction extends ApiPrivateAuthAction
|
|||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (empty($this->user_a) || empty($this->user_b)) {
|
if (empty($this->profile_a) || empty($this->profile_b)) {
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
_('Two user ids or screen_names must be supplied.'),
|
_('Two valid IDs or screen_names must be supplied.'),
|
||||||
400,
|
400,
|
||||||
$this->format
|
$this->format
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->user_a->isSubscribed($this->user_b);
|
$result = Subscription::exists($this->profile_a, $this->profile_b);
|
||||||
|
|
||||||
switch ($this->format) {
|
switch ($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
|
@ -1374,6 +1374,34 @@ class ApiAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTargetProfile($id)
|
||||||
|
{
|
||||||
|
if (empty($id)) {
|
||||||
|
|
||||||
|
// Twitter supports these other ways of passing the user ID
|
||||||
|
if (is_numeric($this->arg('id'))) {
|
||||||
|
return Profile::staticGet($this->arg('id'));
|
||||||
|
} else if ($this->arg('id')) {
|
||||||
|
$nickname = common_canonical_nickname($this->arg('id'));
|
||||||
|
return Profile::staticGet('nickname', $nickname);
|
||||||
|
} else if ($this->arg('user_id')) {
|
||||||
|
// This is to ensure that a non-numeric user_id still
|
||||||
|
// overrides screen_name even if it doesn't get used
|
||||||
|
if (is_numeric($this->arg('user_id'))) {
|
||||||
|
return Profile::staticGet('id', $this->arg('user_id'));
|
||||||
|
}
|
||||||
|
} else if ($this->arg('screen_name')) {
|
||||||
|
$nickname = common_canonical_nickname($this->arg('screen_name'));
|
||||||
|
return Profile::staticGet('nickname', $nickname);
|
||||||
|
}
|
||||||
|
} else if (is_numeric($id)) {
|
||||||
|
return Profile::staticGet($id);
|
||||||
|
} else {
|
||||||
|
$nickname = common_canonical_nickname($id);
|
||||||
|
return Profile::staticGet('nickname', $nickname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getTargetGroup($id)
|
function getTargetGroup($id)
|
||||||
{
|
{
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user