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(