1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

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
This commit is contained in:
epriestley 2012-10-23 12:03:11 -07:00
parent 6b39af4022
commit 7749c5abf3
3 changed files with 81 additions and 58 deletions

View file

@ -558,8 +558,9 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
$xherald_header = HeraldTranscript::loadXHeraldRulesHeader(
$revision->getPHID());
$mailed_phids = array();
if (!$this->noEmail) {
id(new DifferentialCommentMail(
$mail = id(new DifferentialCommentMail(
$revision,
$actor_handle,
$comment,
@ -575,6 +576,8 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
->setXHeraldRulesHeader($xherald_header)
->setParentMessageID($this->parentMessageID)
->send();
$mailed_phids = $mail->getRawMail()->buildRecipientList();
}
$event_data = array(
@ -586,12 +589,13 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
'feedback_content' => $comment->getContent(),
'actor_phid' => $actor_phid,
);
// TODO: Get rid of this
id(new PhabricatorTimelineEvent('difx', $event_data))
->recordEvent();
// TODO: Move to a daemon?
id(new PhabricatorFeedStoryPublisher())
->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_DIFFERENTIAL)
->setStoryType('PhabricatorFeedStoryDifferential')
->setStoryData($event_data)
->setStoryTime(time())
->setStoryAuthorPHID($actor_phid)
@ -607,9 +611,10 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
array($revision->getAuthorPHID()),
$revision->getReviewers(),
$revision->getCCPHIDs()))
->setMailRecipientPHIDs($mailed_phids)
->publish();
// TODO: Move to a daemon?
// TODO: Move to workers
PhabricatorSearchDifferentialIndexer::indexRevision($revision);
return $comment;

View file

@ -420,31 +420,8 @@ final class DifferentialRevisionEditor extends PhabricatorEditor {
id(new PhabricatorTimelineEvent('difx', $event_data))
->recordEvent();
id(new PhabricatorFeedStoryPublisher())
->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_DIFFERENTIAL)
->setStoryData($event_data)
->setStoryTime(time())
->setStoryAuthorPHID($revision->getAuthorPHID())
->setRelatedPHIDs(
array(
$revision->getPHID(),
$revision->getAuthorPHID(),
))
->setPrimaryObjectPHID($revision->getPHID())
->setSubscribedPHIDs(
array_merge(
array($revision->getAuthorPHID()),
$revision->getReviewers(),
$revision->getCCPHIDs()))
->publish();
// TODO: Move this into a worker task thing.
PhabricatorSearchDifferentialIndexer::indexRevision($revision);
if ($this->silentUpdate) {
return;
}
$mailed_phids = array();
if (!$this->silentUpdate) {
$revision->loadRelationships();
if ($add['rev']) {
@ -467,12 +444,12 @@ final class DifferentialRevisionEditor extends PhabricatorEditor {
$mail[] = $message;
}
// If we added CCs, we want to send them an email, but only if they were not
// already a reviewer and were not added as one (in these cases, they got
// a "NewDiff" mail, either in the past or just a moment ago). You can still
// get two emails, but only if a revision is updated and you are added as a
// reviewer at the same time a list you are on is added as a CC, which is
// rare and reasonable.
// If we added CCs, we want to send them an email, but only if they were
// not already a reviewer and were not added as one (in these cases, they
// got a "NewDiff" mail, either in the past or just a moment ago). You can
// still get two emails, but only if a revision is updated and you are
// added as a reviewer at the same time a list you are on is added as a
// CC, which is rare and reasonable.
$implied_ccs = self::getImpliedCCs($revision);
$implied_ccs = array_fill_keys($implied_ccs, true);
@ -491,7 +468,33 @@ final class DifferentialRevisionEditor extends PhabricatorEditor {
$message->setHeraldTranscriptURI($xscript_uri);
$message->setXHeraldRulesHeader($xscript_header);
$message->send();
$mailed_phids[] = $message->getRawMail()->buildRecipientList();
}
$mailed_phids = array_mergev($mailed_phids);
}
id(new PhabricatorFeedStoryPublisher())
->setStoryType('PhabricatorFeedStoryDifferential')
->setStoryData($event_data)
->setStoryTime(time())
->setStoryAuthorPHID($revision->getAuthorPHID())
->setRelatedPHIDs(
array(
$revision->getPHID(),
$revision->getAuthorPHID(),
))
->setPrimaryObjectPHID($revision->getPHID())
->setSubscribedPHIDs(
array_merge(
array($revision->getAuthorPHID()),
$revision->getReviewers(),
$revision->getCCPHIDs()))
->setMailRecipientPHIDs($mailed_phids)
->publish();
// TODO: Move this into a worker task thing.
PhabricatorSearchDifferentialIndexer::indexRevision($revision);
}
public static function addCCAndUpdateRevision(

View file

@ -35,6 +35,15 @@ abstract class DifferentialMail {
protected $replyHandler;
protected $parentMessageID;
private $rawMail;
public function getRawMail() {
if (!$this->rawMail) {
throw new Exception("Call send() before getRawMail()!");
}
return $this->rawMail;
}
protected function renderSubject() {
$revision = $this->getRevision();
$title = $revision->getTitle();
@ -187,6 +196,10 @@ abstract class DifferentialMail {
$this->prepareBody();
$this->rawMail = clone $template;
$this->rawMail->addTos($to_phids);
$this->rawMail->addCCs($cc_phids);
$mails = $reply_handler->multiplexMail($template, $to_handles, $cc_handles);
$original_translator = PhutilTranslator::getInstance();
@ -236,6 +249,8 @@ abstract class DifferentialMail {
}
PhutilTranslator::setInstance($original_translator);
return $this;
}
protected function getMailTags() {