Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14097677
D11570.id27835.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D11570.id27835.diff
View Options
diff --git a/resources/sql/autopatches/20150129.pastefileapplicationemails.php b/resources/sql/autopatches/20150129.pastefileapplicationemails.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20150129.pastefileapplicationemails.php
@@ -0,0 +1,38 @@
+<?php
+
+$key_files = 'metamta.files.public-create-email';
+$key_paste = 'metamta.paste.public-create-email';
+echo "Migrating `$key_files` and `$key_paste` to new application email ".
+ "infrastructure...\n";
+
+$value_files = PhabricatorEnv::getEnvConfigIfExists($key_files);
+$files_app = new PhabricatorFilesApplication();
+
+if ($value_files) {
+ try {
+ PhabricatorMetaMTAApplicationEmail::initializeNewAppEmail(
+ PhabricatorUser::getOmnipotentUser())
+ ->setAddress($value_files)
+ ->setApplicationPHID($files_app->getPHID())
+ ->save();
+ } catch (AphrontDuplicateKeyQueryException $ex) {
+ // already migrated?
+ }
+}
+
+$value_paste = PhabricatorEnv::getEnvConfigIfExists($key_paste);
+$paste_app = new PhabricatorPasteApplication();
+
+if ($value_paste) {
+ try {
+ PhabricatorMetaMTAApplicationEmail::initializeNewAppEmail(
+ PhabricatorUser::getOmnipotentUser())
+ ->setAddress($value_paste)
+ ->setApplicationPHID($paste_app->getPHID())
+ ->save();
+ } catch (AphrontDuplicateKeyQueryException $ex) {
+ // already migrated?
+ }
+}
+
+echo "Done.\n";
diff --git a/src/applications/files/application/PhabricatorFilesApplication.php b/src/applications/files/application/PhabricatorFilesApplication.php
--- a/src/applications/files/application/PhabricatorFilesApplication.php
+++ b/src/applications/files/application/PhabricatorFilesApplication.php
@@ -44,6 +44,21 @@
);
}
+ public function supportsEmailIntegration() {
+ return true;
+ }
+
+ public function getAppEmailBlurb() {
+ return pht(
+ 'Send emails with file attachments to these addresses to upload '.
+ 'files. %s',
+ phutil_tag(
+ 'a',
+ array(
+ 'href' => $this->getInboundEmailSupportLink(),),
+ pht('Learn More')));
+ }
+
protected function getCustomCapabilities() {
return array(
FilesDefaultViewCapability::CAPABILITY => array(
diff --git a/src/applications/files/config/PhabricatorFilesConfigOptions.php b/src/applications/files/config/PhabricatorFilesConfigOptions.php
--- a/src/applications/files/config/PhabricatorFilesConfigOptions.php
+++ b/src/applications/files/config/PhabricatorFilesConfigOptions.php
@@ -179,7 +179,16 @@
'metamta.files.public-create-email',
'string',
null)
- ->setDescription(pht('Allow uploaded files via email.')),
+ ->setLocked(true)
+ ->setLockedMessage(pht(
+ 'This configuration is deprecated. See description for details.'))
+ ->setSummary(pht('DEPRECATED - Allow uploaded files via email.'))
+ ->setDescription(
+ pht(
+ 'This config has been deprecated in favor of [[ '.
+ '/applications/view/PhabricatorFilesApplication/ | '.
+ 'application settings ]], which allow for multiple email '.
+ 'addresses and other functionality.')),
$this->newOption(
'metamta.files.subject-prefix',
'string',
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
@@ -8,19 +8,8 @@
}
public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) {
- $config_key = 'metamta.files.public-create-email';
- $create_address = PhabricatorEnv::getEnvConfig($config_key);
- if (!$create_address) {
- return false;
- }
-
- foreach ($mail->getToAddresses() as $to_address) {
- if ($this->matchAddresses($create_address, $to_address)) {
- return true;
- }
- }
-
- return false;
+ $files_app = new PhabricatorFilesApplication();
+ return $this->canAcceptApplicationMail($files_app, $mail);
}
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
@@ -9,22 +9,7 @@
public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) {
$maniphest_app = new PhabricatorManiphestApplication();
- $application_emails = id(new PhabricatorMetaMTAApplicationEmailQuery())
- ->setViewer($this->getViewer())
- ->withApplicationPHIDs(array($maniphest_app->getPHID()))
- ->execute();
-
- foreach ($mail->getToAddresses() as $to_address) {
- foreach ($application_emails as $application_email) {
- $create_address = $application_email->getAddress();
- if ($this->matchAddresses($create_address, $to_address)) {
- $this->setApplicationEmail($application_email);
- return true;
- }
- }
- }
-
- return false;
+ return $this->canAcceptApplicationMail($maniphest_app, $mail);
}
protected function processReceivedMail(
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,6 +16,27 @@
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->getToAddresses() as $to_address) {
+ foreach ($application_emails as $application_email) {
+ $create_address = $application_email->getAddress();
+ if ($this->matchAddresses($create_address, $to_address)) {
+ $this->setApplicationEmail($application_email);
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
abstract protected function processReceivedMail(
diff --git a/src/applications/paste/application/PhabricatorPasteApplication.php b/src/applications/paste/application/PhabricatorPasteApplication.php
--- a/src/applications/paste/application/PhabricatorPasteApplication.php
+++ b/src/applications/paste/application/PhabricatorPasteApplication.php
@@ -49,6 +49,20 @@
);
}
+ public function supportsEmailIntegration() {
+ return true;
+ }
+
+ public function getAppEmailBlurb() {
+ return pht(
+ 'Send email to these addresses to create pastes. %s',
+ phutil_tag(
+ 'a',
+ array(
+ 'href' => $this->getInboundEmailSupportLink(),),
+ pht('Learn More')));
+ }
+
protected function getCustomCapabilities() {
return array(
PasteDefaultViewCapability::CAPABILITY => array(
diff --git a/src/applications/paste/config/PhabricatorPasteConfigOptions.php b/src/applications/paste/config/PhabricatorPasteConfigOptions.php
--- a/src/applications/paste/config/PhabricatorPasteConfigOptions.php
+++ b/src/applications/paste/config/PhabricatorPasteConfigOptions.php
@@ -17,7 +17,16 @@
'metamta.paste.public-create-email',
'string',
null)
- ->setDescription(pht('Allow creating pastes via email.')),
+ ->setLocked(true)
+ ->setLockedMessage(pht(
+ 'This configuration is deprecated. See description for details.'))
+ ->setSummary(pht('DEPRECATED - Allow creating pastes via email.'))
+ ->setDescription(
+ pht(
+ 'This config has been deprecated in favor of [[ '.
+ '/applications/view/PhabricatorPasteApplication/ | '.
+ 'application settings ]], which allow for multiple email '.
+ 'addresses and other functionality.')),
$this->newOption(
'metamta.paste.subject-prefix',
'string',
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
@@ -8,19 +8,8 @@
}
public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) {
- $config_key = 'metamta.paste.public-create-email';
- $create_address = PhabricatorEnv::getEnvConfig($config_key);
- if (!$create_address) {
- return false;
- }
-
- foreach ($mail->getToAddresses() as $to_address) {
- if ($this->matchAddresses($create_address, $to_address)) {
- return true;
- }
- }
-
- return false;
+ $paste_app = new PhabricatorPasteApplication();
+ return $this->canAcceptApplicationMail($paste_app, $mail);
}
protected function processReceivedMail(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 7:35 AM (16 h, 6 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6792626
Default Alt Text
D11570.id27835.diff (8 KB)
Attached To
Mode
D11570: Application emails - move over paste and files
Attached
Detach File
Event Timeline
Log In to Comment