1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-20 05:42:40 +01:00

Changed PhabricatorMetaMTAReceiveController to accept email addresses as input along with objects.

Summary: Similar to title. I tried to test as specified. I thought I had to configure inbound and outbound mail. I had installed lamson too :O. when it started to become complicated I asked you :P. Please have a look at the code and let me know where I am going wrong or have understood correctly or not :)

Test Plan: Send an email using /mail/recieve/ form to an email id pointed to by maniphest.public-create-email and see if creates a maniphest task.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Maniphest Tasks: T1205

Differential Revision: https://secure.phabricator.com/D5681
This commit is contained in:
Afaque Hussain 2013-04-16 08:35:54 -07:00 committed by epriestley
parent a9099912bb
commit 1e4162f81b

View file

@ -9,21 +9,34 @@ final class PhabricatorMetaMTAReceiveController
$user = $request->getUser(); $user = $request->getUser();
if ($request->isFormPost()) { if ($request->isFormPost()) {
$receiver = PhabricatorMetaMTAReceivedMail::loadReceiverObject( $received = new PhabricatorMetaMTAReceivedMail();
$request->getStr('obj')); $header_content = array();
if (!$receiver) { $from = $request->getStr('sender');
throw new Exception(pht("No such task or revision!")); $to = $request->getStr('receiver');
$uri = '/mail/received/';
if (!empty($from)) {
$header_content['from'] = $from;
} }
$hash = PhabricatorMetaMTAReceivedMail::computeMailHash( if (preg_match('/.+@.+/', $to)) {
$header_content['to'] = $to;
} else {
$receiver = PhabricatorMetaMTAReceivedMail::loadReceiverObject($to);
if (!$receiver) {
throw new Exception(pht("No such task or revision!"));
}
$hash = PhabricatorMetaMTAReceivedMail::computeMailHash(
$receiver->getMailKey(), $receiver->getMailKey(),
$user->getPHID()); $user->getPHID());
$received = new PhabricatorMetaMTAReceivedMail(); $header_content['to'] =
$received->setHeaders( $to.'+'.$user->getID().'+'.$hash.'@';
array( }
'to' => $request->getStr('obj').'+'.$user->getID().'+'.$hash.'@',
)); $received->setHeaders($header_content);
$received->setBodies( $received->setBodies(
array( array(
'text' => $request->getStr('body'), 'text' => $request->getStr('body'),
@ -38,10 +51,6 @@ final class PhabricatorMetaMTAReceiveController
$received->processReceivedMail(); $received->processReceivedMail();
$phid = $receiver->getPHID();
$handles = $this->loadViewerHandles(array($phid));
$uri = $handles[$phid]->getURI();
return id(new AphrontRedirectResponse())->setURI($uri); return id(new AphrontRedirectResponse())->setURI($uri);
} }
@ -51,15 +60,21 @@ final class PhabricatorMetaMTAReceiveController
$form $form
->appendChild(hsprintf( ->appendChild(hsprintf(
'<p class="aphront-form-instructions">%s</p>', '<p class="aphront-form-instructions">%s</p>',
pht('This form will simulate sending mail to an object.'))) pht(
'This form will simulate sending mail to an object '.
'or an email address.')))
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('From'))
->setName('sender'))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel(pht('To')) ->setLabel(pht('To'))
->setName('obj') ->setName('receiver')
->setCaption(pht( ->setCaption(pht(
'e.g. %s or %s', 'e.g. %s or %s',
phutil_tag('tt', array(), 'D1234'), phutil_tag('tt', array(), 'D1234'),
phutil_tag('tt', array(), 'T1234')))) phutil_tag('tt', array(), 'bugs@example.com'))))
->appendChild( ->appendChild(
id(new AphrontFormTextAreaControl()) id(new AphrontFormTextAreaControl())
->setLabel(pht('Body')) ->setLabel(pht('Body'))
@ -86,3 +101,4 @@ final class PhabricatorMetaMTAReceiveController
} }
} }