Differential D20911 Diff 49833 src/applications/diffusion/identity/DiffusionRepositoryIdentityEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/identity/DiffusionRepositoryIdentityEngine.php
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | private function resolveIdentity(PhabricatorRepositoryIdentity $identity) { | ||||
$raw_identity = $identity->getIdentityName(); | $raw_identity = $identity->getIdentityName(); | ||||
return id(new DiffusionResolveUserQuery()) | return id(new DiffusionResolveUserQuery()) | ||||
->withName($raw_identity) | ->withName($raw_identity) | ||||
->execute(); | ->execute(); | ||||
} | } | ||||
private function updateIdentity(PhabricatorRepositoryIdentity $identity) { | private function updateIdentity(PhabricatorRepositoryIdentity $identity) { | ||||
// If we're updating an identity and it has a manual user PHID associated | |||||
// with it but the user is no longer valid, remove the value. This likely | |||||
// corresponds to a user that was destroyed. | |||||
$assigned_phid = $identity->getManuallySetUserPHID(); | |||||
$unassigned = DiffusionIdentityUnassignedDatasource::FUNCTION_TOKEN; | |||||
if ($assigned_phid && ($assigned_phid !== $unassigned)) { | |||||
$viewer = $this->getViewer(); | |||||
$user = id(new PhabricatorPeopleQuery()) | |||||
->setViewer($viewer) | |||||
->withPHIDs(array($assigned_phid)) | |||||
->executeOne(); | |||||
if (!$user) { | |||||
$identity->setManuallySetUserPHID(null); | |||||
} | |||||
} | |||||
$resolved_phid = $this->resolveIdentity($identity); | $resolved_phid = $this->resolveIdentity($identity); | ||||
$identity | $identity | ||||
->setAutomaticGuessedUserPHID($resolved_phid) | ->setAutomaticGuessedUserPHID($resolved_phid) | ||||
->save(); | ->save(); | ||||
return $identity; | return $identity; | ||||
} | } | ||||
} | } |