The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/rocketchat-utils/lib/getUserNotificationPreferen...

31 lines
872 B

import { settings } from 'meteor/rocketchat:settings';
import { Users } from 'meteor/rocketchat:models';
export const getUserNotificationPreference = (user, pref) => {
if (typeof user === 'string') {
user = Users.findOneById(user);
}
let preferenceKey;
switch (pref) {
case 'desktop': preferenceKey = 'desktopNotifications'; break;
case 'mobile': preferenceKey = 'mobileNotifications'; break;
case 'email': preferenceKey = 'emailNotificationMode'; break;
}
if (user && user.settings && user.settings.preferences && user.settings.preferences[preferenceKey] !== 'default') {
return {
value: user.settings.preferences[preferenceKey],
origin: 'user',
};
}
const serverValue = settings.get(`Accounts_Default_User_Preferences_${ preferenceKey }`);
if (serverValue) {
return {
value: serverValue,
origin: 'server',
};
}
return null;
};