1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Add loadObject() methods to PhabricatorObjectMailReceiver subclasses

Summary: This doesn't do anything, but touches a bunch of files so I split it out to reduce the size of the next diff. Basically, make `MailReceiver` classes responsible for loading their application objects. Ref T1205.

Test Plan: Inspection / next diff / code is not reached.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1205

Differential Revision: https://secure.phabricator.com/D5941
This commit is contained in:
epriestley 2013-05-17 03:47:46 -07:00
parent 4ba86e7205
commit bb0a39a48c
9 changed files with 95 additions and 0 deletions

View file

@ -11,4 +11,13 @@ final class PhabricatorAuditMailReceiver extends PhabricatorObjectMailReceiver {
return 'C[1-9]\d*';
}
protected function loadObject($pattern, PhabricatorUser $viewer) {
$id = (int)trim($pattern, 'C');
return id(new DiffusionCommitQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
}
}

View file

@ -12,4 +12,14 @@ final class ConpherenceThreadMailReceiver
return 'E[1-9]\d*';
}
protected function loadObject($pattern, PhabricatorUser $viewer) {
$id = (int)trim($pattern, 'E');
return id(new ConpherenceThreadQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
}
}

View file

@ -12,4 +12,16 @@ final class DifferentialRevisionMailReceiver
return 'D[1-9]\d*';
}
protected function loadObject($pattern, PhabricatorUser $viewer) {
$id = (int)trim($pattern, 'D');
$results = id(new DifferentialRevisionQuery())
->setViewer($viewer)
->withIDs(array($id))
->execute();
return head($results);
}
}

View file

@ -11,4 +11,14 @@ final class PhabricatorMacroMailReceiver extends PhabricatorObjectMailReceiver {
return 'MCRO[1-9]\d*';
}
protected function loadObject($pattern, PhabricatorUser $viewer) {
$id = (int)substr($pattern, 4);
return id(new PhabricatorMacroQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
}
}

View file

@ -11,4 +11,15 @@ final class ManiphestTaskMailReceiver extends PhabricatorObjectMailReceiver {
return 'T[1-9]\d*';
}
protected function loadObject($pattern, PhabricatorUser $viewer) {
$id = (int)trim($pattern, 'T');
$results = id(new ManiphestTaskQuery())
->setViewer($viewer)
->withTaskIDs(array($id))
->execute();
return head($results);
}
}

View file

@ -11,4 +11,14 @@ final class PholioMockMailReceiver extends PhabricatorObjectMailReceiver {
return 'M[1-9]\d*';
}
protected function loadObject($pattern, PhabricatorUser $viewer) {
$id = (int)trim($pattern, 'M');
return id(new PholioMockQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
}
}

View file

@ -11,4 +11,14 @@ final class PonderQuestionMailReceiver extends PhabricatorObjectMailReceiver {
return 'Q[1-9]\d*';
}
protected function loadObject($pattern, PhabricatorUser $viewer) {
$id = (int)trim($pattern, 'Q');
return id(new PonderQuestionQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
}
}

View file

@ -11,4 +11,14 @@ final class ReleephRequestMailReceiver extends PhabricatorObjectMailReceiver {
return 'RQ[1-9]\d*';
}
protected function loadObject($pattern, PhabricatorUser $viewer) {
$id = (int)substr($pattern, 2);
return id(new ReleephRequestQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
}
}

View file

@ -5,6 +5,12 @@ final class ReleephRequestQuery
private $requestedCommitPHIDs;
private $commitToRevMap;
private $ids;
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;
}
public function getRevisionPHID($commit_phid) {
if ($this->commitToRevMap) {
@ -56,6 +62,13 @@ final class ReleephRequestQuery
private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
if ($this->ids) {
$where[] = qsprintf(
$conn_r,
'id IN (%Ld)',
$this->ids);
}
if ($this->requestedCommitPHIDs) {
$where[] = qsprintf(
$conn_r,