@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+23 -17
+10 -5
src/applications/maniphest/ManiphestReplyHandler.php
··· 60 60 $template->setContentSource($content_source); 61 61 $template->setAuthorPHID($user->getPHID()); 62 62 63 - 63 + $is_unsub = false; 64 64 if ($is_new_task) { 65 65 // If this is a new task, create a "User created this task." transaction 66 66 // and then set the title and description. ··· 100 100 $new_value = $user->getPHID(); 101 101 break; 102 102 case 'unsubscribe': 103 + $is_unsub = true; 103 104 $ttype = ManiphestTransactionType::TYPE_CCS; 104 105 $ccs = $task->getCCPHIDs(); 105 106 foreach ($ccs as $k => $phid) { ··· 119 120 $xactions[] = $xaction; 120 121 } 121 122 122 - $task->setCCPHIDs(array($user->getPHID())); 123 123 $ccs = $mail->loadCCPHIDs(); 124 - if ($ccs) { 125 - $old_ccs = $task->getCCPHIDs(); 126 - $new_ccs = array_unique(array_merge($old_ccs, $ccs)); 124 + $old_ccs = $task->getCCPHIDs(); 125 + $new_ccs = array_merge($old_ccs, $ccs); 126 + if (!$is_unsub) { 127 + $new_ccs[] = $user->getPHID(); 128 + } 129 + $new_ccs = array_unique($new_ccs); 130 + 131 + if (array_diff($new_ccs, $old_ccs)) { 127 132 $cc_xaction = clone $template; 128 133 $cc_xaction->setTransactionType(ManiphestTransactionType::TYPE_CCS); 129 134 $cc_xaction->setNewValue($new_ccs);
+13 -12
src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php
··· 217 217 if ($allow_email_users) { 218 218 $email = new PhutilEmailAddress($from); 219 219 220 - $user = id(new PhabricatorExternalAccount())->loadOneWhere( 220 + $xuser = id(new PhabricatorExternalAccount())->loadOneWhere( 221 221 'accountType = %s AND accountDomain IS NULL and accountID = %s', 222 - 'email', $email->getAddress()); 222 + 'email', 223 + $email->getAddress()); 223 224 224 - if (!$user) { 225 - $user = new PhabricatorExternalAccount(); 226 - $user->setAccountID($email->getAddress()); 227 - $user->setAccountType('email'); 228 - $user->setDisplayName($email->getDisplayName()); 229 - $user->save(); 230 - 225 + if (!$xuser) { 226 + $xuser = new PhabricatorExternalAccount(); 227 + $xuser->setAccountID($email->getAddress()); 228 + $xuser->setAccountType('email'); 229 + $xuser->setDisplayName($email->getDisplayName()); 230 + $xuser->save(); 231 231 } 232 232 233 + $user = $xuser->getPhabricatorUser(); 233 234 } else { 234 235 $default_author = PhabricatorEnv::getEnvConfig( 235 236 'metamta.maniphest.default-public-author'); ··· 260 261 $receiver->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE); 261 262 262 263 $editor = new ManiphestTransactionEditor(); 263 - $editor->setActor($user->getPhabricatorUser()); 264 + $editor->setActor($user); 264 265 $handler = $editor->buildReplyHandler($receiver); 265 266 266 - $handler->setActor($user->getPhabricatorUser()); 267 + $handler->setActor($user); 267 268 $handler->setExcludeMailRecipientPHIDs( 268 - $this->loadExcludeMailRecipientPHIDs()); 269 + $this->loadExcludeMailRecipientPHIDs()); 269 270 $handler->processEmail($this); 270 271 271 272 $this->setRelatedPHID($receiver->getPHID());