mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-08 22:01:03 +01:00
Fix some issues with Maniphest inbound email
Summary: Fixes T3181. - Inbound `bugs@` mail is broken right now if it doesn't use the new external user stuff, because it calls `$user->getPhabricatorUser()` on an object which is already a `PhabricatorUser`. Instead, build the right `$user` object from the external user earlier on. - Maniphest mail is nuking or otherwise awkwardly altering CCs. Make this work properly. - Make sure "!unsubscribe" works correctly. Test Plan: Sent `bugs@` mail. Sent CC mail. Sent "!unsubscribe" mail. Reviewers: btrahan, chad Reviewed By: chad CC: aran, tido Maniphest Tasks: T3181 Differential Revision: https://secure.phabricator.com/D5911
This commit is contained in:
parent
9c87ba8b09
commit
9e6da42206
2 changed files with 23 additions and 17 deletions
|
@ -60,7 +60,7 @@ final class ManiphestReplyHandler extends PhabricatorMailReplyHandler {
|
|||
$template->setContentSource($content_source);
|
||||
$template->setAuthorPHID($user->getPHID());
|
||||
|
||||
|
||||
$is_unsub = false;
|
||||
if ($is_new_task) {
|
||||
// If this is a new task, create a "User created this task." transaction
|
||||
// and then set the title and description.
|
||||
|
@ -100,6 +100,7 @@ final class ManiphestReplyHandler extends PhabricatorMailReplyHandler {
|
|||
$new_value = $user->getPHID();
|
||||
break;
|
||||
case 'unsubscribe':
|
||||
$is_unsub = true;
|
||||
$ttype = ManiphestTransactionType::TYPE_CCS;
|
||||
$ccs = $task->getCCPHIDs();
|
||||
foreach ($ccs as $k => $phid) {
|
||||
|
@ -119,11 +120,15 @@ final class ManiphestReplyHandler extends PhabricatorMailReplyHandler {
|
|||
$xactions[] = $xaction;
|
||||
}
|
||||
|
||||
$task->setCCPHIDs(array($user->getPHID()));
|
||||
$ccs = $mail->loadCCPHIDs();
|
||||
if ($ccs) {
|
||||
$old_ccs = $task->getCCPHIDs();
|
||||
$new_ccs = array_unique(array_merge($old_ccs, $ccs));
|
||||
$old_ccs = $task->getCCPHIDs();
|
||||
$new_ccs = array_merge($old_ccs, $ccs);
|
||||
if (!$is_unsub) {
|
||||
$new_ccs[] = $user->getPHID();
|
||||
}
|
||||
$new_ccs = array_unique($new_ccs);
|
||||
|
||||
if (array_diff($new_ccs, $old_ccs)) {
|
||||
$cc_xaction = clone $template;
|
||||
$cc_xaction->setTransactionType(ManiphestTransactionType::TYPE_CCS);
|
||||
$cc_xaction->setNewValue($new_ccs);
|
||||
|
|
|
@ -217,19 +217,20 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
|||
if ($allow_email_users) {
|
||||
$email = new PhutilEmailAddress($from);
|
||||
|
||||
$user = id(new PhabricatorExternalAccount())->loadOneWhere(
|
||||
$xuser = id(new PhabricatorExternalAccount())->loadOneWhere(
|
||||
'accountType = %s AND accountDomain IS NULL and accountID = %s',
|
||||
'email', $email->getAddress());
|
||||
|
||||
if (!$user) {
|
||||
$user = new PhabricatorExternalAccount();
|
||||
$user->setAccountID($email->getAddress());
|
||||
$user->setAccountType('email');
|
||||
$user->setDisplayName($email->getDisplayName());
|
||||
$user->save();
|
||||
'email',
|
||||
$email->getAddress());
|
||||
|
||||
if (!$xuser) {
|
||||
$xuser = new PhabricatorExternalAccount();
|
||||
$xuser->setAccountID($email->getAddress());
|
||||
$xuser->setAccountType('email');
|
||||
$xuser->setDisplayName($email->getDisplayName());
|
||||
$xuser->save();
|
||||
}
|
||||
|
||||
$user = $xuser->getPhabricatorUser();
|
||||
} else {
|
||||
$default_author = PhabricatorEnv::getEnvConfig(
|
||||
'metamta.maniphest.default-public-author');
|
||||
|
@ -260,12 +261,12 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
|||
$receiver->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE);
|
||||
|
||||
$editor = new ManiphestTransactionEditor();
|
||||
$editor->setActor($user->getPhabricatorUser());
|
||||
$editor->setActor($user);
|
||||
$handler = $editor->buildReplyHandler($receiver);
|
||||
|
||||
$handler->setActor($user->getPhabricatorUser());
|
||||
$handler->setActor($user);
|
||||
$handler->setExcludeMailRecipientPHIDs(
|
||||
$this->loadExcludeMailRecipientPHIDs());
|
||||
$this->loadExcludeMailRecipientPHIDs());
|
||||
$handler->processEmail($this);
|
||||
|
||||
$this->setRelatedPHID($receiver->getPHID());
|
||||
|
|
Loading…
Reference in a new issue