diff --git a/src/applications/people/conduit/UserConduitAPIMethod.php b/src/applications/people/conduit/UserConduitAPIMethod.php index 82da171f43..187e28b9b3 100644 --- a/src/applications/people/conduit/UserConduitAPIMethod.php +++ b/src/applications/people/conduit/UserConduitAPIMethod.php @@ -1,60 +1,68 @@ getIsDisabled()) { $roles[] = 'disabled'; } if ($user->getIsSystemAgent()) { $roles[] = 'agent'; } if ($user->getIsAdmin()) { $roles[] = 'admin'; } $primary = $user->loadPrimaryEmail(); if ($primary && $primary->getIsVerified()) { $email = $primary->getAddress(); $roles[] = 'verified'; } else { $email = null; $roles[] = 'unverified'; } if ($user->getIsApproved()) { $roles[] = 'approved'; } if ($user->isUserActivated()) { $roles[] = 'activated'; } $return = array( '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; } } diff --git a/src/applications/people/conduit/UserQueryConduitAPIMethod.php b/src/applications/people/conduit/UserQueryConduitAPIMethod.php index c480ae0c73..4a567a0158 100644 --- a/src/applications/people/conduit/UserQueryConduitAPIMethod.php +++ b/src/applications/people/conduit/UserQueryConduitAPIMethod.php @@ -1,79 +1,82 @@ 'optional list', 'emails' => 'optional list', 'realnames' => 'optional list', 'phids' => 'optional list', 'ids' => 'optional list', 'offset' => 'optional int', 'limit' => 'optional int (default = 100)', ); } protected function defineReturnType() { return 'list'; } protected function defineErrorTypes() { return array( 'ERR-INVALID-PARAMETER' => 'Missing or malformed parameter.', ); } protected function execute(ConduitAPIRequest $request) { $usernames = $request->getValue('usernames', array()); $emails = $request->getValue('emails', array()); $realnames = $request->getValue('realnames', array()); $phids = $request->getValue('phids', array()); $ids = $request->getValue('ids', array()); $offset = $request->getValue('offset', 0); $limit = $request->getValue('limit', 100); $query = id(new PhabricatorPeopleQuery()) ->setViewer($request->getUser()) ->needProfileImage(true) ->needAvailability(true); if ($usernames) { $query->withUsernames($usernames); } if ($emails) { $query->withEmails($emails); } if ($realnames) { $query->withRealnames($realnames); } if ($phids) { $query->withPHIDs($phids); } if ($ids) { $query->withIDs($ids); } if ($limit) { $query->setLimit($limit); } if ($offset) { $query->setOffset($offset); } $users = $query->execute(); $results = array(); foreach ($users as $user) { - $results[] = $this->buildUserInformationDictionary($user); + $results[] = $this->buildUserInformationDictionary( + $user, + $with_email = false, + $with_availability = true); } return $results; } } diff --git a/src/applications/people/conduit/UserWhoAmIConduitAPIMethod.php b/src/applications/people/conduit/UserWhoAmIConduitAPIMethod.php index aa7e3e7f26..b646246c5d 100644 --- a/src/applications/people/conduit/UserWhoAmIConduitAPIMethod.php +++ b/src/applications/people/conduit/UserWhoAmIConduitAPIMethod.php @@ -1,35 +1,38 @@ '; } public function getRequiredScope() { return PhabricatorOAuthServerScope::SCOPE_WHOAMI; } protected function execute(ConduitAPIRequest $request) { $person = id(new PhabricatorPeopleQuery()) ->setViewer($request->getUser()) ->needProfileImage(true) ->withPHIDs(array($request->getUser()->getPHID())) ->executeOne(); - return $this->buildUserInformationDictionary($person); + return $this->buildUserInformationDictionary( + $person, + $with_email = true, + $with_availability = false); } }