Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php
| Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO { | ||||
| } | } | ||||
| public function processReceivedMail() { | public function processReceivedMail() { | ||||
| $sender = null; | $sender = null; | ||||
| try { | try { | ||||
| $this->dropMailFromPhabricator(); | $this->dropMailFromPhabricator(); | ||||
| $this->dropMailAlreadyReceived(); | $this->dropMailAlreadyReceived(); | ||||
| $this->dropEmptyMail(); | |||||
| $receiver = $this->loadReceiver(); | $receiver = $this->loadReceiver(); | ||||
| $sender = $receiver->loadSender($this); | $sender = $receiver->loadSender($this); | ||||
| $receiver->validateSender($this, $sender); | $receiver->validateSender($this, $sender); | ||||
| $this->setAuthorPHID($sender->getPHID()); | $this->setAuthorPHID($sender->getPHID()); | ||||
| // Now that we've identified the sender, mark them as the author of | // Now that we've identified the sender, mark them as the author of | ||||
| ▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | $message = pht( | ||||
| $message_id_hash, | $message_id_hash, | ||||
| $messages_count); | $messages_count); | ||||
| throw new PhabricatorMetaMTAReceivedMailProcessingException( | throw new PhabricatorMetaMTAReceivedMailProcessingException( | ||||
| MetaMTAReceivedMailStatus::STATUS_DUPLICATE, | MetaMTAReceivedMailStatus::STATUS_DUPLICATE, | ||||
| $message); | $message); | ||||
| } | } | ||||
| private function dropEmptyMail() { | |||||
| $body = $this->getCleanTextBody(); | |||||
| $attachments = $this->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($this->getToAddresses()) == 1) && | |||||
| (count($this->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.')); | |||||
| } | |||||
| /** | /** | ||||
| * Load a concrete instance of the @{class:PhabricatorMailReceiver} which | * Load a concrete instance of the @{class:PhabricatorMailReceiver} which | ||||
| * accepts this mail, if one exists. | * accepts this mail, if one exists. | ||||
| */ | */ | ||||
| private function loadReceiver() { | private function loadReceiver() { | ||||
| $receivers = id(new PhutilClassMapQuery()) | $receivers = id(new PhutilClassMapQuery()) | ||||
| ->setAncestorClass('PhabricatorMailReceiver') | ->setAncestorClass('PhabricatorMailReceiver') | ||||
| ▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines | |||||