diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 4d4e6d2dd8..82764cb217 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -186,7 +186,6 @@ phutil_register_library_map(array( 'ConduitAPI_user_addstatus_Method' => 'applications/conduit/method/user/addstatus', 'ConduitAPI_user_disable_Method' => 'applications/conduit/method/user/disable', 'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find', - 'ConduitAPI_user_getcurrentstatus_Method' => 'applications/conduit/method/user/getcurrentstatus', 'ConduitAPI_user_info_Method' => 'applications/conduit/method/user/info', 'ConduitAPI_user_query_Method' => 'applications/conduit/method/user/query', 'ConduitAPI_user_removestatus_Method' => 'applications/conduit/method/user/removestatus', @@ -1220,7 +1219,6 @@ phutil_register_library_map(array( 'ConduitAPI_user_addstatus_Method' => 'ConduitAPI_user_Method', 'ConduitAPI_user_disable_Method' => 'ConduitAPI_user_Method', 'ConduitAPI_user_find_Method' => 'ConduitAPI_user_Method', - 'ConduitAPI_user_getcurrentstatus_Method' => 'ConduitAPI_user_Method', 'ConduitAPI_user_info_Method' => 'ConduitAPI_user_Method', 'ConduitAPI_user_query_Method' => 'ConduitAPI_user_Method', 'ConduitAPI_user_removestatus_Method' => 'ConduitAPI_user_Method', diff --git a/src/applications/conduit/method/user/base/ConduitAPI_user_Method.php b/src/applications/conduit/method/user/base/ConduitAPI_user_Method.php index b126358713..3c32e7ee5f 100644 --- a/src/applications/conduit/method/user/base/ConduitAPI_user_Method.php +++ b/src/applications/conduit/method/user/base/ConduitAPI_user_Method.php @@ -21,14 +21,24 @@ */ abstract class ConduitAPI_user_Method extends ConduitAPIMethod { - protected function buildUserInformationDictionary(PhabricatorUser $user) { - return array( + protected function buildUserInformationDictionary( + PhabricatorUser $user, + PhabricatorUserStatus $current_status = null) { + + $return = array( 'phid' => $user->getPHID(), 'userName' => $user->getUserName(), 'realName' => $user->getRealName(), 'image' => $user->loadProfileImageURI(), 'uri' => PhabricatorEnv::getURI('/p/'.$user->getUsername().'/'), ); + + if ($current_status) { + $return['currentStatus'] = $current_status->getTextStatus(); + $return['currentStatusUntil'] = $current_status->getDateTo(); + } + + return $return; } } diff --git a/src/applications/conduit/method/user/getcurrentstatus/ConduitAPI_user_getcurrentstatus_Method.php b/src/applications/conduit/method/user/getcurrentstatus/ConduitAPI_user_getcurrentstatus_Method.php deleted file mode 100644 index 6f43e8c868..0000000000 --- a/src/applications/conduit/method/user/getcurrentstatus/ConduitAPI_user_getcurrentstatus_Method.php +++ /dev/null @@ -1,63 +0,0 @@ - 'required list', - ); - } - - public function defineReturnType() { - return 'dict'; - } - - public function defineErrorTypes() { - return array( - ); - } - - protected function execute(ConduitAPIRequest $request) { - $statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( - $request->getValue('userPHIDs')); - - $return = array(); - foreach ($statuses as $status) { - $return[$status->getUserPHID()] = array( - 'fromEpoch' => $status->getDateFrom(), - 'toEpoch' => $status->getDateTo(), - 'status' => $status->getTextStatus(), - ); - } - return $return; - } - -} diff --git a/src/applications/conduit/method/user/getcurrentstatus/__init__.php b/src/applications/conduit/method/user/getcurrentstatus/__init__.php deleted file mode 100644 index 66159193d6..0000000000 --- a/src/applications/conduit/method/user/getcurrentstatus/__init__.php +++ /dev/null @@ -1,15 +0,0 @@ -withUsernames($usernames); } if ($emails) { - // TODO -- validate emails and maybs + // TODO -- validate emails and maybe // throw new ConduitException('ERR-INVALID-PARAMETER'); $query->withEmails($emails); } @@ -85,9 +85,14 @@ final class ConduitAPI_user_query_Method } $users = $query->execute(); + $statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( + mpull($users, 'getPHID')); + $results = array(); foreach ($users as $user) { - $results[] = $this->buildUserInformationDictionary($user); + $results[] = $this->buildUserInformationDictionary( + $user, + idx($statuses, $user->getPHID())); } return $results; } diff --git a/src/applications/conduit/method/user/query/__init__.php b/src/applications/conduit/method/user/query/__init__.php index 22b6e03e38..2f288fc6fa 100644 --- a/src/applications/conduit/method/user/query/__init__.php +++ b/src/applications/conduit/method/user/query/__init__.php @@ -8,6 +8,9 @@ phutil_require_module('phabricator', 'applications/conduit/method/user/base'); phutil_require_module('phabricator', 'applications/people/query'); +phutil_require_module('phabricator', 'applications/people/storage/userstatus'); + +phutil_require_module('phutil', 'utils'); phutil_require_source('ConduitAPI_user_query_Method.php');