From f76ecd9e764c04eaa5dd0956030cffc2ed286da8 Mon Sep 17 00:00:00 2001 From: Afaque Hussain Date: Mon, 6 May 2013 11:34:48 -0700 Subject: [PATCH] Adding Handle Suport Summary: Added PHID_TYPE_XUSR to loadObjectsofType() of PhabricatorObjectHandle data. Was trying to solve the setActor() issue. Created a getPhabricator method in PhabricatorExternalAccount. When I try to set authorPHID using setAuthorPHID() in PhabricatorExternalAccount it's saying bad setter call, if I don't, then it's saying authorPHID can't be null. Sending you diff for comments on this. Test Plan: {F42523} {F42525} Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, AnhNhan Differential Revision: https://secure.phabricator.com/D5839 --- .../PhabricatorMetaMTAReceivedMail.php | 4 ++-- .../storage/PhabricatorExternalAccount.php | 7 ++++++ .../handle/PhabricatorObjectHandleData.php | 24 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php index c2418370a6..67b17c9069 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php @@ -260,10 +260,10 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO { $receiver->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE); $editor = new ManiphestTransactionEditor(); - $editor->setActor($user); + $editor->setActor($user->getPhabricatorUser()); $handler = $editor->buildReplyHandler($receiver); - $handler->setActor($user); + $handler->setActor($user->getPhabricatorUser()); $handler->setExcludeMailRecipientPHIDs( $this->loadExcludeMailRecipientPHIDs()); $handler->processEmail($this); diff --git a/src/applications/people/storage/PhabricatorExternalAccount.php b/src/applications/people/storage/PhabricatorExternalAccount.php index cffffdb482..0f0e9ef92b 100644 --- a/src/applications/people/storage/PhabricatorExternalAccount.php +++ b/src/applications/people/storage/PhabricatorExternalAccount.php @@ -20,4 +20,11 @@ final class PhabricatorExternalAccount extends PhabricatorUserDAO { ) + parent::getConfiguration(); } + public function getPhabricatorUser() { + $tmp_usr = id(new PhabricatorUser()) + ->makeEphemeral() + ->setPHID($this->getPHID()); + return $tmp_usr; + } + } diff --git a/src/applications/phid/handle/PhabricatorObjectHandleData.php b/src/applications/phid/handle/PhabricatorObjectHandleData.php index 2a9743a1d1..c018e65a1e 100644 --- a/src/applications/phid/handle/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/PhabricatorObjectHandleData.php @@ -205,6 +205,13 @@ final class PhabricatorObjectHandleData { ->execute(); return mpull($vars, null, 'getPHID'); + case PhabricatorPHIDConstants::PHID_TYPE_XUSR: + $xusr_dao = new PhabricatorExternalAccount(); + $xusrs = $xusr_dao->loadAllWhere( + 'phid in (%Ls)', + $phids); + return mpull($xusrs, null, 'getPHID'); + } } @@ -681,6 +688,23 @@ final class PhabricatorObjectHandleData { } break; + case PhabricatorPHIDConstants::PHID_TYPE_XUSR: + foreach ($phids as $phid) { + $handle = new PhabricatorObjectHandle(); + $handle->setPHID($phid); + $handle->setType($type); + if (empty($objects[$phid])) { + $handle->setName('Unknown Display Name'); + } else { + $xusr = $objects[$phid]; + $display_name = $xusr->getDisplayName(); + $handle->setName($display_name); + $handle->setFullName($display_name.' (External User)'); + } + $handles[$phid] = $handle; + } + break; + default: $loader = null; if (isset($external_loaders[$type])) {