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:
parent
a9099912bb
commit
1e4162f81b
1 changed files with 33 additions and 17 deletions
|
@ -9,21 +9,34 @@ final class PhabricatorMetaMTAReceiveController
|
|||
$user = $request->getUser();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$receiver = PhabricatorMetaMTAReceivedMail::loadReceiverObject(
|
||||
$request->getStr('obj'));
|
||||
if (!$receiver) {
|
||||
throw new Exception(pht("No such task or revision!"));
|
||||
$received = new PhabricatorMetaMTAReceivedMail();
|
||||
$header_content = array();
|
||||
$from = $request->getStr('sender');
|
||||
$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(),
|
||||
$user->getPHID());
|
||||
|
||||
$received = new PhabricatorMetaMTAReceivedMail();
|
||||
$received->setHeaders(
|
||||
array(
|
||||
'to' => $request->getStr('obj').'+'.$user->getID().'+'.$hash.'@',
|
||||
));
|
||||
$header_content['to'] =
|
||||
$to.'+'.$user->getID().'+'.$hash.'@';
|
||||
}
|
||||
|
||||
$received->setHeaders($header_content);
|
||||
$received->setBodies(
|
||||
array(
|
||||
'text' => $request->getStr('body'),
|
||||
|
@ -38,10 +51,6 @@ final class PhabricatorMetaMTAReceiveController
|
|||
|
||||
$received->processReceivedMail();
|
||||
|
||||
$phid = $receiver->getPHID();
|
||||
$handles = $this->loadViewerHandles(array($phid));
|
||||
$uri = $handles[$phid]->getURI();
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
||||
}
|
||||
|
||||
|
@ -51,15 +60,21 @@ final class PhabricatorMetaMTAReceiveController
|
|||
$form
|
||||
->appendChild(hsprintf(
|
||||
'<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(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel(pht('To'))
|
||||
->setName('obj')
|
||||
->setName('receiver')
|
||||
->setCaption(pht(
|
||||
'e.g. %s or %s',
|
||||
phutil_tag('tt', array(), 'D1234'),
|
||||
phutil_tag('tt', array(), 'T1234'))))
|
||||
phutil_tag('tt', array(), 'bugs@example.com'))))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextAreaControl())
|
||||
->setLabel(pht('Body'))
|
||||
|
@ -86,3 +101,4 @@ final class PhabricatorMetaMTAReceiveController
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue