Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15406689
D19947.id47618.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D19947.id47618.diff
View Options
diff --git a/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php b/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php
--- a/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php
+++ b/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php
@@ -67,40 +67,9 @@
PhabricatorMetaMTAReceivedMail $mail);
public function processEmail(PhabricatorMetaMTAReceivedMail $mail) {
- $this->dropEmptyMail($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() {
return (bool)$this->getReplyHandlerDomain() &&
!$this->supportsPublicReplies();
diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php
--- a/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php
+++ b/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php
@@ -109,6 +109,7 @@
try {
$this->dropMailFromPhabricator();
$this->dropMailAlreadyReceived();
+ $this->dropEmptyMail();
$receiver = $this->loadReceiver();
$sender = $receiver->loadSender($this);
@@ -260,6 +261,34 @@
$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
diff --git a/src/applications/metamta/storage/__tests__/PhabricatorMetaMTAReceivedMailTestCase.php b/src/applications/metamta/storage/__tests__/PhabricatorMetaMTAReceivedMailTestCase.php
--- a/src/applications/metamta/storage/__tests__/PhabricatorMetaMTAReceivedMailTestCase.php
+++ b/src/applications/metamta/storage/__tests__/PhabricatorMetaMTAReceivedMailTestCase.php
@@ -54,6 +54,10 @@
'Message-ID' => 'test@example.com',
'To' => 'does+not+exist@example.com',
));
+ $mail->setBodies(
+ array(
+ 'text' => 'test',
+ ));
$mail->save();
$mail->processReceivedMail();
@@ -77,6 +81,10 @@
'To' => 'bugs@example.com',
'From' => 'does+not+exist@example.com',
));
+ $mail->setBodies(
+ array(
+ 'text' => 'test',
+ ));
$mail->save();
$mail->processReceivedMail();
@@ -101,6 +109,10 @@
'From' => $user->loadPrimaryEmail()->getAddress(),
'To' => 'bugs@example.com',
));
+ $mail->setBodies(
+ array(
+ 'text' => 'test',
+ ));
$mail->save();
$mail->processReceivedMail();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 19, 1:20 PM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7711397
Default Alt Text
D19947.id47618.diff (4 KB)
Attached To
Mode
D19947: Drop empty inbound mail at the beginning of the receive workflow, not inside object handlers
Attached
Detach File
Event Timeline
Log In to Comment