From 951864d388f34bce10e12699e591a14a8e732a6c Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 23 Oct 2012 12:01:40 -0700 Subject: [PATCH] Allow notifications to be published as read if the user also is getting an email Summary: See discussion in T1403. Possibly we'll add a preference for this or something? Test Plan: Not yet in use. See future diff. Reviewers: btrahan, vrana Reviewed By: vrana CC: aran Maniphest Tasks: T1403 Differential Revision: https://secure.phabricator.com/D3784 --- .../feed/PhabricatorFeedStoryPublisher.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/applications/feed/PhabricatorFeedStoryPublisher.php b/src/applications/feed/PhabricatorFeedStoryPublisher.php index 0262f86af9..19458d41a0 100644 --- a/src/applications/feed/PhabricatorFeedStoryPublisher.php +++ b/src/applications/feed/PhabricatorFeedStoryPublisher.php @@ -25,6 +25,7 @@ final class PhabricatorFeedStoryPublisher { private $storyAuthorPHID; private $primaryObjectPHID; private $subscribedPHIDs = array(); + private $mailRecipientPHIDs = array(); public function setRelatedPHIDs(array $phids) { $this->relatedPHIDs = $phids; @@ -60,6 +61,11 @@ final class PhabricatorFeedStoryPublisher { return $this; } + public function setMailRecipientPHIDs(array $phids) { + $this->mailRecipientPHIDs = $phids; + return $this; + } + public function publish() { $class = $this->storyType; if (!$class) { @@ -136,14 +142,22 @@ final class PhabricatorFeedStoryPublisher { $sql = array(); $conn = $notif->establishConnection('w'); + $will_receive_mail = array_fill_keys($this->mailRecipientPHIDs, true); + foreach (array_unique($subscribed_phids) as $user_phid) { + if (isset($will_receive_mail[$user_phid])) { + $mark_read = 1; + } else { + $mark_read = 0; + } + $sql[] = qsprintf( $conn, '(%s, %s, %s, %d)', $this->primaryObjectPHID, $user_phid, $chrono_key, - 0); + $mark_read); } queryfx(