Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php
| Show All 30 Lines | public function execute() { | ||||
| // TODO: Move this to PhabricatorPHIDType, or the objects, or some | // TODO: Move this to PhabricatorPHIDType, or the objects, or some | ||||
| // interface. | // interface. | ||||
| foreach ($type_map as $type => $phids) { | foreach ($type_map as $type => $phids) { | ||||
| switch ($type) { | switch ($type) { | ||||
| case PhabricatorPeopleUserPHIDType::TYPECONST: | case PhabricatorPeopleUserPHIDType::TYPECONST: | ||||
| $this->loadUserActors($actors, $phids); | $this->loadUserActors($actors, $phids); | ||||
| break; | break; | ||||
| case PhabricatorPeopleExternalPHIDType::TYPECONST: | |||||
| $this->loadExternalUserActors($actors, $phids); | |||||
| break; | |||||
| default: | default: | ||||
| $this->loadUnknownActors($actors, $phids); | $this->loadUnknownActors($actors, $phids); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| return $actors; | return $actors; | ||||
| } | } | ||||
| Show All 39 Lines | foreach ($phids as $phid) { | ||||
| $actor->setUndeliverable(PhabricatorMetaMTAActor::REASON_NO_ADDRESS); | $actor->setUndeliverable(PhabricatorMetaMTAActor::REASON_NO_ADDRESS); | ||||
| } else { | } else { | ||||
| $actor->setEmailAddress($email->getAddress()); | $actor->setEmailAddress($email->getAddress()); | ||||
| $actor->setIsVerified($email->getIsVerified()); | $actor->setIsVerified($email->getIsVerified()); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| private function loadExternalUserActors(array $actors, array $phids) { | |||||
| assert_instances_of($actors, 'PhabricatorMetaMTAActor'); | |||||
| $xusers = id(new PhabricatorExternalAccountQuery()) | |||||
| ->setViewer($this->getViewer()) | |||||
| ->withPHIDs($phids) | |||||
| ->execute(); | |||||
| $xusers = mpull($xusers, null, 'getPHID'); | |||||
| foreach ($phids as $phid) { | |||||
| $actor = $actors[$phid]; | |||||
| $xuser = idx($xusers, $phid); | |||||
| if (!$xuser) { | |||||
| $actor->setUndeliverable(PhabricatorMetaMTAActor::REASON_UNLOADABLE); | |||||
| continue; | |||||
| } | |||||
| $actor->setName($xuser->getDisplayName()); | |||||
| if ($xuser->getAccountType() != 'email') { | |||||
| $actor->setUndeliverable(PhabricatorMetaMTAActor::REASON_EXTERNAL_TYPE); | |||||
| continue; | |||||
| } | |||||
| $actor->setEmailAddress($xuser->getAccountID()); | |||||
| // Circa T7477, it appears that we never intentionally send email to | |||||
| // external users (even when they email "bugs@" to create a task). | |||||
| // Mark these users as unverified so mail to them is always dropped. | |||||
| // See also T12237. In the future, we might change this behavior. | |||||
| $actor->setIsVerified(false); | |||||
| } | |||||
| } | |||||
| private function loadUnknownActors(array $actors, array $phids) { | private function loadUnknownActors(array $actors, array $phids) { | ||||
| foreach ($phids as $phid) { | foreach ($phids as $phid) { | ||||
| $actor = $actors[$phid]; | $actor = $actors[$phid]; | ||||
| $actor->setUndeliverable(PhabricatorMetaMTAActor::REASON_UNMAILABLE); | $actor->setUndeliverable(PhabricatorMetaMTAActor::REASON_UNMAILABLE); | ||||
| } | } | ||||
| } | } | ||||
| Show All 25 Lines | |||||