@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Application emails - move over paste and files

Summary: Fixes T3404 (post D11565), fixes T5952. This infrastructure has been getting deployed against Maniphest and its time to get these other two applications going on it.

Test Plan: created an email address for paste and used `./bin/mail receive-test` ; a paste was successfully created

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T5952, T3404

Differential Revision: https://secure.phabricator.com/D11570

+113 -44
+38
resources/sql/autopatches/20150129.pastefileapplicationemails.php
··· 1 + <?php 2 + 3 + $key_files = 'metamta.files.public-create-email'; 4 + $key_paste = 'metamta.paste.public-create-email'; 5 + echo "Migrating `$key_files` and `$key_paste` to new application email ". 6 + "infrastructure...\n"; 7 + 8 + $value_files = PhabricatorEnv::getEnvConfigIfExists($key_files); 9 + $files_app = new PhabricatorFilesApplication(); 10 + 11 + if ($value_files) { 12 + try { 13 + PhabricatorMetaMTAApplicationEmail::initializeNewAppEmail( 14 + PhabricatorUser::getOmnipotentUser()) 15 + ->setAddress($value_files) 16 + ->setApplicationPHID($files_app->getPHID()) 17 + ->save(); 18 + } catch (AphrontDuplicateKeyQueryException $ex) { 19 + // already migrated? 20 + } 21 + } 22 + 23 + $value_paste = PhabricatorEnv::getEnvConfigIfExists($key_paste); 24 + $paste_app = new PhabricatorPasteApplication(); 25 + 26 + if ($value_paste) { 27 + try { 28 + PhabricatorMetaMTAApplicationEmail::initializeNewAppEmail( 29 + PhabricatorUser::getOmnipotentUser()) 30 + ->setAddress($value_paste) 31 + ->setApplicationPHID($paste_app->getPHID()) 32 + ->save(); 33 + } catch (AphrontDuplicateKeyQueryException $ex) { 34 + // already migrated? 35 + } 36 + } 37 + 38 + echo "Done.\n";
+15
src/applications/files/application/PhabricatorFilesApplication.php
··· 44 44 ); 45 45 } 46 46 47 + public function supportsEmailIntegration() { 48 + return true; 49 + } 50 + 51 + public function getAppEmailBlurb() { 52 + return pht( 53 + 'Send emails with file attachments to these addresses to upload '. 54 + 'files. %s', 55 + phutil_tag( 56 + 'a', 57 + array( 58 + 'href' => $this->getInboundEmailSupportLink(),), 59 + pht('Learn More'))); 60 + } 61 + 47 62 protected function getCustomCapabilities() { 48 63 return array( 49 64 FilesDefaultViewCapability::CAPABILITY => array(
+10 -1
src/applications/files/config/PhabricatorFilesConfigOptions.php
··· 179 179 'metamta.files.public-create-email', 180 180 'string', 181 181 null) 182 - ->setDescription(pht('Allow uploaded files via email.')), 182 + ->setLocked(true) 183 + ->setLockedMessage(pht( 184 + 'This configuration is deprecated. See description for details.')) 185 + ->setSummary(pht('DEPRECATED - Allow uploaded files via email.')) 186 + ->setDescription( 187 + pht( 188 + 'This config has been deprecated in favor of [[ '. 189 + '/applications/view/PhabricatorFilesApplication/ | '. 190 + 'application settings ]], which allow for multiple email '. 191 + 'addresses and other functionality.')), 183 192 $this->newOption( 184 193 'metamta.files.subject-prefix', 185 194 'string',
+2 -13
src/applications/files/mail/FileCreateMailReceiver.php
··· 8 8 } 9 9 10 10 public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) { 11 - $config_key = 'metamta.files.public-create-email'; 12 - $create_address = PhabricatorEnv::getEnvConfig($config_key); 13 - if (!$create_address) { 14 - return false; 15 - } 16 - 17 - foreach ($mail->getToAddresses() as $to_address) { 18 - if ($this->matchAddresses($create_address, $to_address)) { 19 - return true; 20 - } 21 - } 22 - 23 - return false; 11 + $files_app = new PhabricatorFilesApplication(); 12 + return $this->canAcceptApplicationMail($files_app, $mail); 24 13 } 25 14 26 15 protected function processReceivedMail(
+1 -16
src/applications/maniphest/mail/ManiphestCreateMailReceiver.php
··· 9 9 10 10 public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) { 11 11 $maniphest_app = new PhabricatorManiphestApplication(); 12 - $application_emails = id(new PhabricatorMetaMTAApplicationEmailQuery()) 13 - ->setViewer($this->getViewer()) 14 - ->withApplicationPHIDs(array($maniphest_app->getPHID())) 15 - ->execute(); 16 - 17 - foreach ($mail->getToAddresses() as $to_address) { 18 - foreach ($application_emails as $application_email) { 19 - $create_address = $application_email->getAddress(); 20 - if ($this->matchAddresses($create_address, $to_address)) { 21 - $this->setApplicationEmail($application_email); 22 - return true; 23 - } 24 - } 25 - } 26 - 27 - return false; 12 + return $this->canAcceptApplicationMail($maniphest_app, $mail); 28 13 } 29 14 30 15 protected function processReceivedMail(
+21
src/applications/metamta/receiver/PhabricatorMailReceiver.php
··· 16 16 17 17 abstract public function isEnabled(); 18 18 abstract public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail); 19 + final protected function canAcceptApplicationMail( 20 + PhabricatorApplication $app, 21 + PhabricatorMetaMTAReceivedMail $mail) { 22 + 23 + $application_emails = id(new PhabricatorMetaMTAApplicationEmailQuery()) 24 + ->setViewer($this->getViewer()) 25 + ->withApplicationPHIDs(array($app->getPHID())) 26 + ->execute(); 27 + 28 + foreach ($mail->getToAddresses() as $to_address) { 29 + foreach ($application_emails as $application_email) { 30 + $create_address = $application_email->getAddress(); 31 + if ($this->matchAddresses($create_address, $to_address)) { 32 + $this->setApplicationEmail($application_email); 33 + return true; 34 + } 35 + } 36 + } 37 + 38 + return false; 39 + } 19 40 20 41 21 42 abstract protected function processReceivedMail(
+14
src/applications/paste/application/PhabricatorPasteApplication.php
··· 49 49 ); 50 50 } 51 51 52 + public function supportsEmailIntegration() { 53 + return true; 54 + } 55 + 56 + public function getAppEmailBlurb() { 57 + return pht( 58 + 'Send email to these addresses to create pastes. %s', 59 + phutil_tag( 60 + 'a', 61 + array( 62 + 'href' => $this->getInboundEmailSupportLink(),), 63 + pht('Learn More'))); 64 + } 65 + 52 66 protected function getCustomCapabilities() { 53 67 return array( 54 68 PasteDefaultViewCapability::CAPABILITY => array(
+10 -1
src/applications/paste/config/PhabricatorPasteConfigOptions.php
··· 17 17 'metamta.paste.public-create-email', 18 18 'string', 19 19 null) 20 - ->setDescription(pht('Allow creating pastes via email.')), 20 + ->setLocked(true) 21 + ->setLockedMessage(pht( 22 + 'This configuration is deprecated. See description for details.')) 23 + ->setSummary(pht('DEPRECATED - Allow creating pastes via email.')) 24 + ->setDescription( 25 + pht( 26 + 'This config has been deprecated in favor of [[ '. 27 + '/applications/view/PhabricatorPasteApplication/ | '. 28 + 'application settings ]], which allow for multiple email '. 29 + 'addresses and other functionality.')), 21 30 $this->newOption( 22 31 'metamta.paste.subject-prefix', 23 32 'string',
+2 -13
src/applications/paste/mail/PasteCreateMailReceiver.php
··· 8 8 } 9 9 10 10 public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) { 11 - $config_key = 'metamta.paste.public-create-email'; 12 - $create_address = PhabricatorEnv::getEnvConfig($config_key); 13 - if (!$create_address) { 14 - return false; 15 - } 16 - 17 - foreach ($mail->getToAddresses() as $to_address) { 18 - if ($this->matchAddresses($create_address, $to_address)) { 19 - return true; 20 - } 21 - } 22 - 23 - return false; 11 + $paste_app = new PhabricatorPasteApplication(); 12 + return $this->canAcceptApplicationMail($paste_app, $mail); 24 13 } 25 14 26 15 protected function processReceivedMail(