1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Fix an issue with user.whoami

Summary:
Both user.whoami and user.query call the same wire formatting code, but expect different data.

Don't try to add availability data to user.whoami.

Stop adding email data to user.query. We've added it since D11791, but my intent was for it to be exposed //only// via user.whoami (i.e., expose your address, not others').

Test Plan:
  - Called both methods.
  - Saw emails on user.whoami.
  - Saw availability on user.query.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D12848
This commit is contained in:
epriestley 2015-05-14 16:48:45 -07:00
parent b34d5bf44b
commit 705c1e6498
3 changed files with 24 additions and 10 deletions

View file

@ -6,7 +6,10 @@ abstract class UserConduitAPIMethod extends ConduitAPIMethod {
return PhabricatorApplication::getByClass('PhabricatorPeopleApplication');
}
protected function buildUserInformationDictionary(PhabricatorUser $user) {
protected function buildUserInformationDictionary(
PhabricatorUser $user,
$with_email = false,
$with_availability = false) {
$roles = array();
if ($user->getIsDisabled()) {
@ -40,18 +43,23 @@ abstract class UserConduitAPIMethod extends ConduitAPIMethod {
'phid' => $user->getPHID(),
'userName' => $user->getUserName(),
'realName' => $user->getRealName(),
'primaryEmail' => $email,
'image' => $user->getProfileImageURI(),
'uri' => PhabricatorEnv::getURI('/p/'.$user->getUsername().'/'),
'roles' => $roles,
);
// TODO: Modernize this once we have a more long-term view of what the
// data looks like.
$until = $user->getAwayUntil();
if ($until) {
$return['currentStatus'] = 'away';
$return['currentStatusUntil'] = $until;
if ($with_email) {
$return['primaryEmail'] = $email;
}
if ($with_availability) {
// TODO: Modernize this once we have a more long-term view of what the
// data looks like.
$until = $user->getAwayUntil();
if ($until) {
$return['currentStatus'] = 'away';
$return['currentStatusUntil'] = $until;
}
}
return $return;

View file

@ -71,7 +71,10 @@ final class UserQueryConduitAPIMethod extends UserConduitAPIMethod {
$results = array();
foreach ($users as $user) {
$results[] = $this->buildUserInformationDictionary($user);
$results[] = $this->buildUserInformationDictionary(
$user,
$with_email = false,
$with_availability = true);
}
return $results;
}

View file

@ -29,7 +29,10 @@ final class UserWhoAmIConduitAPIMethod extends UserConduitAPIMethod {
->withPHIDs(array($request->getUser()->getPHID()))
->executeOne();
return $this->buildUserInformationDictionary($person);
return $this->buildUserInformationDictionary(
$person,
$with_email = true,
$with_availability = false);
}
}