Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14759896
D19950.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D19950.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 23, 2:48 PM (20 h, 33 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7031218
Default Alt Text
D19950.diff (11 KB)
Attached To
Mode
D19950: Consolidate some application email receiver code in preparation for API changes
Attached
Detach File
Event Timeline
Log In to Comment