Differential D19947 Diff 47639 src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php
| Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | abstract class PhabricatorMailReplyHandler extends Phobject { | ||||
| public function getReplyHandlerDomain() { | public function getReplyHandlerDomain() { | ||||
| return PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain'); | return PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain'); | ||||
| } | } | ||||
| abstract protected function receiveEmail( | abstract protected function receiveEmail( | ||||
| PhabricatorMetaMTAReceivedMail $mail); | PhabricatorMetaMTAReceivedMail $mail); | ||||
| public function processEmail(PhabricatorMetaMTAReceivedMail $mail) { | public function processEmail(PhabricatorMetaMTAReceivedMail $mail) { | ||||
| $this->dropEmptyMail($mail); | |||||
| return $this->receiveEmail($mail); | return $this->receiveEmail($mail); | ||||
| } | } | ||||
| private function dropEmptyMail(PhabricatorMetaMTAReceivedMail $mail) { | |||||
| $body = $mail->getCleanTextBody(); | |||||
| $attachments = $mail->getAttachments(); | |||||
| if (strlen($body) || $attachments) { | |||||
| return; | |||||
| } | |||||
| // Only send an error email if the user is talking to just Phabricator. | |||||
| // We can assume if there is only one "To" address it is a Phabricator | |||||
| // address since this code is running and everything. | |||||
| $is_direct_mail = (count($mail->getToAddresses()) == 1) && | |||||
| (count($mail->getCCAddresses()) == 0); | |||||
| if ($is_direct_mail) { | |||||
| $status_code = MetaMTAReceivedMailStatus::STATUS_EMPTY; | |||||
| } else { | |||||
| $status_code = MetaMTAReceivedMailStatus::STATUS_EMPTY_IGNORED; | |||||
| } | |||||
| throw new PhabricatorMetaMTAReceivedMailProcessingException( | |||||
| $status_code, | |||||
| pht( | |||||
| 'Your message does not contain any body text or attachments, so '. | |||||
| 'Phabricator can not do anything useful with it. Make sure comment '. | |||||
| 'text appears at the top of your message: quoted replies, inline '. | |||||
| 'text, and signatures are discarded and ignored.')); | |||||
| } | |||||
| public function supportsPrivateReplies() { | public function supportsPrivateReplies() { | ||||
| return (bool)$this->getReplyHandlerDomain() && | return (bool)$this->getReplyHandlerDomain() && | ||||
| !$this->supportsPublicReplies(); | !$this->supportsPublicReplies(); | ||||
| } | } | ||||
| public function supportsPublicReplies() { | public function supportsPublicReplies() { | ||||
| if (!PhabricatorEnv::getEnvConfig('metamta.public-replies')) { | if (!PhabricatorEnv::getEnvConfig('metamta.public-replies')) { | ||||
| return false; | return false; | ||||
| ▲ Show 20 Lines • Show All 331 Lines • Show Last 20 Lines | |||||