Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/query/PhabricatorMetaMTAMailQuery.php
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | ||||
if ($this->recipientPHIDs !== null) { | if ($this->recipientPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'recipient.dst IN (%Ls)', | 'recipient.dst IN (%Ls)', | ||||
$this->recipientPHIDs); | $this->recipientPHIDs); | ||||
} | } | ||||
if ($this->actorPHIDs === null && $this->recipientPHIDs === null) { | |||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'edge.dst = %s OR actorPHID = %s', | 'edge.dst = %s OR actorPHID = %s', | ||||
$viewer->getPHID(), | $viewer->getPHID(), | ||||
$viewer->getPHID()); | $viewer->getPHID()); | ||||
} | |||||
$where[] = $this->buildPagingClause($conn_r); | $where[] = $this->buildPagingClause($conn_r); | ||||
return $this->formatWhereClause($where); | return $this->formatWhereClause($where); | ||||
} | } | ||||
protected function buildJoinClause(AphrontDatabaseConnection $conn) { | protected function buildJoinClause(AphrontDatabaseConnection $conn) { | ||||
$joins = array(); | $joins = array(); | ||||
if ($this->actorPHIDs === null && $this->recipientPHIDs === null) { | |||||
$joins[] = qsprintf( | $joins[] = qsprintf( | ||||
$conn, | $conn, | ||||
'LEFT JOIN %T edge ON mail.phid = edge.src AND edge.type = %d', | 'LEFT JOIN %T edge ON mail.phid = edge.src AND edge.type = %d', | ||||
PhabricatorEdgeConfig::TABLE_NAME_EDGE, | PhabricatorEdgeConfig::TABLE_NAME_EDGE, | ||||
PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST); | PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST); | ||||
} | |||||
if ($this->recipientPHIDs !== null) { | if ($this->recipientPHIDs !== null) { | ||||
$joins[] = qsprintf( | $joins[] = qsprintf( | ||||
$conn, | $conn, | ||||
'LEFT JOIN %T recipient '. | 'LEFT JOIN %T recipient '. | ||||
'ON mail.phid = recipient.src AND recipient.type = %d', | 'ON mail.phid = recipient.src AND recipient.type = %d', | ||||
PhabricatorEdgeConfig::TABLE_NAME_EDGE, | PhabricatorEdgeConfig::TABLE_NAME_EDGE, | ||||
PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST); | PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST); | ||||
Show All 18 Lines |