Page MenuHomePhabricator

D7760.diff

diff --git a/scripts/mail/mail_handler.php b/scripts/mail/mail_handler.php
--- a/scripts/mail/mail_handler.php
+++ b/scripts/mail/mail_handler.php
@@ -1,14 +1,37 @@
#!/usr/bin/env php
<?php
+// NOTE: This script is very oldschool and takes the environment as an argument.
+// Some day, we could take a shot at cleaning this up.
if ($argc > 1) {
- $_SERVER['PHABRICATOR_ENV'] = $argv[1];
+ foreach (array_slice($argv, 1) as $arg) {
+ if (!preg_match('/^-/', $arg)) {
+ $_SERVER['PHABRICATOR_ENV'] = $arg;
+ break;
+ }
+ }
}
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/externals/mimemailparser/MimeMailParser.class.php';
+$args = new PhutilArgumentParser($argv);
+$args->parseStandardArguments();
+$args->parse(
+ array(
+ array(
+ 'name' => 'process-duplicates',
+ 'help' => pht(
+ "Process this message, even if it's a duplicate of another message. ".
+ "This is mostly useful when debugging issues with mail routing."),
+ ),
+ array(
+ 'name' => 'env',
+ 'wildcard' => true,
+ ),
+ ));
+
$parser = new MimeMailParser();
$parser->setText(file_get_contents('php://stdin'));
@@ -28,6 +51,10 @@
$headers['subject'] = iconv_mime_decode($headers['subject'], 0, "UTF-8");
$headers['from'] = iconv_mime_decode($headers['from'], 0, "UTF-8");
+if ($args->getArg('process-duplicates')) {
+ $headers['message-id'] = Filesystem::readRandomCharacters(64);
+}
+
$received = new PhabricatorMetaMTAReceivedMail();
$received->setHeaders($headers);
$received->setBodies(array(
@@ -62,6 +89,8 @@
$received
->setMessage('EXCEPTION: '.$e->getMessage())
->save();
+
+ throw $e;
}
diff --git a/src/applications/conpherence/mail/ConpherenceCreateThreadMailReceiver.php b/src/applications/conpherence/mail/ConpherenceCreateThreadMailReceiver.php
--- a/src/applications/conpherence/mail/ConpherenceCreateThreadMailReceiver.php
+++ b/src/applications/conpherence/mail/ConpherenceCreateThreadMailReceiver.php
@@ -53,13 +53,15 @@
$phids = mpull($users, 'getPHID');
$conpherence = id(new ConpherenceReplyHandler())
- ->setMailReceiver(new ConpherenceThread())
+ ->setMailReceiver(ConpherenceThread::initializeNewThread($sender))
->setMailAddedParticipantPHIDs($phids)
->setActor($sender)
->setExcludeMailRecipientPHIDs($mail->loadExcludeMailRecipientPHIDs())
->processEmail($mail);
- $mail->setRelatedPHID($conpherence->getPHID());
+ if ($conpherence) {
+ $mail->setRelatedPHID($conpherence->getPHID());
+ }
}
}
diff --git a/src/applications/conpherence/storage/ConpherenceThread.php b/src/applications/conpherence/storage/ConpherenceThread.php
--- a/src/applications/conpherence/storage/ConpherenceThread.php
+++ b/src/applications/conpherence/storage/ConpherenceThread.php
@@ -18,6 +18,12 @@
private $widgetData = self::ATTACHABLE;
private $images = array();
+ public function initializeNewThread(PhabricatorUser $sender) {
+ return id(new ConpherenceThread())
+ ->setMessageCount(0)
+ ->setTitle('');
+ }
+
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,

File Metadata

Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/sl/43/tassr4lfzkygk7um
Default Alt Text
D7760.diff (3 KB)

Event Timeline