Stick behind a feature flag

pull/21833/head
Will Hunt 2019-04-21 18:01:26 +01:00
parent 776210c135
commit 0f2cd6ea73
5 changed files with 25 additions and 14 deletions

View File

@ -120,11 +120,11 @@ const Notifier = {
};
},
_playAudioNotification: function(ev, room) {
this.getSoundForRoom(room.roomId).then((sound) => {
console.log(`Got sound ${sound.name || "default"} for ${room.roomId}`);
// XXX: How do we ensure this is a sound file and not
// going to be exploited?
_playAudioNotification: async function(ev, room) {
const sound = SettingsStore.isFeatureEnabled("feature_notification_sounds") ? await this.getSoundForRoom(room.roomId) : null;
console.log(`Got sound ${sound.name || "default"} for ${room.roomId}`);
// XXX: How do we ensure this is a sound file and not going to be exploited?
try {
const selector = document.querySelector(sound ? `audio[src='${sound.url}']` : "#messageAudio");
let audioElement = selector;
if (!selector) {
@ -139,9 +139,9 @@ const Notifier = {
document.body.appendChild(audioElement);
}
audioElement.play();
}).catch((ex) => {
} catch (ex) {
console.warn("Caught error when trying to fetch room notification sound:", ex);
});
}
},
start: function() {

View File

@ -25,6 +25,7 @@ import SecurityRoomSettingsTab from "../settings/tabs/room/SecurityRoomSettingsT
import NotificationSettingsTab from "../settings/tabs/room/NotificationSettingsTab";
import sdk from "../../../index";
import MatrixClientPeg from "../../../MatrixClientPeg";
import SettingsStore from '../../../settings/SettingsStore';
export default class RoomSettingsDialog extends React.Component {
static propTypes = {
@ -50,11 +51,15 @@ export default class RoomSettingsDialog extends React.Component {
"mx_RoomSettingsDialog_rolesIcon",
<RolesRoomSettingsTab roomId={this.props.roomId} />,
));
tabs.push(new Tab(
_td("Notifications"),
"mx_RoomSettingsDialog_rolesIcon",
<NotificationSettingsTab roomId={this.props.roomId} />,
));
if (SettingsStore.isFeatureEnabled("feature_notification_sounds")) {
tabs.push(new Tab(
_td("Notifications"),
"mx_RoomSettingsDialog_rolesIcon",
<NotificationSettingsTab roomId={this.props.roomId} />,
));
}
tabs.push(new Tab(
_td("Advanced"),
"mx_RoomSettingsDialog_warningIcon",

View File

@ -115,7 +115,7 @@ export default class NotificationsSettingsTab extends React.Component {
<div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'>
<span className='mx_SettingsTab_subheading'>{_t("Sounds")}</span>
<div>
<span>{_t("Notification sound")}: <code>{this.state.currentSound}</code></span>
<span>{_t("Custom Notification Sounds")}: <code>{this.state.currentSound}</code></span>
</div>
<div>
<h3>{_t("Set a new custom sound")}</h3>

View File

@ -1616,7 +1616,7 @@
"Failed to remove tag %(tagName)s from room": "Failed to remove tag %(tagName)s from room",
"Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room",
"Sounds": "Sounds",
"Notification sound": "Notification sound",
"Custom Notification Sounds": "Notification sound",
"Set a new custom sound": "Set a new custom sound",
"Reset to default sound": "Reset to default sound"
}

View File

@ -119,6 +119,12 @@ export const SETTINGS = {
supportedLevels: LEVELS_FEATURE,
default: false,
},
"feature_notification_sounds": {
isFeature: true,
displayName: _td("Custom Notification Sounds"),
supportedLevels: LEVELS_FEATURE,
default: false,
},
"MessageComposerInput.suggestEmoji": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: _td('Enable Emoji suggestions while typing'),