Page MenuHomePhabricator

D19950.diff
No OneTemporary

D19950.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
@@ -2111,6 +2111,7 @@
'PhabricatorApplicationEditHTTPParameterHelpView' => 'applications/transactions/view/PhabricatorApplicationEditHTTPParameterHelpView.php',
'PhabricatorApplicationEditor' => 'applications/meta/editor/PhabricatorApplicationEditor.php',
'PhabricatorApplicationEmailCommandsController' => 'applications/meta/controller/PhabricatorApplicationEmailCommandsController.php',
+ 'PhabricatorApplicationMailReceiver' => 'applications/metamta/receiver/PhabricatorApplicationMailReceiver.php',
'PhabricatorApplicationObjectMailEngineExtension' => 'applications/transactions/engineextension/PhabricatorApplicationObjectMailEngineExtension.php',
'PhabricatorApplicationPanelController' => 'applications/meta/controller/PhabricatorApplicationPanelController.php',
'PhabricatorApplicationPolicyChangeTransaction' => 'applications/meta/xactions/PhabricatorApplicationPolicyChangeTransaction.php',
@@ -5852,7 +5853,7 @@
'DifferentialCreateCommentConduitAPIMethod' => 'DifferentialConduitAPIMethod',
'DifferentialCreateDiffConduitAPIMethod' => 'DifferentialConduitAPIMethod',
'DifferentialCreateInlineConduitAPIMethod' => 'DifferentialConduitAPIMethod',
- 'DifferentialCreateMailReceiver' => 'PhabricatorMailReceiver',
+ 'DifferentialCreateMailReceiver' => 'PhabricatorApplicationMailReceiver',
'DifferentialCreateRawDiffConduitAPIMethod' => 'DifferentialConduitAPIMethod',
'DifferentialCreateRevisionConduitAPIMethod' => 'DifferentialConduitAPIMethod',
'DifferentialCustomField' => 'PhabricatorCustomField',
@@ -6704,7 +6705,7 @@
'FeedStoryNotificationGarbageCollector' => 'PhabricatorGarbageCollector',
'FileAllocateConduitAPIMethod' => 'FileConduitAPIMethod',
'FileConduitAPIMethod' => 'ConduitAPIMethod',
- 'FileCreateMailReceiver' => 'PhabricatorMailReceiver',
+ 'FileCreateMailReceiver' => 'PhabricatorApplicationMailReceiver',
'FileDeletionWorker' => 'PhabricatorWorker',
'FileDownloadConduitAPIMethod' => 'FileConduitAPIMethod',
'FileInfoConduitAPIMethod' => 'FileConduitAPIMethod',
@@ -7232,7 +7233,7 @@
),
'ManiphestConstants' => 'Phobject',
'ManiphestController' => 'PhabricatorController',
- 'ManiphestCreateMailReceiver' => 'PhabricatorMailReceiver',
+ 'ManiphestCreateMailReceiver' => 'PhabricatorApplicationMailReceiver',
'ManiphestCreateTaskConduitAPIMethod' => 'ManiphestConduitAPIMethod',
'ManiphestCustomField' => 'PhabricatorCustomField',
'ManiphestCustomFieldNumericIndex' => 'PhabricatorCustomFieldNumericIndexStorage',
@@ -7679,7 +7680,7 @@
'PassphraseTokenCredentialType' => 'PassphraseCredentialType',
'PasteConduitAPIMethod' => 'ConduitAPIMethod',
'PasteCreateConduitAPIMethod' => 'PasteConduitAPIMethod',
- 'PasteCreateMailReceiver' => 'PhabricatorMailReceiver',
+ 'PasteCreateMailReceiver' => 'PhabricatorApplicationMailReceiver',
'PasteDefaultEditCapability' => 'PhabricatorPolicyCapability',
'PasteDefaultViewCapability' => 'PhabricatorPolicyCapability',
'PasteEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
@@ -7740,6 +7741,7 @@
'PhabricatorApplicationEditHTTPParameterHelpView' => 'AphrontView',
'PhabricatorApplicationEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorApplicationEmailCommandsController' => 'PhabricatorApplicationsController',
+ 'PhabricatorApplicationMailReceiver' => 'PhabricatorMailReceiver',
'PhabricatorApplicationObjectMailEngineExtension' => 'PhabricatorMailEngineExtension',
'PhabricatorApplicationPanelController' => 'PhabricatorApplicationsController',
'PhabricatorApplicationPolicyChangeTransaction' => 'PhabricatorApplicationTransactionType',
@@ -11364,7 +11366,7 @@
'PonderQuestionAnswerWikiTransaction' => 'PonderQuestionTransactionType',
'PonderQuestionCommentController' => 'PonderController',
'PonderQuestionContentTransaction' => 'PonderQuestionTransactionType',
- 'PonderQuestionCreateMailReceiver' => 'PhabricatorMailReceiver',
+ 'PonderQuestionCreateMailReceiver' => 'PhabricatorApplicationMailReceiver',
'PonderQuestionEditController' => 'PonderController',
'PonderQuestionEditEngine' => 'PhabricatorEditEngine',
'PonderQuestionEditor' => 'PonderEditor',
diff --git a/src/applications/differential/mail/DifferentialCreateMailReceiver.php b/src/applications/differential/mail/DifferentialCreateMailReceiver.php
--- a/src/applications/differential/mail/DifferentialCreateMailReceiver.php
+++ b/src/applications/differential/mail/DifferentialCreateMailReceiver.php
@@ -1,15 +1,10 @@
<?php
-final class DifferentialCreateMailReceiver extends PhabricatorMailReceiver {
+final class DifferentialCreateMailReceiver
+ extends PhabricatorApplicationMailReceiver {
- public function isEnabled() {
- return PhabricatorApplication::isClassInstalled(
- 'PhabricatorDifferentialApplication');
- }
-
- public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) {
- $differential_app = new PhabricatorDifferentialApplication();
- return $this->canAcceptApplicationMail($differential_app, $mail);
+ protected function newApplication() {
+ return new PhabricatorDifferentialApplication();
}
protected function processReceivedMail(
diff --git a/src/applications/files/mail/FileCreateMailReceiver.php b/src/applications/files/mail/FileCreateMailReceiver.php
--- a/src/applications/files/mail/FileCreateMailReceiver.php
+++ b/src/applications/files/mail/FileCreateMailReceiver.php
@@ -1,15 +1,10 @@
<?php
-final class FileCreateMailReceiver extends PhabricatorMailReceiver {
+final class FileCreateMailReceiver
+ extends PhabricatorApplicationMailReceiver {
- public function isEnabled() {
- $app_class = 'PhabricatorFilesApplication';
- return PhabricatorApplication::isClassInstalled($app_class);
- }
-
- public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) {
- $files_app = new PhabricatorFilesApplication();
- return $this->canAcceptApplicationMail($files_app, $mail);
+ protected function newApplication() {
+ return new PhabricatorFilesApplication();
}
protected function processReceivedMail(
diff --git a/src/applications/maniphest/mail/ManiphestCreateMailReceiver.php b/src/applications/maniphest/mail/ManiphestCreateMailReceiver.php
--- a/src/applications/maniphest/mail/ManiphestCreateMailReceiver.php
+++ b/src/applications/maniphest/mail/ManiphestCreateMailReceiver.php
@@ -1,15 +1,10 @@
<?php
-final class ManiphestCreateMailReceiver extends PhabricatorMailReceiver {
+final class ManiphestCreateMailReceiver
+ extends PhabricatorApplicationMailReceiver {
- public function isEnabled() {
- return PhabricatorApplication::isClassInstalled(
- 'PhabricatorManiphestApplication');
- }
-
- public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) {
- $maniphest_app = new PhabricatorManiphestApplication();
- return $this->canAcceptApplicationMail($maniphest_app, $mail);
+ protected function newApplication() {
+ return new PhabricatorManiphestApplication();
}
protected function processReceivedMail(
diff --git a/src/applications/metamta/receiver/PhabricatorApplicationMailReceiver.php b/src/applications/metamta/receiver/PhabricatorApplicationMailReceiver.php
new file mode 100644
--- /dev/null
+++ b/src/applications/metamta/receiver/PhabricatorApplicationMailReceiver.php
@@ -0,0 +1,34 @@
+<?php
+
+abstract class PhabricatorApplicationMailReceiver
+ extends PhabricatorMailReceiver {
+
+ abstract protected function newApplication();
+
+ final public function isEnabled() {
+ return $this->newApplication()->isInstalled();
+ }
+
+ final public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) {
+ $application = $this->newApplication();
+ $viewer = $this->getViewer();
+
+ $application_emails = id(new PhabricatorMetaMTAApplicationEmailQuery())
+ ->setViewer($viewer)
+ ->withApplicationPHIDs(array($application->getPHID()))
+ ->execute();
+
+ foreach ($mail->newTargetAddresses() as $address) {
+ foreach ($application_emails as $application_email) {
+ $create_address = $application_email->newAddress();
+ if (PhabricatorMailUtil::matchAddresses($create_address, $address)) {
+ $this->setApplicationEmail($application_email);
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+}
diff --git a/src/applications/metamta/receiver/PhabricatorMailReceiver.php b/src/applications/metamta/receiver/PhabricatorMailReceiver.php
--- a/src/applications/metamta/receiver/PhabricatorMailReceiver.php
+++ b/src/applications/metamta/receiver/PhabricatorMailReceiver.php
@@ -16,28 +16,6 @@
abstract public function isEnabled();
abstract public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail);
- final protected function canAcceptApplicationMail(
- PhabricatorApplication $app,
- PhabricatorMetaMTAReceivedMail $mail) {
-
- $application_emails = id(new PhabricatorMetaMTAApplicationEmailQuery())
- ->setViewer($this->getViewer())
- ->withApplicationPHIDs(array($app->getPHID()))
- ->execute();
-
- foreach ($mail->newTargetAddresses() as $address) {
- foreach ($application_emails as $application_email) {
- $create_address = $application_email->newAddress();
- if (PhabricatorMailUtil::matchAddresses($create_address, $address)) {
- $this->setApplicationEmail($application_email);
- return true;
- }
- }
- }
-
- return false;
- }
-
abstract protected function processReceivedMail(
PhabricatorMetaMTAReceivedMail $mail,
diff --git a/src/applications/paste/mail/PasteCreateMailReceiver.php b/src/applications/paste/mail/PasteCreateMailReceiver.php
--- a/src/applications/paste/mail/PasteCreateMailReceiver.php
+++ b/src/applications/paste/mail/PasteCreateMailReceiver.php
@@ -1,15 +1,10 @@
<?php
-final class PasteCreateMailReceiver extends PhabricatorMailReceiver {
+final class PasteCreateMailReceiver
+ extends PhabricatorApplicationMailReceiver {
- public function isEnabled() {
- $app_class = 'PhabricatorPasteApplication';
- return PhabricatorApplication::isClassInstalled($app_class);
- }
-
- public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) {
- $paste_app = new PhabricatorPasteApplication();
- return $this->canAcceptApplicationMail($paste_app, $mail);
+ protected function newApplication() {
+ return new PhabricatorPasteApplication();
}
protected function processReceivedMail(
diff --git a/src/applications/ponder/mail/PonderQuestionCreateMailReceiver.php b/src/applications/ponder/mail/PonderQuestionCreateMailReceiver.php
--- a/src/applications/ponder/mail/PonderQuestionCreateMailReceiver.php
+++ b/src/applications/ponder/mail/PonderQuestionCreateMailReceiver.php
@@ -1,15 +1,10 @@
<?php
-final class PonderQuestionCreateMailReceiver extends PhabricatorMailReceiver {
+final class PonderQuestionCreateMailReceiver
+ extends PhabricatorApplicationMailReceiver {
- public function isEnabled() {
- $app_class = 'PhabricatorPonderApplication';
- return PhabricatorApplication::isClassInstalled($app_class);
- }
-
- public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) {
- $ponder_app = new PhabricatorPonderApplication();
- return $this->canAcceptApplicationMail($ponder_app, $mail);
+ protected function newApplication() {
+ return new PhabricatorPonderApplication();
}
protected function processReceivedMail(

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 23, 3:04 AM (12 h, 1 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7031218
Default Alt Text
D19950.diff (11 KB)

Event Timeline