diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2280,6 +2280,7 @@ 'PhabricatorConpherenceColumnMinimizeSetting' => 'applications/settings/setting/PhabricatorConpherenceColumnMinimizeSetting.php', 'PhabricatorConpherenceColumnVisibleSetting' => 'applications/settings/setting/PhabricatorConpherenceColumnVisibleSetting.php', 'PhabricatorConpherenceNotificationsSetting' => 'applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php', + 'PhabricatorConpherenceParticipantSetting' => 'applications/settings/setting/PhabricatorConpherenceParticipantSetting.php', 'PhabricatorConpherencePreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php', 'PhabricatorConpherenceThreadPHIDType' => 'applications/conpherence/phid/PhabricatorConpherenceThreadPHIDType.php', 'PhabricatorConpherenceWidgetVisibleSetting' => 'applications/settings/setting/PhabricatorConpherenceWidgetVisibleSetting.php', @@ -7143,6 +7144,7 @@ 'PhabricatorConpherenceColumnMinimizeSetting' => 'PhabricatorInternalSetting', 'PhabricatorConpherenceColumnVisibleSetting' => 'PhabricatorInternalSetting', 'PhabricatorConpherenceNotificationsSetting' => 'PhabricatorSelectSetting', + 'PhabricatorConpherenceParticipantSetting' => 'PhabricatorSelectSetting', 'PhabricatorConpherencePreferencesSettingsPanel' => 'PhabricatorEditEngineSettingsPanel', 'PhabricatorConpherenceThreadPHIDType' => 'PhabricatorPHIDType', 'PhabricatorConpherenceWidgetVisibleSetting' => 'PhabricatorInternalSetting', diff --git a/src/applications/conpherence/editor/ConpherenceEditor.php b/src/applications/conpherence/editor/ConpherenceEditor.php --- a/src/applications/conpherence/editor/ConpherenceEditor.php +++ b/src/applications/conpherence/editor/ConpherenceEditor.php @@ -5,6 +5,8 @@ const ERROR_EMPTY_PARTICIPANTS = 'error-empty-participants'; const ERROR_EMPTY_MESSAGE = 'error-empty-message'; + private $addedParticipants = array(); + public function getEditorApplicationClass() { return 'PhabricatorConpherenceApplication'; } @@ -330,6 +332,16 @@ return $xactions; } + foreach ($xactions as $xaction) { + switch ($xaction->getTransactionType()) { + case ConpherenceTransaction::TYPE_PARTICIPANTS: + $old_map = array_fuse($xaction->getOldValue()); + $new_map = array_fuse($xaction->getNewValue()); + $this->addedParticipants = array_diff_key($new_map, $old_map); + break; + } + } + $message_count = 0; foreach ($xactions as $xaction) { switch ($xaction->getTransactionType()) { @@ -479,6 +491,7 @@ } $participant_phids = mpull($participants, 'getParticipantPHID'); + $added = $this->addedParticipants; $users = id(new PhabricatorPeopleQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) @@ -487,27 +500,47 @@ ->execute(); $users = mpull($users, null, 'getPHID'); - $notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY; - $notification_email = + $new_message_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY; + $new_message_email = PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL; + $status_key = PhabricatorConpherenceParticipantSetting::SETTINGKEY; + $status_email = + PhabricatorConpherenceParticipantSetting::VALUE_CONPHERENCE_PART_EMAIL; + + // Email people who want new message emails foreach ($participants as $phid => $participant) { $user = idx($users, $phid); if ($user) { - $default = $user->getUserSetting($notification_key); + $default = $user->getUserSetting($new_message_key); } else { - $default = $notification_email; + $default = $new_message_email; } $settings = $participant->getSettings(); $notifications = idx($settings, 'notifications', $default); - if ($notifications == $notification_email) { + if ($notifications == $new_message_email) { + $to_phids[] = $phid; + } + } + + // Email people who want participant status change emails + foreach ($added as $phid) { + $user = idx($users, $phid); + if ($user) { + $default_status = $user->getUserSetting($status_key); + } else { + $default = $status_email; + } + $joined = array_key_exists($phid, $added); + + if (($joined) && ($default_status == $status_email)) { $to_phids[] = $phid; } } - return $to_phids; + return array_unique($to_phids); } protected function getMailCC(PhabricatorLiskDAO $object) { diff --git a/src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php b/src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php --- a/src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php +++ b/src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php @@ -9,7 +9,7 @@ const VALUE_CONPHERENCE_NOTIFY = '1'; public function getSettingName() { - return pht('Conpherence Notifications'); + return pht('New Message'); } public function getSettingPanelKey() { @@ -18,7 +18,7 @@ protected function getControlInstructions() { return pht( - 'Choose the default notification behavior for Conpherence rooms.'); + 'Choose the default new message behavior for Conpherence rooms.'); } protected function isEnabledForViewer(PhabricatorUser $viewer) { @@ -28,7 +28,7 @@ } public function getSettingDefaultValue() { - return self::VALUE_CONPHERENCE_EMAIL; + return self::VALUE_CONPHERENCE_NOTIFY; } protected function getSelectOptions() { diff --git a/src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php b/src/applications/settings/setting/PhabricatorConpherenceParticipantSetting.php copy from src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php copy to src/applications/settings/setting/PhabricatorConpherenceParticipantSetting.php --- a/src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php +++ b/src/applications/settings/setting/PhabricatorConpherenceParticipantSetting.php @@ -1,15 +1,15 @@ pht('Send Email'), - self::VALUE_CONPHERENCE_NOTIFY => pht('Send Notifications'), + self::VALUE_CONPHERENCE_PART_EMAIL => pht('Send Email'), + self::VALUE_CONPHERENCE_PART_NOTIFY => pht('Send Notification'), ); }