Page MenuHomePhabricator

D11546.id.diff
No OneTemporary

D11546.id.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1953,6 +1953,7 @@
'PhabricatorMetaMTAActorQuery' => 'applications/metamta/query/PhabricatorMetaMTAActorQuery.php',
'PhabricatorMetaMTAApplication' => 'applications/metamta/application/PhabricatorMetaMTAApplication.php',
'PhabricatorMetaMTAApplicationEmail' => 'applications/metamta/storage/PhabricatorMetaMTAApplicationEmail.php',
+ 'PhabricatorMetaMTAApplicationEmailDatasource' => 'applications/metamta/typeahead/PhabricatorMetaMTAApplicationEmailDatasource.php',
'PhabricatorMetaMTAApplicationEmailPHIDType' => 'applications/phid/PhabricatorMetaMTAApplicationEmailPHIDType.php',
'PhabricatorMetaMTAApplicationEmailQuery' => 'applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php',
'PhabricatorMetaMTAAttachment' => 'applications/metamta/storage/PhabricatorMetaMTAAttachment.php',
@@ -5184,6 +5185,7 @@
'PhabricatorMetaMTADAO',
'PhabricatorPolicyInterface',
),
+ 'PhabricatorMetaMTAApplicationEmailDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorMetaMTAApplicationEmailPHIDType' => 'PhabricatorPHIDType',
'PhabricatorMetaMTAApplicationEmailQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorMetaMTAConfigOptions' => 'PhabricatorApplicationConfigOptions',
diff --git a/src/applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php b/src/applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php
--- a/src/applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php
+++ b/src/applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php
@@ -6,6 +6,7 @@
private $ids;
private $phids;
private $addresses;
+ private $addressPrefix;
private $applicationPHIDs;
public function withIDs(array $ids) {
@@ -23,6 +24,11 @@
return $this;
}
+ public function withAddressPrefix($prefix) {
+ $this->addressPrefix = $prefix;
+ return $this;
+ }
+
public function withApplicationPHIDs(array $phids) {
$this->applicationPHIDs = $phids;
return $this;
@@ -75,6 +81,13 @@
$this->addresses);
}
+ if ($this->addressPrefix !== null) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'appemail.address LIKE %>',
+ $this->addressPrefix);
+ }
+
if ($this->applicationPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
diff --git a/src/applications/metamta/typeahead/PhabricatorMetaMTAApplicationEmailDatasource.php b/src/applications/metamta/typeahead/PhabricatorMetaMTAApplicationEmailDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/metamta/typeahead/PhabricatorMetaMTAApplicationEmailDatasource.php
@@ -0,0 +1,43 @@
+<?php
+
+final class PhabricatorMetaMTAApplicationEmailDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getPlaceholderText() {
+ return pht('Type an application email address...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorMetaMTAApplication';
+ }
+
+ public function loadResults() {
+ $viewer = $this->getViewer();
+ $raw_query = $this->getRawQuery();
+
+ $emails = id(new PhabricatorMetaMTAApplicationEmailQuery())
+ ->setViewer($viewer)
+ ->withAddressPrefix($raw_query)
+ ->setLimit($this->getLimit())
+ ->execute();
+
+ if ($emails) {
+ $handles = id(new PhabricatorHandleQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(mpull($emails, 'getPHID'))
+ ->execute();
+ } else {
+ $handles = array();
+ }
+
+ $results = array();
+ foreach ($handles as $handle) {
+ $results[] = id(new PhabricatorTypeaheadResult())
+ ->setName($handle->getName())
+ ->setPHID($handle->getPHID());
+ }
+
+ return $results;
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Wed, Oct 16, 7:39 AM (1 d, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6716608
Default Alt Text
D11546.id.diff (3 KB)

Event Timeline