@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.

Mark notifications as read in Differential if we also sent an email

Summary: See D3789. Same thing for Differential.

Test Plan: Created a new revision and made a comment. Verified reviewer got popup notifications but the in-app notifications were delivered already marked as read.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1403

Differential Revision: https://secure.phabricator.com/D3790

+81 -58
+9 -4
src/applications/differential/editor/DifferentialCommentEditor.php
··· 558 558 $xherald_header = HeraldTranscript::loadXHeraldRulesHeader( 559 559 $revision->getPHID()); 560 560 561 + $mailed_phids = array(); 561 562 if (!$this->noEmail) { 562 - id(new DifferentialCommentMail( 563 + $mail = id(new DifferentialCommentMail( 563 564 $revision, 564 565 $actor_handle, 565 566 $comment, ··· 575 576 ->setXHeraldRulesHeader($xherald_header) 576 577 ->setParentMessageID($this->parentMessageID) 577 578 ->send(); 579 + 580 + $mailed_phids = $mail->getRawMail()->buildRecipientList(); 578 581 } 579 582 580 583 $event_data = array( ··· 586 589 'feedback_content' => $comment->getContent(), 587 590 'actor_phid' => $actor_phid, 588 591 ); 592 + 593 + // TODO: Get rid of this 589 594 id(new PhabricatorTimelineEvent('difx', $event_data)) 590 595 ->recordEvent(); 591 596 592 - // TODO: Move to a daemon? 593 597 id(new PhabricatorFeedStoryPublisher()) 594 - ->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_DIFFERENTIAL) 598 + ->setStoryType('PhabricatorFeedStoryDifferential') 595 599 ->setStoryData($event_data) 596 600 ->setStoryTime(time()) 597 601 ->setStoryAuthorPHID($actor_phid) ··· 607 611 array($revision->getAuthorPHID()), 608 612 $revision->getReviewers(), 609 613 $revision->getCCPHIDs())) 614 + ->setMailRecipientPHIDs($mailed_phids) 610 615 ->publish(); 611 616 612 - // TODO: Move to a daemon? 617 + // TODO: Move to workers 613 618 PhabricatorSearchDifferentialIndexer::indexRevision($revision); 614 619 615 620 return $comment;
+57 -54
src/applications/differential/editor/DifferentialRevisionEditor.php
··· 420 420 id(new PhabricatorTimelineEvent('difx', $event_data)) 421 421 ->recordEvent(); 422 422 423 + $mailed_phids = array(); 424 + if (!$this->silentUpdate) { 425 + $revision->loadRelationships(); 426 + 427 + if ($add['rev']) { 428 + $message = id(new DifferentialNewDiffMail( 429 + $revision, 430 + $actor_handle, 431 + $changesets)) 432 + ->setIsFirstMailAboutRevision($is_new) 433 + ->setIsFirstMailToRecipients(true) 434 + ->setToPHIDs(array_keys($add['rev'])); 435 + 436 + if ($is_new) { 437 + // The first time we send an email about a revision, put the CCs in 438 + // the "CC:" field of the same "Review Requested" email that reviewers 439 + // get, so you don't get two initial emails if you're on a list that 440 + // is CC'd. 441 + $message->setCCPHIDs(array_keys($add['ccs'])); 442 + } 443 + 444 + $mail[] = $message; 445 + } 446 + 447 + // If we added CCs, we want to send them an email, but only if they were 448 + // not already a reviewer and were not added as one (in these cases, they 449 + // got a "NewDiff" mail, either in the past or just a moment ago). You can 450 + // still get two emails, but only if a revision is updated and you are 451 + // added as a reviewer at the same time a list you are on is added as a 452 + // CC, which is rare and reasonable. 453 + 454 + $implied_ccs = self::getImpliedCCs($revision); 455 + $implied_ccs = array_fill_keys($implied_ccs, true); 456 + $add['ccs'] = array_diff_key($add['ccs'], $implied_ccs); 457 + 458 + if (!$is_new && $add['ccs']) { 459 + $mail[] = id(new DifferentialCCWelcomeMail( 460 + $revision, 461 + $actor_handle, 462 + $changesets)) 463 + ->setIsFirstMailToRecipients(true) 464 + ->setToPHIDs(array_keys($add['ccs'])); 465 + } 466 + 467 + foreach ($mail as $message) { 468 + $message->setHeraldTranscriptURI($xscript_uri); 469 + $message->setXHeraldRulesHeader($xscript_header); 470 + $message->send(); 471 + 472 + $mailed_phids[] = $message->getRawMail()->buildRecipientList(); 473 + } 474 + $mailed_phids = array_mergev($mailed_phids); 475 + } 476 + 423 477 id(new PhabricatorFeedStoryPublisher()) 424 - ->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_DIFFERENTIAL) 478 + ->setStoryType('PhabricatorFeedStoryDifferential') 425 479 ->setStoryData($event_data) 426 480 ->setStoryTime(time()) 427 481 ->setStoryAuthorPHID($revision->getAuthorPHID()) ··· 436 490 array($revision->getAuthorPHID()), 437 491 $revision->getReviewers(), 438 492 $revision->getCCPHIDs())) 493 + ->setMailRecipientPHIDs($mailed_phids) 439 494 ->publish(); 440 495 441 - // TODO: Move this into a worker task thing. 496 + // TODO: Move this into a worker task thing. 442 497 PhabricatorSearchDifferentialIndexer::indexRevision($revision); 443 - 444 - if ($this->silentUpdate) { 445 - return; 446 - } 447 - 448 - $revision->loadRelationships(); 449 - 450 - if ($add['rev']) { 451 - $message = id(new DifferentialNewDiffMail( 452 - $revision, 453 - $actor_handle, 454 - $changesets)) 455 - ->setIsFirstMailAboutRevision($is_new) 456 - ->setIsFirstMailToRecipients(true) 457 - ->setToPHIDs(array_keys($add['rev'])); 458 - 459 - if ($is_new) { 460 - // The first time we send an email about a revision, put the CCs in 461 - // the "CC:" field of the same "Review Requested" email that reviewers 462 - // get, so you don't get two initial emails if you're on a list that 463 - // is CC'd. 464 - $message->setCCPHIDs(array_keys($add['ccs'])); 465 - } 466 - 467 - $mail[] = $message; 468 - } 469 - 470 - // If we added CCs, we want to send them an email, but only if they were not 471 - // already a reviewer and were not added as one (in these cases, they got 472 - // a "NewDiff" mail, either in the past or just a moment ago). You can still 473 - // get two emails, but only if a revision is updated and you are added as a 474 - // reviewer at the same time a list you are on is added as a CC, which is 475 - // rare and reasonable. 476 - 477 - $implied_ccs = self::getImpliedCCs($revision); 478 - $implied_ccs = array_fill_keys($implied_ccs, true); 479 - $add['ccs'] = array_diff_key($add['ccs'], $implied_ccs); 480 - 481 - if (!$is_new && $add['ccs']) { 482 - $mail[] = id(new DifferentialCCWelcomeMail( 483 - $revision, 484 - $actor_handle, 485 - $changesets)) 486 - ->setIsFirstMailToRecipients(true) 487 - ->setToPHIDs(array_keys($add['ccs'])); 488 - } 489 - 490 - foreach ($mail as $message) { 491 - $message->setHeraldTranscriptURI($xscript_uri); 492 - $message->setXHeraldRulesHeader($xscript_header); 493 - $message->send(); 494 - } 495 498 } 496 499 497 500 public static function addCCAndUpdateRevision(
+15
src/applications/differential/mail/DifferentialMail.php
··· 35 35 protected $replyHandler; 36 36 protected $parentMessageID; 37 37 38 + private $rawMail; 39 + 40 + public function getRawMail() { 41 + if (!$this->rawMail) { 42 + throw new Exception("Call send() before getRawMail()!"); 43 + } 44 + return $this->rawMail; 45 + } 46 + 38 47 protected function renderSubject() { 39 48 $revision = $this->getRevision(); 40 49 $title = $revision->getTitle(); ··· 187 196 188 197 $this->prepareBody(); 189 198 199 + $this->rawMail = clone $template; 200 + $this->rawMail->addTos($to_phids); 201 + $this->rawMail->addCCs($cc_phids); 202 + 190 203 $mails = $reply_handler->multiplexMail($template, $to_handles, $cc_handles); 191 204 192 205 $original_translator = PhutilTranslator::getInstance(); ··· 236 249 } 237 250 238 251 PhutilTranslator::setInstance($original_translator); 252 + 253 + return $this; 239 254 } 240 255 241 256 protected function getMailTags() {