Page MenuHomestyx hydra

No OneTemporary

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 @@
<?php
abstract class UserConduitAPIMethod extends ConduitAPIMethod {
final public function getApplication() {
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()) {
$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 @@
<?php
final class UserQueryConduitAPIMethod extends UserConduitAPIMethod {
public function getAPIMethodName() {
return 'user.query';
}
public function getMethodDescription() {
return 'Query users.';
}
protected function defineParamTypes() {
return array(
'usernames' => 'optional list<string>',
'emails' => 'optional list<string>',
'realnames' => 'optional list<string>',
'phids' => 'optional list<phid>',
'ids' => 'optional list<uint>',
'offset' => 'optional int',
'limit' => 'optional int (default = 100)',
);
}
protected function defineReturnType() {
return 'list<dict>';
}
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 @@
<?php
final class UserWhoAmIConduitAPIMethod extends UserConduitAPIMethod {
public function getAPIMethodName() {
return 'user.whoami';
}
public function getMethodDescription() {
return 'Retrieve information about the logged-in user.';
}
protected function defineParamTypes() {
return array();
}
protected function defineReturnType() {
return 'nonempty dict<string, wild>';
}
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);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Dec 3, 11:20 AM (12 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
433301
Default Alt Text
(6 KB)

Event Timeline