Allow screennames that are === '0'

This commit is contained in:
Mikael Nordfeldth 2016-02-08 11:38:52 +01:00
parent 2686635f60
commit 13cf744fb3

View File

@ -1404,20 +1404,21 @@ class ApiAction extends Action
if (self::is_decimal($this->arg('user_id'))) { if (self::is_decimal($this->arg('user_id'))) {
return Profile::getKV('id', $this->arg('user_id')); return Profile::getKV('id', $this->arg('user_id'));
} }
} else if ($this->arg('screen_name')) { } elseif (mb_strlen($this->arg('screen_name')) > 0) {
$nickname = common_canonical_nickname($this->arg('screen_name')); $nickname = common_canonical_nickname($this->arg('screen_name'));
$user = User::getKV('nickname', $nickname); $user = User::getByNickname($nickname);
return $user instanceof User ? $user->getProfile() : null; return $user->getProfile();
} else { } else {
// Fall back to trying the currently authenticated user // Fall back to trying the currently authenticated user
return $this->scoped; return $this->scoped;
} }
} else if (self::is_decimal($id)) { } else if (self::is_decimal($id) && intval($id) > 0) {
return Profile::getKV($id); return Profile::getByID($id);
} else { } else {
// FIXME: check if isAcct to identify remote profiles and not just local nicknames
$nickname = common_canonical_nickname($id); $nickname = common_canonical_nickname($id);
$user = User::getKV('nickname', $nickname); $user = User::getByNickname($nickname);
return $user ? $user->getProfile() : null; return $user->getProfile();
} }
} }
@ -1564,4 +1565,4 @@ class ApiAction extends Action
return $uri; return $uri;
} }
} }