From 1670f5841ddccc771e5ee3011be72bbe98c428df Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 26 Jan 2013 15:22:06 -0800 Subject: [PATCH] Set messageIDHash from SendGrid and Test controllers Summary: Most mail comes in through the script, but we can also generate it with the test controller or the SendGrid receiver. In these cases, we produce a `null` message hash ID, which fails on inserts into MySQL databases configured in strict mode. Instead, correctly generate the hash ID in these cases (for tests, make one up). Test Plan: Generated test mail. (I'll see if @sokcevic can test SendGrid). Reviewers: btrahan Reviewed By: btrahan CC: sokcevic, aran Maniphest Tasks: T2423 Differential Revision: https://secure.phabricator.com/D4667 --- .../controller/PhabricatorMetaMTAReceiveController.php | 6 ++++++ .../PhabricatorMetaMTASendGridReceiveController.php | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/applications/metamta/controller/PhabricatorMetaMTAReceiveController.php b/src/applications/metamta/controller/PhabricatorMetaMTAReceiveController.php index 6afb4b3c17..2ae211e2ad 100644 --- a/src/applications/metamta/controller/PhabricatorMetaMTAReceiveController.php +++ b/src/applications/metamta/controller/PhabricatorMetaMTAReceiveController.php @@ -28,6 +28,12 @@ final class PhabricatorMetaMTAReceiveController array( 'text' => $request->getStr('body'), )); + + // Make up some unique value, since this column isn't nullable. + $received->setMessageIDHash( + PhabricatorHash::digestForIndex( + Filesystem::readRandomBytes(12))); + $received->save(); $received->processReceivedMail(); diff --git a/src/applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php b/src/applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php index 4b81a3c08b..fbd86a2871 100644 --- a/src/applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php +++ b/src/applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php @@ -39,6 +39,8 @@ final class PhabricatorMetaMTASendGridReceiveController 'text' => $request->getStr('text'), 'html' => $request->getStr('from'), )); + $received->setMessageIDHash( + PhabricatorHash::digestForIndex($received->getMessageID())); $file_phids = array(); foreach ($_FILES as $file_raw) {