Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2890771
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
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
@@ -1,78 +1,84 @@
<?php
final class PhabricatorMetaMTAReceiveController
extends PhabricatorMetaMTAController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
if ($request->isFormPost()) {
$receiver = PhabricatorMetaMTAReceivedMail::loadReceiverObject(
$request->getStr('obj'));
if (!$receiver) {
throw new Exception("No such task or revision!");
}
$hash = PhabricatorMetaMTAReceivedMail::computeMailHash(
$receiver->getMailKey(),
$user->getPHID());
$received = new PhabricatorMetaMTAReceivedMail();
$received->setHeaders(
array(
'to' => $request->getStr('obj').'+'.$user->getID().'+'.$hash.'@',
));
$received->setBodies(
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();
$phid = $receiver->getPHID();
$handles = $this->loadViewerHandles(array($phid));
$uri = $handles[$phid]->getURI();
return id(new AphrontRedirectResponse())->setURI($uri);
}
$form = new AphrontFormView();
$form->setUser($request->getUser());
$form->setAction($this->getApplicationURI('/receive/'));
$form
->appendChild(
'<p class="aphront-form-instructions">This form will simulate '.
'sending mail to an object.</p>')
->appendChild(
id(new AphrontFormTextControl())
->setLabel('To')
->setName('obj')
->setCaption('e.g. <tt>D1234</tt> or <tt>T1234</tt>'))
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Body')
->setName('body'))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Receive Mail'));
$panel = new AphrontPanelView();
$panel->setHeader('Receive Email');
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$nav = $this->buildSideNavView();
$nav->selectFilter('receive');
$nav->appendChild($panel);
return $this->buildApplicationPage(
$nav,
array(
'title' => 'Receive Test',
));
}
}
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
@@ -1,66 +1,68 @@
<?php
final class PhabricatorMetaMTASendGridReceiveController
extends PhabricatorMetaMTAController {
public function shouldRequireLogin() {
return false;
}
public function shouldRequireAdmin() {
return false;
}
public function processRequest() {
// No CSRF for SendGrid.
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$request = $this->getRequest();
$user = $request->getUser();
$raw_headers = $request->getStr('headers');
$raw_headers = explode("\n", rtrim($raw_headers));
$raw_dict = array();
foreach (array_filter($raw_headers) as $header) {
list($name, $value) = explode(':', $header, 2);
$raw_dict[$name] = ltrim($value);
}
$headers = array(
'to' => $request->getStr('to'),
'from' => $request->getStr('from'),
'subject' => $request->getStr('subject'),
) + $raw_dict;
$received = new PhabricatorMetaMTAReceivedMail();
$received->setHeaders($headers);
$received->setBodies(array(
'text' => $request->getStr('text'),
'html' => $request->getStr('from'),
));
+ $received->setMessageIDHash(
+ PhabricatorHash::digestForIndex($received->getMessageID()));
$file_phids = array();
foreach ($_FILES as $file_raw) {
try {
$file = PhabricatorFile::newFromPHPUpload(
$file_raw,
array(
'authorPHID' => $user->getPHID(),
));
$file_phids[] = $file->getPHID();
} catch (Exception $ex) {
phlog($ex);
}
}
$received->setAttachments($file_phids);
$received->save();
$received->processReceivedMail();
$response = new AphrontWebpageResponse();
$response->setContent("Got it! Thanks, SendGrid!\n");
return $response;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 14:05 (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1125339
Default Alt Text
(5 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment