@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Integrate `user.getcurrentstatus` into `user.query`

Summary: D2492#6

Test Plan:
`user.query` of user which is away.
`user.query` of user which is not away.
`user.whoami` - no information there.

Reviewers: epriestley

Reviewed By: epriestley

CC: btrahan, aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2502

vrana fa36dd51 18deff55

+22 -84
-2
src/__phutil_library_map__.php
··· 186 186 'ConduitAPI_user_addstatus_Method' => 'applications/conduit/method/user/addstatus', 187 187 'ConduitAPI_user_disable_Method' => 'applications/conduit/method/user/disable', 188 188 'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find', 189 - 'ConduitAPI_user_getcurrentstatus_Method' => 'applications/conduit/method/user/getcurrentstatus', 190 189 'ConduitAPI_user_info_Method' => 'applications/conduit/method/user/info', 191 190 'ConduitAPI_user_query_Method' => 'applications/conduit/method/user/query', 192 191 'ConduitAPI_user_removestatus_Method' => 'applications/conduit/method/user/removestatus', ··· 1220 1219 'ConduitAPI_user_addstatus_Method' => 'ConduitAPI_user_Method', 1221 1220 'ConduitAPI_user_disable_Method' => 'ConduitAPI_user_Method', 1222 1221 'ConduitAPI_user_find_Method' => 'ConduitAPI_user_Method', 1223 - 'ConduitAPI_user_getcurrentstatus_Method' => 'ConduitAPI_user_Method', 1224 1222 'ConduitAPI_user_info_Method' => 'ConduitAPI_user_Method', 1225 1223 'ConduitAPI_user_query_Method' => 'ConduitAPI_user_Method', 1226 1224 'ConduitAPI_user_removestatus_Method' => 'ConduitAPI_user_Method',
+12 -2
src/applications/conduit/method/user/base/ConduitAPI_user_Method.php
··· 21 21 */ 22 22 abstract class ConduitAPI_user_Method extends ConduitAPIMethod { 23 23 24 - protected function buildUserInformationDictionary(PhabricatorUser $user) { 25 - return array( 24 + protected function buildUserInformationDictionary( 25 + PhabricatorUser $user, 26 + PhabricatorUserStatus $current_status = null) { 27 + 28 + $return = array( 26 29 'phid' => $user->getPHID(), 27 30 'userName' => $user->getUserName(), 28 31 'realName' => $user->getRealName(), 29 32 'image' => $user->loadProfileImageURI(), 30 33 'uri' => PhabricatorEnv::getURI('/p/'.$user->getUsername().'/'), 31 34 ); 35 + 36 + if ($current_status) { 37 + $return['currentStatus'] = $current_status->getTextStatus(); 38 + $return['currentStatusUntil'] = $current_status->getDateTo(); 39 + } 40 + 41 + return $return; 32 42 } 33 43 34 44 }
-63
src/applications/conduit/method/user/getcurrentstatus/ConduitAPI_user_getcurrentstatus_Method.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2012 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - /** 20 - * @group conduit 21 - */ 22 - final class ConduitAPI_user_getcurrentstatus_Method 23 - extends ConduitAPI_user_Method { 24 - 25 - public function getMethodStatus() { 26 - return self::METHOD_STATUS_UNSTABLE; 27 - } 28 - 29 - public function getMethodDescription() { 30 - return "Get current status (away or sporadic) of specified users."; 31 - } 32 - 33 - public function defineParamTypes() { 34 - return array( 35 - 'userPHIDs' => 'required list', 36 - ); 37 - } 38 - 39 - public function defineReturnType() { 40 - return 'dict'; 41 - } 42 - 43 - public function defineErrorTypes() { 44 - return array( 45 - ); 46 - } 47 - 48 - protected function execute(ConduitAPIRequest $request) { 49 - $statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( 50 - $request->getValue('userPHIDs')); 51 - 52 - $return = array(); 53 - foreach ($statuses as $status) { 54 - $return[$status->getUserPHID()] = array( 55 - 'fromEpoch' => $status->getDateFrom(), 56 - 'toEpoch' => $status->getDateTo(), 57 - 'status' => $status->getTextStatus(), 58 - ); 59 - } 60 - return $return; 61 - } 62 - 63 - }
-15
src/applications/conduit/method/user/getcurrentstatus/__init__.php
··· 1 - <?php 2 - /** 3 - * This file is automatically generated. Lint this module to rebuild it. 4 - * @generated 5 - */ 6 - 7 - 8 - 9 - phutil_require_module('phabricator', 'applications/conduit/method/user/base'); 10 - phutil_require_module('phabricator', 'applications/people/storage/userstatus'); 11 - 12 - phutil_require_module('phutil', 'utils'); 13 - 14 - 15 - phutil_require_source('ConduitAPI_user_getcurrentstatus_Method.php');
+7 -2
src/applications/conduit/method/user/query/ConduitAPI_user_query_Method.php
··· 64 64 $query->withUsernames($usernames); 65 65 } 66 66 if ($emails) { 67 - // TODO -- validate emails and maybs 67 + // TODO -- validate emails and maybe 68 68 // throw new ConduitException('ERR-INVALID-PARAMETER'); 69 69 $query->withEmails($emails); 70 70 } ··· 85 85 } 86 86 $users = $query->execute(); 87 87 88 + $statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( 89 + mpull($users, 'getPHID')); 90 + 88 91 $results = array(); 89 92 foreach ($users as $user) { 90 - $results[] = $this->buildUserInformationDictionary($user); 93 + $results[] = $this->buildUserInformationDictionary( 94 + $user, 95 + idx($statuses, $user->getPHID())); 91 96 } 92 97 return $results; 93 98 }
+3
src/applications/conduit/method/user/query/__init__.php
··· 8 8 9 9 phutil_require_module('phabricator', 'applications/conduit/method/user/base'); 10 10 phutil_require_module('phabricator', 'applications/people/query'); 11 + phutil_require_module('phabricator', 'applications/people/storage/userstatus'); 12 + 13 + phutil_require_module('phutil', 'utils'); 11 14 12 15 13 16 phutil_require_source('ConduitAPI_user_query_Method.php');