Skip to content

Commit

Permalink
Fix: Missing checks for Troubleshoot > Disable Notifications (#17155)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok authored Apr 3, 2020
1 parent 6e27845 commit ff8017a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
9 changes: 7 additions & 2 deletions app/lib/server/functions/notifications/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ export function shouldNotifyAudio({
return false;
}

if (!audioNotifications && settings.get('Accounts_Default_User_Preferences_audioNotifications') === 'all') {
return true;
if (!audioNotifications) {
if (settings.get('Accounts_Default_User_Preferences_audioNotifications') === 'all') {
return true;
}
if (settings.get('Accounts_Default_User_Preferences_audioNotifications') === 'nothing') {
return false;
}
}

return roomType === 'd' || (!disableAllMessageNotifications && (hasMentionToAll || hasMentionToHere)) || isHighlighted || audioNotifications === 'all' || hasMentionToUser || hasReplyToThread;
Expand Down
15 changes: 14 additions & 1 deletion app/lib/server/lib/sendNotificationsOnMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { sendSinglePush, shouldNotifyMobile } from '../functions/notifications/m
import { notifyDesktopUser, shouldNotifyDesktop } from '../functions/notifications/desktop';
import { notifyAudioUser, shouldNotifyAudio } from '../functions/notifications/audio';

let TroubleshootDisableNotifications;

export const sendNotification = async ({
subscription,
sender,
Expand All @@ -24,6 +26,10 @@ export const sendNotification = async ({
mentionIds,
disableAllMessageNotifications,
}) => {
if (TroubleshootDisableNotifications === true) {
return;
}

// don't notify the sender
if (subscription.u._id === sender._id) {
return;
Expand Down Expand Up @@ -187,6 +193,10 @@ const lookup = {
};

export async function sendMessageNotifications(message, room, usersInThread = []) {
if (TroubleshootDisableNotifications === true) {
return;
}

const sender = roomTypes.getConfig(room.t).getMsgSender(message.u._id);
if (!sender) {
return message;
Expand Down Expand Up @@ -287,6 +297,10 @@ export async function sendMessageNotifications(message, room, usersInThread = []
}

export async function sendAllNotifications(message, room) {
if (TroubleshootDisableNotifications === true) {
return;
}

// threads
if (message.tmid) {
return message;
Expand Down Expand Up @@ -353,7 +367,6 @@ export async function sendAllNotifications(message, room) {
return message;
}

let TroubleshootDisableNotifications;
settings.get('Troubleshoot_Disable_Notifications', (key, value) => {
if (TroubleshootDisableNotifications === value) { return; }
TroubleshootDisableNotifications = value;
Expand Down

0 comments on commit ff8017a

Please sign in to comment.