From 923d9ef71ce49bfa55460bf42acb8a35bf3e84be Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 28 Jun 2010 16:53:05 -0700 Subject: - Fix bugs with block and friendship API methods - Friendship API methods now use a Profile instead of User for target --- lib/apiaction.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib/apiaction.php') diff --git a/lib/apiaction.php b/lib/apiaction.php index 89a487102..8de13a62d 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -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) { if (empty($id)) { -- cgit v1.2.3-54-g00ecf