1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-26 23:40:57 +01:00

Remove "PhabricatorEventType::TYPE_DIFFUSION_LOOKUPUSER" event

Summary: Ref T13444. This is an ancient event and part of the old event system. It is not likely to be in use anymore, and repository identities should generally replace it nowadays anyway.

Test Plan: Grepped for constant and related methods, no longer found any hits.

Maniphest Tasks: T13444

Differential Revision: https://secure.phabricator.com/D20909
This commit is contained in:
epriestley 2019-11-13 20:22:48 -08:00
parent a2b2c391a1
commit 6afbb6102d
6 changed files with 8 additions and 66 deletions

View file

@ -8,25 +8,14 @@
final class DiffusionResolveUserQuery extends Phobject {
private $name;
private $commit;
public function withName($name) {
$this->name = $name;
return $this;
}
public function withCommit($commit) {
$this->commit = $commit;
return $this;
}
public function execute() {
$user_name = $this->name;
$phid = $this->findUserPHID($this->name);
$phid = $this->fireLookupEvent($phid);
return $phid;
return $this->findUserPHID($this->name);
}
private function findUserPHID($user_name) {
@ -75,33 +64,15 @@ final class DiffusionResolveUserQuery extends Phobject {
}
/**
* Emit an event so installs can do custom lookup of commit authors who may
* not be naturally resolvable.
*/
private function fireLookupEvent($guess) {
$type = PhabricatorEventType::TYPE_DIFFUSION_LOOKUPUSER;
$data = array(
'commit' => $this->commit,
'query' => $this->name,
'result' => $guess,
);
$event = new PhabricatorEvent($type, $data);
PhutilEventEngine::dispatchEvent($event);
return $event->getValue('result');
}
private function findUserByUserName($user_name) {
$by_username = id(new PhabricatorUser())->loadOneWhere(
'userName = %s',
$user_name);
if ($by_username) {
return $by_username->getPHID();
}
return null;
}
@ -112,18 +83,22 @@ final class DiffusionResolveUserQuery extends Phobject {
$by_realname = id(new PhabricatorUser())->loadAllWhere(
'realName = %s',
$real_name);
if (count($by_realname) == 1) {
return reset($by_realname)->getPHID();
return head($by_realname)->getPHID();
}
return null;
}
private function findUserByEmailAddress($email_address) {
$by_email = PhabricatorUser::loadOneWithEmailAddress($email_address);
if ($by_email) {
return $by_email->getPHID();
}
return null;
}

View file

@ -99,7 +99,6 @@ final class PhabricatorRepositoryManagementLookupUsersWorkflow
private function resolveUser(PhabricatorRepositoryCommit $commit, $name) {
$phid = id(new DiffusionResolveUserQuery())
->withCommit($commit)
->withName($name)
->execute();

View file

@ -101,7 +101,6 @@ final class PhabricatorRepositoryManagementRebuildIdentitiesWorkflow
if (empty($seen[$identity_key])) {
try {
$user_phid = id(new DiffusionResolveUserQuery())
->withCommit($commit)
->withName($identity_name)
->execute();

View file

@ -182,7 +182,6 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
$user_name) {
return id(new DiffusionResolveUserQuery())
->withCommit($commit)
->withName($user_name)
->execute();
}

View file

@ -159,35 +159,6 @@ will be available yet. Data available on this event:
- `repository` The @{class:PhabricatorRepository} the commit was discovered
in.
== Diffusion: Lookup User ==
The constant for this event is
`PhabricatorEventType::TYPE_DIFFUSION_LOOKUPUSER`.
This event is dispatched when the daemons are trying to link a commit to a
Phabricator user account. You can listen for it to improve the accuracy of
associating users with their commits.
By default, Phabricator will try to find matches based on usernames, real names,
or email addresses, but this can result in incorrect matches (e.g., if you have
several employees with the same name) or failures to match (e.g., if someone
changed their email address). Listening for this event allows you to intercept
the lookup and supplement the results from another datasource.
Data available on this event:
- `commit` The @{class:PhabricatorRepositoryCommit} that data is being looked
up for.
- `query` The author or committer string being looked up. This will usually
be something like "Abraham Lincoln <alincoln@logcabin.example.com>", but
comes from the commit metadata so it may not be well-formatted.
- `result` The current result from the lookup (Phabricator's best guess at
the user PHID of the user named in the "query"). To substitute the result
with a different result, replace this with the correct PHID in your event
listener.
Using @{class@libphutil:PhutilEmailAddress} may be helpful in parsing the query.
== Test: Did Run Test ==
The constant for this event is

View file

@ -9,7 +9,6 @@ final class PhabricatorEventType extends PhutilEventType {
const TYPE_DIFFERENTIAL_WILLMARKGENERATED = 'differential.willMarkGenerated';
const TYPE_DIFFUSION_DIDDISCOVERCOMMIT = 'diffusion.didDiscoverCommit';
const TYPE_DIFFUSION_LOOKUPUSER = 'diffusion.lookupUser';
const TYPE_TEST_DIDRUNTEST = 'test.didRunTest';