Page MenuHomePhabricator

D16733.id40325.diff
No OneTemporary

D16733.id40325.diff

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,9 @@
const ERROR_EMPTY_PARTICIPANTS = 'error-empty-participants';
const ERROR_EMPTY_MESSAGE = 'error-empty-message';
+ private $addedParticipants = array();
+ private $removedParticipants = array();
+
public function getEditorApplicationClass() {
return 'PhabricatorConpherenceApplication';
}
@@ -330,6 +333,17 @@
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);
+ $this->removedParticipants = array_diff_key($old_map, $new_map);
+ break;
+ }
+ }
+
$message_count = 0;
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {
@@ -479,35 +493,53 @@
}
$participant_phids = mpull($participants, 'getParticipantPHID');
+ $rem = $this->removedParticipants;
+ $add = $this->addedParticipants;
+ $all_phids = array_fuse($participant_phids, $rem);
$users = id(new PhabricatorPeopleQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
- ->withPHIDs($participant_phids)
+ ->withPHIDs($all_phids)
->needUserSettings(true)
->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;
+
foreach ($participants as $phid => $participant) {
$user = idx($users, $phid);
if ($user) {
- $default = $user->getUserSetting($notification_key);
+ $default = $user->getUserSetting($new_message_key);
+ $default_status = $user->getUserSetting($status_key);
} else {
- $default = $notification_email;
+ $default = $new_message_email;
}
$settings = $participant->getSettings();
$notifications = idx($settings, 'notifications', $default);
- if ($notifications == $notification_email) {
+ // Email people who want new message emails
+ if ($notifications == $new_message_email) {
+ $to_phids[] = $phid;
+ }
+
+ $joined = array_key_exists($add[$phid]);
+ $left = array_key_exists($rem[$phid]);
+
+ // Email people who want participant status change emails
+ if (($left || $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 @@
<?php
-final class PhabricatorConpherenceNotificationsSetting
+final class PhabricatorConpherenceParticipantSetting
extends PhabricatorSelectSetting {
- const SETTINGKEY = 'conph-notifications';
+ const SETTINGKEY = 'conph-participant-notifications';
- const VALUE_CONPHERENCE_EMAIL = '0';
- const VALUE_CONPHERENCE_NOTIFY = '1';
+ const VALUE_CONPHERENCE_PART_EMAIL = '0';
+ const VALUE_CONPHERENCE_PART_NOTIFY = '1';
public function getSettingName() {
- return pht('Conpherence Notifications');
+ return pht('Participation Status');
}
public function getSettingPanelKey() {
@@ -18,7 +18,8 @@
protected function getControlInstructions() {
return pht(
- 'Choose the default notification behavior for Conpherence rooms.');
+ 'Choose the default notification behavior for being added or removed '.
+ 'from Conpherence rooms.');
}
protected function isEnabledForViewer(PhabricatorUser $viewer) {
@@ -28,7 +29,7 @@
}
public function getSettingDefaultValue() {
- return self::VALUE_CONPHERENCE_EMAIL;
+ return self::VALUE_CONPHERENCE_PART_EMAIL;
}
protected function getSelectOptions() {
@@ -42,8 +43,8 @@
private static function getOptionsMap() {
return array(
- self::VALUE_CONPHERENCE_EMAIL => 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'),
);
}

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 5, 7:37 AM (58 m, 24 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6737551
Default Alt Text
D16733.id40325.diff (7 KB)

Event Timeline