diff --git a/client/startup/unread.js b/client/startup/unread.js index 634075c748da..258bfa418a2d 100644 --- a/client/startup/unread.js +++ b/client/startup/unread.js @@ -32,7 +32,7 @@ Meteor.startup(function() { // Increment the total unread count. unreadCount += subscription.unread; if (subscription.alert === true && subscription.unreadAlert !== 'nothing') { - const userUnreadAlert = Meteor.user() && Meteor.user().settings && Meteor.user().settings.preferences && Meteor.user().settings.preferences.unreadAlert; + const userUnreadAlert = RocketChat.getUserPreference(Meteor.user(), 'unreadAlert'); if (subscription.unreadAlert === 'all' || userUnreadAlert !== false) { unreadAlert = '•'; } diff --git a/packages/rocketchat-emoji-emojione/rocketchat.js b/packages/rocketchat-emoji-emojione/rocketchat.js index 62207d31662b..48d15ba3b6eb 100644 --- a/packages/rocketchat-emoji-emojione/rocketchat.js +++ b/packages/rocketchat-emoji-emojione/rocketchat.js @@ -35,8 +35,8 @@ for (const key in emojione.emojioneList) { Meteor.startup(function() { Tracker.autorun(function() { if (isSetNotNull(() => RocketChat.emoji.packages.emojione)) { - if (isSetNotNull(() => Meteor.user().settings.preferences.convertAsciiEmoji)) { - RocketChat.emoji.packages.emojione.ascii = Meteor.user().settings.preferences.convertAsciiEmoji; + if (isSetNotNull(() => RocketChat.getUserPreference(Meteor.user(), 'convertAsciiEmoji'))) { + RocketChat.emoji.packages.emojione.ascii = RocketChat.getUserPreference(Meteor.user(), 'convertAsciiEmoji'); } else { RocketChat.emoji.packages.emojione.ascii = true; } diff --git a/packages/rocketchat-emoji/client/emojiParser.js b/packages/rocketchat-emoji/client/emojiParser.js index bba9300830dd..d31b4bc77887 100644 --- a/packages/rocketchat-emoji/client/emojiParser.js +++ b/packages/rocketchat-emoji/client/emojiParser.js @@ -6,7 +6,8 @@ import s from 'underscore.string'; * @param {Object} message - The message object */ RocketChat.callbacks.add('renderMessage', (message) => { - if (isSetNotNull(() => Meteor.user().settings.preferences.useEmojis) && !Meteor.user().settings.preferences.useEmojis) { + if (isSetNotNull(() => RocketChat.getUserPreference(Meteor.user(), 'useEmojis')) && + !RocketChat.getUserPreference(Meteor.user(), 'useEmojis')) { return message; } diff --git a/packages/rocketchat-highlight-words/client/client.js b/packages/rocketchat-highlight-words/client/client.js index 22a897bdcc69..aa3c6dc5c32b 100644 --- a/packages/rocketchat-highlight-words/client/client.js +++ b/packages/rocketchat-highlight-words/client/client.js @@ -15,7 +15,7 @@ function HighlightWordsClient(message) { } } - const to_highlight = Meteor.user() && Meteor.user().settings && Meteor.user().settings.preferences && Meteor.user().settings.preferences.highlights; + const to_highlight = RocketChat.getUserPreference(Meteor.user(), 'highlights'); if (Array.isArray(to_highlight)) { to_highlight.forEach((highlight) => { if (!s.isBlank(highlight)) { diff --git a/packages/rocketchat-i18n/i18n/ca.i18n.json b/packages/rocketchat-i18n/i18n/ca.i18n.json index 7a1afcb9737b..31af00dcee70 100644 --- a/packages/rocketchat-i18n/i18n/ca.i18n.json +++ b/packages/rocketchat-i18n/i18n/ca.i18n.json @@ -40,6 +40,8 @@ "Accounts_CustomFields_Description": "Ha de ser un objecte JSON vàlid on les claus són els noms dels camps i contenen un diccionari amb les opcions del camp. Exemple:
{\n \"role\": {\n  \"type\": \"select\",\n  \"defaultValue\": \"student\",\n  \"options\": [\"teacher\", \"student\"],\n  \"required\": true,\n  \"modifyRecordField\": {\n   \"array\": true,\n   \"field\": \"roles\"\n  }\n },\n \"twitter\": {\n  \"type\": \"text\",\n  \"required\": true,\n  \"minLength\": 2,\n  \"maxLength\": 10\n }\n} ", "Accounts_CustomFieldsToShowInUserInfo": "Camps personalitzats a mostrar a l'informació d'usuari", "Accounts_DefaultUsernamePrefixSuggestion": "Prefix suggerit per al nom d'usuari per defecte", + "Accounts_Default_User_Preferences_desktopNotifications": "Alerta per defecte per a les notificacions d'escriptori", + "Accounts_Default_User_Preferences_mobileNotifications": "Alerta per defecte notificacions mòbil", "Accounts_denyUnverifiedEmail": "Denegar correu electrònic sense verificar", "Accounts_EmailVerification": "Verificació de correu electrònic", "Accounts_EmailVerification_Description": "Assegura't que la configuració SMTP és correcta per fer servir aquesta funcionalitat", @@ -478,7 +480,6 @@ "Desktop": "Escriptori", "Desktop_Notification_Test": "Prova de notificació d'escriptori", "Desktop_Notifications": "Notificacions d'escriptori", - "Desktop_Notifications_Default_Alert": "Alerta per defecte per a les notificacions d'escriptori", "Desktop_Notifications_Disabled": "Les notificacions d'escriptori han estat desactivades. Canvia les preferències del navegador si vols tornar a activar-les.", "Desktop_Notifications_Duration": "Durada de les notificacions d'escriptori", "Desktop_Notifications_Duration_Description": "Segons de mostra de les notificacions d'escriptori. Això pot afectar al centre de notificacions del macOS. Introduïu 0 per utilitzar la configuració del navegador per defecte i no afectar al centre de notificacions.", @@ -1183,7 +1184,6 @@ "Min_length_is": "La llargada mínima és %s", "minutes": "minuts", "Mobile": "Mòbil", - "Mobile_Notifications_Default_Alert": "Alerta per defecte notificacions mòbil", "Monday": "dilluns", "Monitor_history_for_changes_on": "Monitoritza l'historial per canvis a ", "More_channels": "Més canals", @@ -2006,4 +2006,4 @@ "your_message_optional": "el teu missatge (opcional)", "Your_password_is_wrong": "La contrasenya és incorrecta!", "Your_push_was_sent_to_s_devices": "La notificació push s'ha enviat a %s dispositius" -} \ No newline at end of file +} diff --git a/packages/rocketchat-i18n/i18n/cs.i18n.json b/packages/rocketchat-i18n/i18n/cs.i18n.json index 9f971f8084ab..72d997305d79 100644 --- a/packages/rocketchat-i18n/i18n/cs.i18n.json +++ b/packages/rocketchat-i18n/i18n/cs.i18n.json @@ -40,6 +40,9 @@ "Accounts_CustomFields_Description": "Validní JSON obsahující klíče polí s nastavením. Například:
{\n \"role\": {\n  \"type\": \"select\",\n  \"defaultValue\": \"student\",\n  \"options\": [\"teacher\", \"student\"],\n  \"required\": true,\n  \"modifyRecordField\": {\n   \"array\": true,\n   \"field\": \"roles\"\n  }\n },\n \"twitter\": {\n  \"type\": \"text\",\n  \"required\": true,\n  \"minLength\": 2,\n  \"maxLength\": 10\n }\n}", "Accounts_CustomFieldsToShowInUserInfo": "Vlastní pole zobrazená v uživatelském profilu", "Accounts_DefaultUsernamePrefixSuggestion": "Výchozí návrh prefixu uživatelského jména", + "Accounts_Default_User_Preferences_audioNotifications": "Výchozí zvuk upozornění audia", + "Accounts_Default_User_Preferences_desktopNotifications": "Výchozí upozornění oznámení na ploše", + "Accounts_Default_User_Preferences_mobileNotifications": "Výchozí upozornění mobilní notifikace", "Accounts_denyUnverifiedEmail": "Zakázat neověřené e-mailové adresy", "Accounts_EmailVerification": "Ověření e-mailu", "Accounts_EmailVerification_Description": "Pro použití této funkce se ujistěte, že máte správné nastavení SMTP", @@ -245,8 +248,6 @@ "Attribute_handling": "Operace s atributy", "Audio_message": "Audio zpráva", "Audio_Notification_Value_Description": "Jakýkoliv z výchozích zvuků: beep, chelle, ding, droplet, highbell, seasons", - "Audio_Notifications_Default_Alert": "Výchozí zvuk upozornění audia", - "Audio_Notifications_Value": "Výchozí zvuk upozornění zprávy", "Auth_Token": "Auth Token", "Author": "Autor", "Authorization_URL": "URL autorizace", @@ -482,7 +483,6 @@ "Desktop": "Plocha", "Desktop_Notification_Test": "Test oznámení na ploše", "Desktop_Notifications": "Oznámení na ploše", - "Desktop_Notifications_Default_Alert": "Výchozí upozornění oznámení na ploše", "Desktop_Notifications_Disabled": "Oznámení na ploše jsou vypnuta. Změňte nastavení svého prohlížeče, pokud chcete oznámení povolit.", "Desktop_Notifications_Duration": "Délka zobrazení notifikace", "Desktop_Notifications_Duration_Description": "Délka zobrazení oznámení (v sekundách). Toto může ovlivnit nastevení OS X Oznamovacího centra. Zadejte 0 pro použítí výchozí nastavení prohlížeče/notifikačního centra OS X", @@ -1224,7 +1224,6 @@ "Min_length_is": "Minimální délka je %s", "minutes": "minuty", "Mobile": "Mobilní", - "Mobile_Notifications_Default_Alert": "Výchozí upozornění mobilní notifikace", "Monday": "Pondělí", "Monitor_history_for_changes_on": "Sledovat historii na změny:", "More_channels": "Více místností", @@ -2058,4 +2057,4 @@ "your_message_optional": "vaše zpráva (nepovinná)", "Your_password_is_wrong": "Vaše heslo je špatně!", "Your_push_was_sent_to_s_devices": "Vaše notifikace byla odeslána do %s zařízení" -} \ No newline at end of file +} diff --git a/packages/rocketchat-i18n/i18n/de.i18n.json b/packages/rocketchat-i18n/i18n/de.i18n.json index 47c4d9bdbe95..4f3457a0c4a0 100644 --- a/packages/rocketchat-i18n/i18n/de.i18n.json +++ b/packages/rocketchat-i18n/i18n/de.i18n.json @@ -41,6 +41,9 @@ "Accounts_CustomFields_Description": "Ein gültiges JSON, in dem die Schlüssel Sprachkürzel sind, die wiederum Tupel von Schlüssel und Übersetzungen enthalten. Beispiel:
\n{\n \"role\": {\n  \"type\": \"select\",\n  \"defaultValue\": \"student\",\n  \"options\": [\"teacher\", \"student\"],\n  \"required\": true,\n  \"modifyRecordField\": {\n   \"array\": true,\n   \"field\": \"roles\"\n  }\n },\n \"twitter\": {\n  \"type\": \"text\",\n  \"required\": true,\n  \"minLength\": 2,\n  \"maxLength\": 10\n }\n}", "Accounts_CustomFieldsToShowInUserInfo": "Eigene Felder, die in der Benutzer-Information angezeigt werden sollen", "Accounts_DefaultUsernamePrefixSuggestion": "Vorschlag für Präfix des Standard-Benutzernamens ", + "Accounts_Default_User_Preferences_audioNotifications": "Akustische Benachrichtigung bei", + "Accounts_Default_User_Preferences_desktopNotifications": "Desktop-Benachrichtigungen bei", + "Accounts_Default_User_Preferences_mobileNotifications": "Mobile Benachrichtigungen bei", "Accounts_denyUnverifiedEmail": "Nicht verifizierte E-Mail-Adressen ablehnen", "Accounts_EmailVerification": "E-Mail-Verifizierung", "Accounts_EmailVerification_Description": "Um diese Funktion nutzen zu können, stellen Sie bitte sicher, dass ihre SMTP-Einstellungen korrekt sind.", @@ -246,8 +249,6 @@ "Attribute_handling": "Behandlung von Eigenschaften", "Audio_message": "Audio-Nachricht", "Audio_Notification_Value_Description": "Dies kann einer der Standard-Töne (beep, chelle, ding, droplet, highbell, seasons) oder jeder eigene Ton sein", - "Audio_Notifications_Default_Alert": "Akustische Benachrichtigung bei", - "Audio_Notifications_Value": "Akustische Benachrichtigung: Ton", "Auth_Token": "Auth-Token", "Author": "Autor", "Authorization_URL": "Autorisierungs-URL", @@ -483,7 +484,6 @@ "Desktop": "Desktop", "Desktop_Notification_Test": "Desktop-Benachrichtigungstest", "Desktop_Notifications": "Desktop-Benachrichtigungen", - "Desktop_Notifications_Default_Alert": "Desktop-Benachrichtigungen bei", "Desktop_Notifications_Disabled": "Desktop-Benachrichtigungen sind deaktiviert. Ändern Sie Ihre Browsereinstellungen, wenn Sie Benachrichtigungen erhalten wollen.", "Desktop_Notifications_Duration": "Desktop-Benachrichtigungsdauer", "Desktop_Notifications_Duration_Description": "Zeit in Sekunden für die Desktop-Benachrichtigungen angezeigt werden sollen. Dies kann OS X Notification Center beeinflussen. Geben Sie 0 ein, um die Standard-Browser-Einstellungen zu verwenden und OS X Notification Center nicht zu beeinflussen.", @@ -1194,7 +1194,6 @@ "Min_length_is": "Die minimale Länge beträgt %s", "minutes": "Minuten", "Mobile": "Mobil", - "Mobile_Notifications_Default_Alert": "Mobile Benachrichtigungen bei", "Monday": "Montag", "Monitor_history_for_changes_on": "Was soll für die Historie überwacht werden?", "More_channels": "Weitere Kanäle", diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 59bf4aa6105a..3b9f3c2c6b1c 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -41,6 +41,10 @@ "Accounts_CustomFields_Description": "Should be a valid JSON where keys are the field names containing a dictionary of field settings. Example:
{\n \"role\": {\n  \"type\": \"select\",\n  \"defaultValue\": \"student\",\n  \"options\": [\"teacher\", \"student\"],\n  \"required\": true,\n  \"modifyRecordField\": {\n   \"array\": true,\n   \"field\": \"roles\"\n  }\n },\n \"twitter\": {\n  \"type\": \"text\",\n  \"required\": true,\n  \"minLength\": 2,\n  \"maxLength\": 10\n }\n} ", "Accounts_CustomFieldsToShowInUserInfo": "Custom Fields to Show in User Info", "Accounts_DefaultUsernamePrefixSuggestion": "Default Username Prefix Suggestion", + "Accounts_Default_User_Preferences": "Default User Preferences", + "Accounts_Default_User_Preferences_audioNotifications": "Audio Notifications Default Alert", + "Accounts_Default_User_Preferences_desktopNotifications": "Desktop Notifications Default Alert", + "Accounts_Default_User_Preferences_mobileNotifications": "Mobile Notifications Default Alert", "Accounts_denyUnverifiedEmail": "Deny unverified email", "Accounts_EmailVerification": "Email Verification", "Accounts_EmailVerification_Description": "Make sure you have correct SMTP settings to use this feature", @@ -255,8 +259,6 @@ "Attribute_handling": "Attribute handling", "Audio_message": "Audio message", "Audio_Notification_Value_Description": "Can be any custom sound or the default ones: beep, chelle, ding, droplet, highbell, seasons", - "Audio_Notifications_Default_Alert": "Audio Notifications Default Alert", - "Audio_Notifications_Value": "Default Message Notification Audio", "Auth_Token": "Auth Token", "Author": "Author", "Authorization_URL": "Authorization URL", @@ -494,7 +496,6 @@ "Desktop": "Desktop", "Desktop_Notification_Test": "Desktop Notification Test", "Desktop_Notifications": "Desktop Notifications", - "Desktop_Notifications_Default_Alert": "Desktop Notifications Default Alert", "Desktop_Notifications_Disabled": "Desktop Notifications are Disabled. Change your browser preferences if you need Notifications enabled.", "Desktop_Notifications_Duration": "Desktop Notifications Duration", "Desktop_Notifications_Duration_Description": "Seconds to display desktop notification. This may affect OS X Notification Center. Enter 0 to use default browser settings and not affect OS X Notification Center.", @@ -1248,7 +1249,6 @@ "Minimum_balance": "Minimum balance", "minutes": "minutes", "Mobile": "Mobile", - "Mobile_Notifications_Default_Alert": "Mobile Notifications Default Alert", "Monday": "Monday", "Monitor_history_for_changes_on": "Monitor History for Changes on", "More_channels": "More channels", diff --git a/packages/rocketchat-i18n/i18n/fr.i18n.json b/packages/rocketchat-i18n/i18n/fr.i18n.json index 82240d73db89..01652705272d 100644 --- a/packages/rocketchat-i18n/i18n/fr.i18n.json +++ b/packages/rocketchat-i18n/i18n/fr.i18n.json @@ -35,6 +35,7 @@ "Accounts_BlockedUsernameList_Description": "Liste de noms d'utilisateurs bloqués (insensible à la casse), séparés par des virgules", "Accounts_CustomFields_Description": "Devrait être un JSON valide où les clés sont les noms des champs contenant un dictionnaire de champs de paramétrage. Exemple :
\n{\n \"role\": {\n  \"type\": \"select\",\n  \"defaultValue\": \"eleve\",\n  \"options\": [\"enseignant\", \"eleve\"],\n  \"required\": true,\n  \"modifyRecordField\": {\n   \"array\": true,\n   \"field\": \"roles\"\n  }\n },\n \"twitter\": {\n  \"type\": \"text\",\n  \"required\": true,\n  \"minLength\": 2,\n  \"maxLength\": 10\n }\n} ", "Accounts_DefaultUsernamePrefixSuggestion": "Suggestion par défaut du préfixe du nom d'utilisateur", + "Accounts_Default_User_Preferences_desktopNotifications": "Alterte notification de bureau par défaut", "Accounts_denyUnverifiedEmail": "Refuser les e-mails non vérifiés", "Accounts_EmailVerification": "Vérification de l'adresse e-mail", "Accounts_EmailVerification_Description": "Vous devez avoir des paramètres SMTP corrects pour utiliser cette fonctionnalité", @@ -415,7 +416,6 @@ "Desktop": "Bureau", "Desktop_Notification_Test": "Test des notifications sur le bureau", "Desktop_Notifications": "Notifications sur le bureau", - "Desktop_Notifications_Default_Alert": "Alterte notification de bureau par défaut", "Desktop_Notifications_Disabled": "Les notifications du bureau sont désactivées, Modifiez les préférences de votre navigateur si vous avez besoin de les activer.", "Desktop_Notifications_Duration": "Durée des notifications", "Desktop_Notifications_Duration_Description": "Secondes pour afficher une notification de bureau. Cela peut affecter le Centre de Notification de OS X. Entrez 0 pour utiliser les paramètres du navigateur par défaut et ne pas affecter le Centre de Notification de OS X.", @@ -1612,4 +1612,4 @@ "your_message_optional": "votre message (optionnel)", "Your_password_is_wrong": "Votre mot de passe est incorrect !", "Your_push_was_sent_to_s_devices": "Votre notification a été envoyée à %s appareils" -} \ No newline at end of file +} diff --git a/packages/rocketchat-i18n/i18n/pl.i18n.json b/packages/rocketchat-i18n/i18n/pl.i18n.json index 530f250a3337..6a731d8b78a1 100644 --- a/packages/rocketchat-i18n/i18n/pl.i18n.json +++ b/packages/rocketchat-i18n/i18n/pl.i18n.json @@ -33,6 +33,7 @@ "Accounts_BlockedDomainsList_Description": "Oddzielonych przecinkami lista zablokowanych domen", "Accounts_BlockedUsernameList": "Lista zablokowanych użytkowników", "Accounts_BlockedUsernameList_Description": "Oddzielona przecinkami lista zablokowanych użytkowników (bez uwzględniania wielkości liter)", + "Accounts_Default_User_Preferences_mobileNotifications": "Domyślne powiadomnienia mobilne", "Accounts_denyUnverifiedEmail": "Odrzucaj niezweryfikowane adresy email", "Accounts_EmailVerification": "Weryfikacja adresu email", "Accounts_EmailVerification_Description": "Upewnij się, że masz odpowiednie ustawienia SMTP by korzystać z tej funkcji", @@ -848,7 +849,6 @@ "Min_length_is": "Minimalna długość to %s", "minutes": "minut", "Mobile": "Powiadomnienia mobilne", - "Mobile_Notifications_Default_Alert": "Domyślne powiadomnienia mobilne", "Monday": "Poniedziałek", "Monitor_history_for_changes_on": "Sprawdź historię zmian na", "More_channels": "Więcej kanałów", @@ -1434,4 +1434,4 @@ "your_message_optional": "twoja wiadomość (opcjonalnie)", "Your_password_is_wrong": "To nie jest poprawne hasło!", "Your_push_was_sent_to_s_devices": "Twój push została wysłany do urządzeń: %s" -} \ No newline at end of file +} diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index 2b66cfc0b18e..1847d68194db 100644 --- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -33,6 +33,10 @@ "Accounts_BlockedUsernameList_Description": "Lista de nomes de usuários bloqueados, separada por vírgulas (não diferencia maiúsculas)", "Accounts_CustomFields_Description": "Deve ser um JSON válido onde as chaves são os nomes de campos contendo um dicionário de configuração de campos. Exemplo:
{\n \"role\": {\n  \"type\": \"select\",\n  \"defaultValue\": \"estudante\",\n  \"options\": [\"professor\", \"estudante\"],\n  \"required\": true,\n  \"modifyRecordField\": {\n   \"array\": true,\n   \"field\": \"roles\"\n  }\n },\n \"twitter\": {\n  \"type\": \"text\",\n  \"required\": true,\n  \"minLength\": 2,\n  \"maxLength\": 10\n }\n} ", "Accounts_CustomFieldsToShowInUserInfo": "Campos personalizados a exibir", + "Accounts_Default_User_Preferences": "Preferências Padrões do Usuário", + "Accounts_Default_User_Preferences_audioNotifications": "Áudio padrão para alerta de notificação", + "Accounts_Default_User_Preferences_desktopNotifications": "Alerta padrão para notificações Desktop", + "Accounts_Default_User_Preferences_mobileNotifications": "Alerta padrão para notificações Mobile", "Accounts_denyUnverifiedEmail": "Proibir e-mail não verificado", "Accounts_EmailVerification": "Verificação de E-mail", "Accounts_EmailVerification_Description": "Certifique-se de que as configurações de SMTP estão corretas para usar este recurso", diff --git a/packages/rocketchat-i18n/i18n/ru.i18n.json b/packages/rocketchat-i18n/i18n/ru.i18n.json index 8ff219e624f8..e53ffc4e24fa 100644 --- a/packages/rocketchat-i18n/i18n/ru.i18n.json +++ b/packages/rocketchat-i18n/i18n/ru.i18n.json @@ -39,6 +39,7 @@ "Accounts_CustomFields_Description": "Ожидается валидный JSON-объект, в котором каждый ключ - это имя поля, а содержимое - словарь настроек поля. Пример:
{\n \"role\": {\n  \"type\": \"select\",\n  \"defaultValue\": \"student\",\n  \"options\": [\"teacher\", \"student\"],\n  \"required\": true,\n  \"modifyRecordField\": {\n   \"array\": true,\n   \"field\": \"roles\"\n  }\n },\n \"twitter\": {\n  \"type\": \"text\",\n  \"required\": true,\n  \"minLength\": 2,\n  \"maxLength\": 10\n }\n}\n", "Accounts_CustomFieldsToShowInUserInfo": "Кастомные поля для отображения в информации пользователя", "Accounts_DefaultUsernamePrefixSuggestion": "Предлагаемая подсказка префикса логина", + "Accounts_Default_User_Preferences_desktopNotifications": "Стандартные оповещения на рабочем столе", "Accounts_denyUnverifiedEmail": "Запретить неподтверждённые адреса электронной почты", "Accounts_EmailVerification": "Подтверждение адреса электронной почты", "Accounts_EmailVerification_Description": "Убедитесь, что у вас верные настройки SMTP для использования этой функции", @@ -442,7 +443,6 @@ "Desktop": "Рабочий стол", "Desktop_Notification_Test": "Проверка уведомлений рабочего стола", "Desktop_Notifications": "Оповещения на рабочем столе", - "Desktop_Notifications_Default_Alert": "Стандартные оповещения на рабочем столе", "Desktop_Notifications_Disabled": "Оповещения отключены. Измените настройки браузера, чтобы включить уведомления.", "Desktop_Notifications_Duration": "Длительность", "Desktop_Notifications_Duration_Description": "Секунды для отображения уведомлений на рабочем столе. Это может повлиять на OS X Центр уведомлений. Введите 0, чтобы использовать настройки браузера по умолчанию и не влиять на OS X Центр уведомлений.", @@ -1731,4 +1731,4 @@ "your_message_optional": "Сообщение (опционально)", "Your_password_is_wrong": "Неверный пароль!", "Your_push_was_sent_to_s_devices": "Оповещение было отправлено на % устройств." -} \ No newline at end of file +} diff --git a/packages/rocketchat-i18n/i18n/tr.i18n.json b/packages/rocketchat-i18n/i18n/tr.i18n.json index 0761806e0886..5f0d6a8536ba 100644 --- a/packages/rocketchat-i18n/i18n/tr.i18n.json +++ b/packages/rocketchat-i18n/i18n/tr.i18n.json @@ -40,6 +40,7 @@ "Accounts_CustomFields_Description": "Anahtarların, alan ayarları sözlüğü bulunduran alan isimleri olduğu geçerli bir JSON olmalı. Örnek:
{\n\n \"role\": {\n\n  \"type\": \"select\",\n\n  \"defaultValue\": \"student\",\n\n  \"options\": [\"teacher\", \"student\"],\n\n  \"required\": true,\n\n  \"modifyRecordField\": {\n\n   \"array\": true,\n\n   \"field\": \"roles\"\n\n  }\n\n },\n\n \"twitter\": {\n\n  \"type\": \"text\",\n\n  \"required\": true,\n\n  \"minLength\": 2,\n\n  \"maxLength\": 10\n\n }\n\n} ", "Accounts_CustomFieldsToShowInUserInfo": "Kullanıcı Bilgilerini Göstermek için Özel alanlar", "Accounts_DefaultUsernamePrefixSuggestion": "Varsayılan kullanıcı adı ön eki tavsiyesi", + "Accounts_Default_User_Preferences_audioNotifications": "Sesli Mesaj için Varsayılan Uyarı", "Accounts_denyUnverifiedEmail": "Doğrulanmamış e-posta'yı reddet", "Accounts_EmailVerification": "E-Posta Doğrulama", "Accounts_EmailVerification_Description": "Bu özelliği kullanmak için doğru SMTP ayarlarına sahip olduğunuza emin olun", @@ -220,8 +221,6 @@ "AtlassianCrowd": "Atlassian Crowd", "Attachment_File_Uploaded": "Dosya Yüklendi", "Audio_message": "Sesli Mesaj", - "Audio_Notifications_Default_Alert": "Sesli Mesaj için Varsayılan Uyarı", - "Audio_Notifications_Value": "Varsayılan mesaj bildirim sesi", "Auth_Token": "Kimlik Doğrulama Jetonu", "Author": "Yazar", "Authorization_URL": "yetkilendirme URL'si", @@ -1304,4 +1303,4 @@ "Your_mail_was_sent_to_s": "Posta %s gönderildi", "Your_password_is_wrong": "Parolanız yanlış!", "Your_push_was_sent_to_s_devices": "Sizin itme %s cihazlara gönderildi" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/lib/getUserPreference.js b/packages/rocketchat-lib/lib/getUserPreference.js new file mode 100644 index 000000000000..1d516996784d --- /dev/null +++ b/packages/rocketchat-lib/lib/getUserPreference.js @@ -0,0 +1,16 @@ +/** + * Tries to retrieve the user preference falling back to a default system + * value or to a default value if it is passed as argument +*/ +RocketChat.getUserPreference = function(user, key, defaultValue=undefined) { + let preference; + + if (user && user.settings && user.settings.preferences && + user.settings.preferences.hasOwnProperty(key)) { + preference = user.settings.preferences[key]; + } else if (defaultValue === undefined) { + preference = RocketChat.settings.get(`Accounts_Default_User_Preferences_${ key }`); + } + + return preference !== undefined ? preference : defaultValue; +}; diff --git a/packages/rocketchat-lib/lib/roomTypes/channels.js b/packages/rocketchat-lib/lib/roomTypes/channels.js index cd39eeeb37bc..4d0fbcc1a837 100644 --- a/packages/rocketchat-lib/lib/roomTypes/channels.js +++ b/packages/rocketchat-lib/lib/roomTypes/channels.js @@ -11,7 +11,8 @@ export class ChannelsRoomType extends RoomTypeConfig { condition() { const user = Meteor.user(); - const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {}; - return ['unread', 'category'].includes(preferences.roomsListExhibitionMode) && preferences.mergeChannels; + const roomsListExhibitionMode = RocketChat.getUserPreference(user, 'roomsListExhibitionMode'); + const mergeChannels = RocketChat.getUserPreference(user, 'mergeChannels'); + return ['unread', 'category'].includes(roomsListExhibitionMode) && mergeChannels; } } diff --git a/packages/rocketchat-lib/lib/roomTypes/conversation.js b/packages/rocketchat-lib/lib/roomTypes/conversation.js index 1aaa9faa2374..009dbf59ccbf 100644 --- a/packages/rocketchat-lib/lib/roomTypes/conversation.js +++ b/packages/rocketchat-lib/lib/roomTypes/conversation.js @@ -11,7 +11,6 @@ export class ConversationRoomType extends RoomTypeConfig { condition() { const user = Meteor.user(); - const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {}; - return preferences.roomsListExhibitionMode === 'activity'; + return RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'activity'; } } diff --git a/packages/rocketchat-lib/lib/roomTypes/direct.js b/packages/rocketchat-lib/lib/roomTypes/direct.js index c98a3f4b3aae..9a2899615144 100644 --- a/packages/rocketchat-lib/lib/roomTypes/direct.js +++ b/packages/rocketchat-lib/lib/roomTypes/direct.js @@ -62,9 +62,8 @@ export class DirectMessageRoomType extends RoomTypeConfig { condition() { const user = Meteor.user(); - const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {}; - - return !preferences.roomsListExhibitionMode || ['unread', 'category'].includes(preferences.roomsListExhibitionMode) && RocketChat.authz.hasAtLeastOnePermission(['view-d-room', 'view-joined-room']); + const roomsListExhibitionMode = RocketChat.getUserPreference(user, 'roomsListExhibitionMode'); + return !roomsListExhibitionMode || ['unread', 'category'].includes(roomsListExhibitionMode) && RocketChat.authz.hasAtLeastOnePermission(['view-d-room', 'view-joined-room']); } getUserStatus(roomId) { diff --git a/packages/rocketchat-lib/lib/roomTypes/private.js b/packages/rocketchat-lib/lib/roomTypes/private.js index cc01d86fe93c..c0a3fdbfe2f4 100644 --- a/packages/rocketchat-lib/lib/roomTypes/private.js +++ b/packages/rocketchat-lib/lib/roomTypes/private.js @@ -44,9 +44,9 @@ export class PrivateRoomType extends RoomTypeConfig { condition() { const user = Meteor.user(); - const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {}; - - return !preferences.roomsListExhibitionMode || ['unread', 'category'].includes(preferences.roomsListExhibitionMode) && !preferences.mergeChannels && RocketChat.authz.hasAllPermission('view-p-room'); + const roomsListExhibitionMode = RocketChat.getUserPreference(user, 'roomsListExhibitionMode'); + const mergeChannels = RocketChat.getUserPreference(user, 'mergeChannels'); + return !roomsListExhibitionMode || ['unread', 'category'].includes(roomsListExhibitionMode) && !mergeChannels && RocketChat.authz.hasAllPermission('view-p-room'); } isGroupChat() { diff --git a/packages/rocketchat-lib/lib/roomTypes/public.js b/packages/rocketchat-lib/lib/roomTypes/public.js index 7d6425230bbc..442423364c9d 100644 --- a/packages/rocketchat-lib/lib/roomTypes/public.js +++ b/packages/rocketchat-lib/lib/roomTypes/public.js @@ -42,8 +42,9 @@ export class PublicRoomType extends RoomTypeConfig { condition() { const user = Meteor.user(); - const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {}; - return !preferences.roomsListExhibitionMode || ['unread', 'category'].includes(preferences.roomsListExhibitionMode) && !preferences.mergeChannels && (RocketChat.authz.hasAtLeastOnePermission(['view-c-room', 'view-joined-room']) || RocketChat.settings.get('Accounts_AllowAnonymousRead') === true); + const roomsListExhibitionMode = RocketChat.getUserPreference(user, 'roomsListExhibitionMode'); + const mergeChannels = RocketChat.getUserPreference(user, 'mergeChannels'); + return !roomsListExhibitionMode || ['unread', 'category'].includes(roomsListExhibitionMode) && !mergeChannels && (RocketChat.authz.hasAtLeastOnePermission(['view-c-room', 'view-joined-room']) || RocketChat.settings.get('Accounts_AllowAnonymousRead') === true); } showJoinLink(roomId) { diff --git a/packages/rocketchat-lib/lib/roomTypes/unread.js b/packages/rocketchat-lib/lib/roomTypes/unread.js index 670f71b47a36..395036c65088 100644 --- a/packages/rocketchat-lib/lib/roomTypes/unread.js +++ b/packages/rocketchat-lib/lib/roomTypes/unread.js @@ -13,7 +13,6 @@ export class UnreadRoomType extends RoomTypeConfig { condition() { const user = Meteor.user(); - const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {}; - return preferences.roomsListExhibitionMode === 'unread'; + return RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'unread'; } } diff --git a/packages/rocketchat-lib/package.js b/packages/rocketchat-lib/package.js index d2b08da20d9b..c91957d52a82 100644 --- a/packages/rocketchat-lib/package.js +++ b/packages/rocketchat-lib/package.js @@ -78,6 +78,8 @@ Package.onUse(function(api) { api.addFiles('lib/MessageTypes.js'); api.addFiles('lib/templateVarHandler.js'); + api.addFiles('lib/getUserPreference.js'); + api.addFiles('server/lib/bugsnag.js', 'server'); api.addFiles('server/lib/metrics.js', 'server'); diff --git a/packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js b/packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js index 6bb2b6a89820..b7f97dba1aac 100644 --- a/packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js +++ b/packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js @@ -63,7 +63,8 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { } highlights.forEach(function(user) { - if (user && user.settings && user.settings.preferences && messageContainsHighlight(message, user.settings.preferences.highlights)) { + const userHighlights = RocketChat.getUserPreference(user, 'highlights'); + if (userHighlights && messageContainsHighlight(message, userHighlights)) { if (user._id !== message.u._id) { highlightsIds.push(user._id); } diff --git a/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js b/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js index 79e2e110d2b6..779b1c57b888 100644 --- a/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js +++ b/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js @@ -167,8 +167,9 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { if (usersOfMention && usersOfMention.length > 0) { usersOfMention.forEach((user) => { + const emailNotificationMode = RocketChat.getUserPreference(user, 'emailNotificationMode'); if (usersToSendEmail[user._id] === 'default') { - if (!user.settings || !user.settings.preferences || !user.settings.preferences.emailNotificationMode || user.settings.preferences.emailNotificationMode === 'all') { //Mention/DM + if (emailNotificationMode === 'all') { //Mention/DM usersToSendEmail[user._id] = 'mention'; } else { return; @@ -176,7 +177,7 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { } if (usersToSendEmail[user._id] === 'direct') { - const userEmailPreferenceIsDisabled = user.settings && user.settings.preferences && user.settings.preferences.emailNotificationMode && (user.settings.preferences.emailNotificationMode === 'disabled'); + const userEmailPreferenceIsDisabled = emailNotificationMode === 'disabled'; const directMessageEmailPreference = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(message.rid, message.rid.replace(message.u._id, '')).emailNotifications; if (directMessageEmailPreference === 'nothing') { diff --git a/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js b/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js index 70e6dda5eb85..401491bbec6e 100644 --- a/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js +++ b/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js @@ -206,9 +206,9 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room, userId) { subscriptions.forEach((s) => { userIds.push(s.u._id); }); - const userSettings = {}; - RocketChat.models.Users.findUsersByIds(userIds, { fields: { 'settings.preferences.audioNotifications': 1, 'settings.preferences.desktopNotifications': 1, 'settings.preferences.mobileNotifications': 1 } }).forEach((user) => { - userSettings[user._id] = user.settings; + const users = {}; + RocketChat.models.Users.findUsersByIds(userIds, { fields: { 'settings.preferences': 1 } }).forEach((user) => { + users[user._id] = user; }); subscriptions.forEach(subscription => { @@ -218,16 +218,13 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room, userId) { settings.dontNotifyAudioUsers.push(subscription.u._id); return; } - const preferences = userSettings[subscription.u._id] ? userSettings[subscription.u._id].preferences || {} : {}; - const userAudioNotificationPreference = preferences.audioNotifications !== 'default' ? preferences.audioNotifications : undefined; - const userDesktopNotificationPreference = preferences.desktopNotifications !== 'default' ? preferences.desktopNotifications : undefined; - const userMobileNotificationPreference = preferences.mobileNotifications !== 'default' ? preferences.mobileNotifications : undefined; - // Set defaults if they don't exist + const { - audioNotifications = userAudioNotificationPreference || RocketChat.settings.get('Audio_Notifications_Default_Alert'), - desktopNotifications = userDesktopNotificationPreference || RocketChat.settings.get('Desktop_Notifications_Default_Alert'), - mobilePushNotifications = userMobileNotificationPreference || RocketChat.settings.get('Mobile_Notifications_Default_Alert') + audioNotifications = RocketChat.getUserPreference(users[subscription.u._id], 'audioNotifications'), + desktopNotifications = RocketChat.getUserPreference(users[subscription.u._id], 'desktopNotifications'), + mobilePushNotifications = RocketChat.getUserPreference(users[subscription.u._id], 'mobileNotifications') } = subscription; + if (audioNotifications === 'all' && !disableAllMessageNotifications) { settings.alwaysNotifyAudioUsers.push(subscription.u._id); } diff --git a/packages/rocketchat-lib/server/startup/settings.js b/packages/rocketchat-lib/server/startup/settings.js index 5e25d29ac04b..dab6f94bcdf4 100644 --- a/packages/rocketchat-lib/server/startup/settings.js +++ b/packages/rocketchat-lib/server/startup/settings.js @@ -170,6 +170,245 @@ RocketChat.settings.addGroup('Accounts', function() { }); }); + this.section('Accounts_Default_User_Preferences', function() { + this.add('Accounts_Default_User_Preferences_enableAutoAway', false, { + type: 'boolean', + 'public': true, + i18nLabel: 'Enable_Auto_Away' + }); + this.add('Accounts_Default_User_Preferences_idleTimeoutLimit', 300000, { + type: 'int', + 'public': true, + i18nLabel: 'Idle_Time_Limit' + }); + this.add('Accounts_Default_User_Preferences_desktopNotificationDuration', 0, { + type: 'int', + 'public': true, + i18nLabel: 'Notification_Duration' + }); + this.add('Accounts_Default_User_Preferences_audioNotifications', 'mentions', { + type: 'select', + values: [ + { + key: 'all', + i18nLabel: 'All_messages' + }, + { + key: 'mentions', + i18nLabel: 'Mentions' + }, + { + key: 'nothing', + i18nLabel: 'Nothing' + } + ], + public: true + }); + this.add('Accounts_Default_User_Preferences_desktopNotifications', 'mentions', { + type: 'select', + values: [ + { + key: 'all', + i18nLabel: 'All_messages' + }, + { + key: 'mentions', + i18nLabel: 'Mentions' + }, + { + key: 'nothing', + i18nLabel: 'Nothing' + } + ], + 'public': true + }); + this.add('Accounts_Default_User_Preferences_mobileNotifications', 'mentions', { + type: 'select', + values: [ + { + key : 'all', + i18nLabel : 'All_messages' + }, + { + key : 'mentions', + i18nLabel : 'Mentions' + }, + { + key : 'nothing', + i18nLabel : 'Nothing' + } + ], + 'public': true + }); + this.add('Accounts_Default_User_Preferences_unreadAlert', true, { + type: 'boolean', + 'public': true, + i18nLabel: 'Unread_Tray_Icon_Alert' + }); + this.add('Accounts_Default_User_Preferences_useEmojis', true, { + type: 'boolean', + 'public': true, + i18nLabel: 'Use_Emojis' + }); + this.add('Accounts_Default_User_Preferences_convertAsciiEmoji', true, { + type: 'boolean', + 'public': true, + i18nLabel: 'Convert_Ascii_Emojis' + }); + this.add('Accounts_Default_User_Preferences_autoImageLoad', true, { + type: 'boolean', + 'public': true, + i18nLabel: 'Auto_Load_Images' + }); + this.add('Accounts_Default_User_Preferences_saveMobileBandwidth', true, { + type: 'boolean', + 'public': true, + i18nLabel: 'Save_Mobile_Bandwidth' + }); + this.add('Accounts_Default_User_Preferences_collapseMediaByDefault', false, { + type: 'boolean', + 'public': true, + i18nLabel: 'Collapse_Embedded_Media_By_Default' + }); + this.add('Accounts_Default_User_Preferences_hideUsernames', false, { + type: 'boolean', + 'public': true, + i18nLabel: 'Hide_usernames' + }); + this.add('Accounts_Default_User_Preferences_hideRoles', false, { + type: 'boolean', + 'public': true, + i18nLabel: 'Hide_roles' + }); + this.add('Accounts_Default_User_Preferences_hideFlexTab', false, { + type: 'boolean', + 'public': true, + i18nLabel: 'Hide_flextab' + }); + this.add('Accounts_Default_User_Preferences_hideAvatars', false, { + type: 'boolean', + 'public': true, + i18nLabel: 'Hide_Avatars' + }); + this.add('Accounts_Default_User_Preferences_roomsListExhibitionMode', 'category', { + type: 'select', + values: [ + { + key: 'unread', + i18nLabel: 'Unread_Rooms_Mode' + }, + { + key: 'activity', + i18nLabel: 'Sort_by_activity' + }, + { + key: 'category', + i18nLabel: 'Split_by_categories' + } + ], + 'public': true, + i18nLabel: 'Sidebar_list_mode' + }); + this.add('Accounts_Default_User_Preferences_mergeChannels', false, { + type: 'boolean', + 'public': true, + i18nLabel: 'UI_Merge_Channels_Groups' + }); + this.add('Accounts_Default_User_Preferences_sendOnEnter', 'normal', { + type: 'select', + values: [ + { + key: 'normal', + i18nLabel: 'Enter_Normal' + }, + { + key: 'alternative', + i18nLabel: 'Enter_Alternative' + }, + { + key: 'desktop', + i18nLabel: 'Only_On_Desktop' + } + ], + 'public': true, + i18nLabel: 'Enter_Behaviour' + }); + this.add('Accounts_Default_User_Preferences_viewMode', 0, { + type: 'select', + values: [ + { + key: 0, + i18nLabel: 'Normal' + }, + { + key: 1, + i18nLabel: 'Cozy' + }, + { + key: 2, + i18nLabel: 'Compact' + } + ], + 'public': true, + i18nLabel: 'View_mode' + }); + this.add('Accounts_Default_User_Preferences_emailNotificationMode', 'all', { + type: 'select', + values: [ + { + key: 'disabled', + i18nLabel: 'Email_Notification_Mode_Disabled' + }, + { + key: 'all', + i18nLabel: 'Email_Notification_Mode_All' + } + ], + 'public': true, + i18nLabel: 'Email_Notification_Mode' + }); + this.add('Accounts_Default_User_Preferences_roomCounterSidebar', false, { + type: 'boolean', + 'public': true, + i18nLabel: 'Show_room_counter_on_sidebar' + }); + this.add('Accounts_Default_User_Preferences_newRoomNotification', 'door', { + type: 'select', + values: [ + { + key: 'none', + i18nLabel: 'None' + }, + { + key: 'door', + i18nLabel: 'Default' + } + ], + 'public': true, + i18nLabel: 'New_Room_Notification' + }); + this.add('Accounts_Default_User_Preferences_newMessageNotification', 'chime', { + type: 'select', + values: [ + { + key: 'none', + i18nLabel: 'None' + }, + { + key: 'chime', + i18nLabel: 'Default' + } + ], + 'public': true, + i18nLabel: 'New_Message_Notification' + }); + this.add('Accounts_Default_User_Preferences_notificationsSoundVolume', 100, { + type: 'int', + 'public': true, + i18nLabel: 'Notifications_Sound_Volume' + }); + }); + this.section('Avatar', function() { this.add('Accounts_AvatarResize', true, { type: 'boolean' @@ -448,63 +687,6 @@ RocketChat.settings.addGroup('General', function() { }); }); this.section('Notifications', function() { - this.add('Desktop_Notifications_Duration', 0, { - type: 'int', - 'public': true, - i18nDescription: 'Desktop_Notification_Durations_Description' - }); - - this.add('Audio_Notifications_Value', 'chime', { - type: 'string', - 'public': true, - i18nDescription: 'Audio_Notification_Value_Description' - }); - - this.add('Audio_Notifications_Default_Alert', 'mentions', { - type: 'select', - values: [{ - key: 'all', - i18nLabel: 'All_messages' - }, { - key: 'mentions', - i18nLabel: 'Mentions' - }, { - key: 'nothing', - i18nLabel: 'Nothing' - }], - public: true - }); - - this.add('Desktop_Notifications_Default_Alert', 'mentions', { - type: 'select', - values: [{ - key: 'all', - i18nLabel: 'All_messages' - }, { - key: 'mentions', - i18nLabel: 'Mentions' - }, { - key: 'nothing', - i18nLabel: 'Nothing' - }], - public: true - }); - - this.add('Mobile_Notifications_Default_Alert', 'mentions', { - type: 'select', - values: [{ - key: 'all', - i18nLabel: 'All_messages' - }, { - key: 'mentions', - i18nLabel: 'Mentions' - }, { - key: 'nothing', - i18nLabel: 'Nothing' - }], - public: true - }); - this.add('Notifications_Max_Room_Members', 100, { type: 'int', public: true, diff --git a/packages/rocketchat-livechat/app/client/lib/_visitor.js b/packages/rocketchat-livechat/app/client/lib/_visitor.js index 4439cd99953e..290ddf92b45a 100644 --- a/packages/rocketchat-livechat/app/client/lib/_visitor.js +++ b/packages/rocketchat-livechat/app/client/lib/_visitor.js @@ -58,7 +58,7 @@ this.visitor = new class { // notification sound if (Session.equals('sound', true) && msg.u._id !== Meteor.userId()) { - const audioVolume = Meteor.user() && Meteor.user().settings && Meteor.user().settings.preferences && Meteor.user().settings.preferences.notificationsSoundVolume || 100; + const audioVolume = RocketChat.getUserPreference(Meteor.user(), 'notificationsSoundVolume'); const audio = document.getElementById('chatAudioNotification'); audio.volume = Number((audioVolume/100).toPrecision(2)); audio.play(); diff --git a/packages/rocketchat-livechat/client/views/sideNav/livechat.js b/packages/rocketchat-livechat/client/views/sideNav/livechat.js index 79497acf3773..83252463a477 100644 --- a/packages/rocketchat-livechat/client/views/sideNav/livechat.js +++ b/packages/rocketchat-livechat/client/views/sideNav/livechat.js @@ -22,10 +22,10 @@ Template.livechat.helpers({ }; const user = RocketChat.models.Users.findOne(Meteor.userId(), { - fields: { 'settings.preferences.unreadRoomsMode': 1 } + fields: { 'settings.preferences.roomsListExhibitionMode': 1 } }); - if (user && user.settings && user.settings.preferences && user.settings.preferences.unreadRoomsMode) { + if (RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'unread') { query.alert = { $ne: true }; } diff --git a/packages/rocketchat-message-attachments/client/messageAttachment.js b/packages/rocketchat-message-attachments/client/messageAttachment.js index c4d641427b76..8da6606bca34 100644 --- a/packages/rocketchat-message-attachments/client/messageAttachment.js +++ b/packages/rocketchat-message-attachments/client/messageAttachment.js @@ -35,11 +35,11 @@ Template.messageAttachment.helpers({ }, loadImage() { const user = Meteor.user(); - if (user && user.settings && user.settings.preferences && this.downloadImages !== true) { - if (user.settings.preferences.autoImageLoad === false) { + if (this.downloadImages !== true) { + if (RocketChat.getUserPreference(user, 'autoImageLoad') === false) { return false; } - if (Meteor.Device.isPhone() && user.settings.preferences.saveMobileBandwidth !== true) { + if (Meteor.Device.isPhone() && RocketChat.getUserPreference(user, 'saveMobileBandwidth') !== true) { return false; } } @@ -56,7 +56,7 @@ Template.messageAttachment.helpers({ return this.collapsed; } else { const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences.collapseMediaByDefault === true; + return RocketChat.getUserPreference(user, 'collapseMediaByDefault') === true; } }, time() { diff --git a/packages/rocketchat-oembed/client/oembedAudioWidget.js b/packages/rocketchat-oembed/client/oembedAudioWidget.js index 23bc9a4d7c12..5c47bcef006f 100644 --- a/packages/rocketchat-oembed/client/oembedAudioWidget.js +++ b/packages/rocketchat-oembed/client/oembedAudioWidget.js @@ -4,7 +4,7 @@ Template.oembedAudioWidget.helpers({ return this.collapsed; } else { const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences.collapseMediaByDefault === true; + return RocketChat.getUserPreference(user, 'collapseMediaByDefault') === true; } } }); diff --git a/packages/rocketchat-oembed/client/oembedFrameWidget.js b/packages/rocketchat-oembed/client/oembedFrameWidget.js index e47f62edca66..8ef60bc08d14 100644 --- a/packages/rocketchat-oembed/client/oembedFrameWidget.js +++ b/packages/rocketchat-oembed/client/oembedFrameWidget.js @@ -4,7 +4,7 @@ Template.oembedFrameWidget.helpers({ return this.collapsed; } else { const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences.collapseMediaByDefault === true; + return RocketChat.getUserPreference(user, 'collapseMediaByDefault') === true; } } }); diff --git a/packages/rocketchat-oembed/client/oembedImageWidget.js b/packages/rocketchat-oembed/client/oembedImageWidget.js index 82c71ae1f415..e62ce218b77b 100644 --- a/packages/rocketchat-oembed/client/oembedImageWidget.js +++ b/packages/rocketchat-oembed/client/oembedImageWidget.js @@ -2,10 +2,10 @@ Template.oembedImageWidget.helpers({ loadImage() { const user = Meteor.user(); - if (user && user.settings && user.settings.preferences && user.settings.preferences.autoImageLoad === false && this.downloadImages == null) { + if (RocketChat.getUserPreference(user, 'autoImageLoad') === false && this.downloadImages == null) { return false; } - if (Meteor.Device.isPhone() && user && user.settings && user.settings.preferences && user.settings.preferences.saveMobileBandwidth && this.downloadImages == null) { + if (Meteor.Device.isPhone() && RocketChat.getUserPreference(user, 'saveMobileBandwidth') && this.downloadImages == null) { return false; } return true; @@ -15,7 +15,7 @@ Template.oembedImageWidget.helpers({ return this.collapsed; } else { const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences.collapseMediaByDefault === true; + return RocketChat.getUserPreference(user, 'collapseMediaByDefault') === true; } } }); diff --git a/packages/rocketchat-oembed/client/oembedUrlWidget.js b/packages/rocketchat-oembed/client/oembedUrlWidget.js index 1b58f8f9e008..dc8378ee39da 100644 --- a/packages/rocketchat-oembed/client/oembedUrlWidget.js +++ b/packages/rocketchat-oembed/client/oembedUrlWidget.js @@ -63,7 +63,7 @@ Template.oembedUrlWidget.helpers({ return this.collapsed; } else { const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences.collapseMediaByDefault === true; + return RocketChat.getUserPreference(user, 'collapseMediaByDefault') === true; } } }); diff --git a/packages/rocketchat-oembed/client/oembedVideoWidget.js b/packages/rocketchat-oembed/client/oembedVideoWidget.js index a825ab5c976b..7a987fa084b4 100644 --- a/packages/rocketchat-oembed/client/oembedVideoWidget.js +++ b/packages/rocketchat-oembed/client/oembedVideoWidget.js @@ -28,7 +28,7 @@ Template.oembedVideoWidget.helpers({ return this.collapsed; } else { const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences.collapseMediaByDefault === true; + return RocketChat.getUserPreference(user, 'collapseMediaByDefault') === true; } } diff --git a/packages/rocketchat-oembed/client/oembedYoutubeWidget.js b/packages/rocketchat-oembed/client/oembedYoutubeWidget.js index 0e2ce33d4e49..5bda6ad5fcd9 100644 --- a/packages/rocketchat-oembed/client/oembedYoutubeWidget.js +++ b/packages/rocketchat-oembed/client/oembedYoutubeWidget.js @@ -4,7 +4,7 @@ Template.oembedYoutubeWidget.helpers({ return this.collapsed; } else { const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences.collapseMediaByDefault === true; + return RocketChat.getUserPreference(user, 'collapseMediaByDefault') === true; } } }); diff --git a/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js b/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js index ca1cbccef86b..19ab56debedf 100644 --- a/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js +++ b/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js @@ -7,11 +7,6 @@ const notificationLabels = { nothing: 'Nothing' }; -function getUserPreference(preference) { - const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences[preference]; -} - Template.pushNotificationsFlexTab.helpers({ audioAssets() { return RocketChat.CustomSounds && RocketChat.CustomSounds.getList && RocketChat.CustomSounds.getList() || []; @@ -173,23 +168,23 @@ Template.pushNotificationsFlexTab.helpers({ return Meteor.user().emails && Meteor.user().emails[0] && Meteor.user().emails[0].verified; }, defaultAudioNotification() { - let preference = getUserPreference('audioNotifications'); - if (preference === 'default' || preference == null) { - preference = RocketChat.settings.get('Audio_Notifications_Default_Alert'); + let preference = RocketChat.getUserPreference(Meteor.user(), 'audioNotifications'); + if (preference === 'default') { + preference = RocketChat.settings.get('Accounts_Default_User_Preferences_audioNotifications'); } return notificationLabels[preference]; }, defaultDesktopNotification() { - let preference = getUserPreference('desktopNotifications'); - if (preference === 'default' || preference == null) { - preference = RocketChat.settings.get('Desktop_Notifications_Default_Alert'); + let preference = RocketChat.getUserPreference(Meteor.user(), 'desktopNotifications'); + if (preference === 'default') { + preference = RocketChat.settings.get('Accounts_Default_User_Preferences_desktopNotifications'); } return notificationLabels[preference]; }, defaultMobileNotification() { - let preference = getUserPreference('mobileNotifications'); - if (preference === 'default' || preference == null) { - preference = RocketChat.settings.get('Mobile_Notifications_Default_Alert'); + let preference = RocketChat.getUserPreference(Meteor.user(), 'mobileNotifications'); + if (preference === 'default') { + preference = RocketChat.settings.get('Accounts_Default_User_Preferences_mobileNotifications'); } return notificationLabels[preference]; } @@ -283,11 +278,11 @@ Template.pushNotificationsFlexTab.events({ const user = Meteor.user(); if (audio === 'Use account preference' || audio === 'none') { - audio = user && user.settings && user.settings.preferences && user.settings.preferences.newMessageNotification || 'chime'; + audio = RocketChat.getUserPreference(user, 'newMessageNotification'); } if (audio && audio !== 'none') { - const audioVolume = user && user.settings && user.settings.preferences && user.settings.preferences.notificationsSoundVolume || 100; + const audioVolume = RocketChat.getUserPreference(user, 'notificationsSoundVolume'); const $audio = $(`audio#${ audio }`); if ($audio && $audio[0] && $audio[0].play) { @@ -304,10 +299,10 @@ Template.pushNotificationsFlexTab.events({ const user = Meteor.user(); if (audio==='') { - audio = user && user.settings && user.settings.preferences && user.settings.preferences.newMessageNotification || 'chime'; + audio = RocketChat.getUserPreference(user, 'newMessageNotification'); } if (audio && audio !== 'none') { - const audioVolume = user && user.settings && user.settings.preferences && user.settings.preferences.notificationsSoundVolume || 100; + const audioVolume = RocketChat.getUserPreference(user, 'notificationsSoundVolume'); const $audio = $(`audio#${ audio }`); if ($audio && $audio[0] && $audio[0].play) { diff --git a/packages/rocketchat-ui-account/client/accountPreferences.html b/packages/rocketchat-ui-account/client/accountPreferences.html index faf442a3fa91..17b6bcf090d6 100644 --- a/packages/rocketchat-ui-account/client/accountPreferences.html +++ b/packages/rocketchat-ui-account/client/accountPreferences.html @@ -30,7 +30,7 @@

{{_ "User_Presence"}}

- +
@@ -80,10 +80,10 @@

{{_ "Messages"}}

@@ -91,45 +91,45 @@

{{_ "Messages"}}

- +
- +
- +
- +
- +
@@ -137,14 +137,14 @@

{{_ "Messages"}}

- +
- +
{{#if showRoles}} @@ -152,7 +152,7 @@

{{_ "Messages"}}

- +
{{/if}} @@ -160,14 +160,14 @@

{{_ "Messages"}}

- +
- +
@@ -176,7 +176,7 @@

{{_ "Messages"}}

@@ -184,9 +184,9 @@

{{_ "Messages"}}

- - - + + +
{{/with}} @@ -195,7 +195,7 @@

{{_ "Messages"}}

@@ -206,9 +206,9 @@

{{_ "Messages"}}

{{_ "View_mode_info"}}
@@ -217,8 +217,8 @@

{{_ "Messages"}}

{{_ "You_need_to_verifiy_your_email_address_to_get_notications"}}
@@ -232,7 +232,7 @@

{{_ "Sidebar"}}

- +
diff --git a/packages/rocketchat-ui-account/client/accountPreferences.js b/packages/rocketchat-ui-account/client/accountPreferences.js index 8dc59e2074e0..678257f8b066 100644 --- a/packages/rocketchat-ui-account/client/accountPreferences.js +++ b/packages/rocketchat-ui-account/client/accountPreferences.js @@ -9,17 +9,12 @@ const notificationLabels = { nothing: 'Nothing' }; -const DEFAULT_IDLE_TIME_LIMIT = 300000; - -const userHasPreferences = (user) => { - const userHasSettings = user.hasOwnProperty('settings'); - - if (!userHasSettings) { - return false; +function checkedSelected(property, value, defaultValue=undefined) { + if (defaultValue && defaultValue.hash) { + defaultValue = undefined; } - - return user.settings.hasOwnProperty('preferences'); -}; + return RocketChat.getUserPreference(Meteor.user(), property, defaultValue) === value; +} Template.accountPreferences.helpers({ showMergedChannels() { @@ -29,12 +24,10 @@ Template.accountPreferences.helpers({ return (RocketChat.CustomSounds && RocketChat.CustomSounds.getList && RocketChat.CustomSounds.getList()) || []; }, newMessageNotification() { - const user = Meteor.user(); - return (user && user.settings && user.settings.preferences && user.settings.preferences.newMessageNotification) || 'chime'; + return RocketChat.getUserPreference(Meteor.user(), 'newMessageNotification'); }, newRoomNotification() { - const user = Meteor.user(); - return (user && user.settings && user.settings.preferences && user.settings.preferences.newRoomNotification) || 'door'; + return RocketChat.getUserPreference(Meteor.user(), 'newRoomNotification'); }, languages() { const languages = TAPi18n.getLanguages(); @@ -56,33 +49,15 @@ Template.accountPreferences.helpers({ } return result; }, - checked(property, value, defaultValue) { - const user = Meteor.user(); - - if (!userHasPreferences(user)) { - return defaultValue; - } - - const userPreferences = user.settings.preferences; - - if (userPreferences.hasOwnProperty(property)) { - return value === userPreferences[property]; - } - - return defaultValue; + checked(property, value, defaultValue=undefined) { + return checkedSelected(property, value, defaultValue); }, - selected(property, value, defaultValue) { - const user = Meteor.user(); - const propertyeExists = !!(user && user.settings && user.settings.preferences && user.settings.preferences[property]); - if (propertyeExists) { - return user.settings.preferences[property] === value; - } else { - return defaultValue === true; - } + selected(property, value, defaultValue=undefined) { + return checkedSelected(property, value, defaultValue); }, highlights() { - const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences['highlights'] && user.settings.preferences['highlights'].join('\n'); + const userHighlights = RocketChat.getUserPreference(Meteor.user(), 'highlights'); + return userHighlights ? userHighlights.join(', ') : undefined; }, desktopNotificationEnabled() { return KonchatNotification.notificationStatus.get() === 'granted' || (window.Notification && Notification.permission === 'granted'); @@ -90,38 +65,30 @@ Template.accountPreferences.helpers({ desktopNotificationDisabled() { return KonchatNotification.notificationStatus.get() === 'denied' || (window.Notification && Notification.permission === 'denied'); }, - defaultAudioNotification() { - return notificationLabels[RocketChat.settings.get('Audio_Notifications_Default_Alert')]; - }, - defaultAudioNotificationValue() { - return RocketChat.settings.get('Audio_Notifications_Value'); - }, desktopNotificationDuration() { - const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences.desktopNotificationDuration; + const userPref = RocketChat.getUserPreference(Meteor.user(), 'desktopNotificationDuration', 'undefined'); + return userPref !== 'undefined' ? userPref : undefined; }, defaultDesktopNotificationDuration() { - return RocketChat.settings.get('Desktop_Notifications_Duration'); + return RocketChat.settings.get('Accounts_Default_User_Preferences_desktopNotificationDuration'); }, idleTimeLimit() { - const user = Meteor.user(); - return (user && user.settings && user.settings.preferences && user.settings.preferences.idleTimeLimit) || DEFAULT_IDLE_TIME_LIMIT; + return RocketChat.getUserPreference(Meteor.user(), 'idleTimeLimit'); }, defaultIdleTimeLimit() { - return DEFAULT_IDLE_TIME_LIMIT; + return RocketChat.settings.get('Accounts_Default_User_Preferences_idleTimeoutLimit'); }, defaultDesktopNotification() { - return notificationLabels[RocketChat.settings.get('Desktop_Notifications_Default_Alert')]; + return notificationLabels[RocketChat.settings.get('Accounts_Default_User_Preferences_desktopNotifications')]; }, defaultMobileNotification() { - return notificationLabels[RocketChat.settings.get('Mobile_Notifications_Default_Alert')]; + return notificationLabels[RocketChat.settings.get('Accounts_Default_User_Preferences_mobileNotifications')]; }, showRoles() { return RocketChat.settings.get('UI_DisplayRoles'); }, notificationsSoundVolume() { - const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences.notificationsSoundVolume || 100; + return RocketChat.getUserPreference(Meteor.user(), 'notificationsSoundVolume'); } }); @@ -135,12 +102,8 @@ Template.accountPreferences.onCreated(function() { settingsTemplate.child.push(this); - if (user && user.settings && user.settings.preferences) { - this.roomsListExhibitionMode = new ReactiveVar(user.settings.preferences.roomsListExhibitionMode || 'category'); - this.useEmojis = new ReactiveVar(user.settings.preferences.desktopNotificationDuration == null || user.settings.preferences.useEmojis); - } else { - this.roomsListExhibitionMode = new ReactiveVar('category'); - } + this.roomsListExhibitionMode = new ReactiveVar(RocketChat.getUserPreference(user, 'roomsListExhibitionMode')); + this.useEmojis = new ReactiveVar(RocketChat.getUserPreference(user, 'useEmojis')); let instance = this; @@ -177,7 +140,6 @@ Template.accountPreferences.onCreated(function() { data.hideAvatars = $('#hideAvatars').find('input:checked').val(); data.mergeChannels = $('#mergeChannels').find('input:checked').val(); data.sendOnEnter = $('#sendOnEnter').find('select').val(); - data.unreadRoomsMode = $('input[name=unreadRoomsMode]:checked').val(); data.roomsListExhibitionMode = $('select[name=roomsListExhibitionMode]').val(); data.autoImageLoad = $('input[name=autoImageLoad]:checked').val(); data.emailNotificationMode = $('select[name=emailNotificationMode]').val(); @@ -201,16 +163,11 @@ Template.accountPreferences.onCreated(function() { let reload = false; // if highlights changed we need page reload - const user = Meteor.user(); - if (user && - user.settings && - user.settings.preferences && - user.settings.preferences['highlights'] && - user.settings.preferences['highlights'].join('\n') !== data.highlights.join('\n')) { + const highlights = RocketChat.getUserPreference(Meteor.user(), 'highlights'); + if (highlights && highlights.join('\n') !== data.highlights.join('\n')) { reload = true; } - if (this.shouldUpdateLocalStorageSetting('userLanguage', selectedLanguage)) { localStorage.setItem('userLanguage', selectedLanguage); data.language = selectedLanguage; diff --git a/packages/rocketchat-ui-master/client/main.js b/packages/rocketchat-ui-master/client/main.js index 77ecfb1a7a87..f8037bd6fe7f 100644 --- a/packages/rocketchat-ui-master/client/main.js +++ b/packages/rocketchat-ui-master/client/main.js @@ -192,9 +192,7 @@ Template.main.onRendered(function() { cancelButtonText: t('Cancel') }); const user = Meteor.user(); - const settings = user && user.settings; - const prefs = settings && settings.preferences; - if (prefs && prefs.hideUsernames != null) { + if (RocketChat.getUserPreference(user, 'hideUsernames')) { $(document.body).on('mouseleave', 'button.thumb', function() { return RocketChat.tooltip.hide(); }); diff --git a/packages/rocketchat-ui-message/client/message.js b/packages/rocketchat-ui-message/client/message.js index e2de12804f82..d04782670e15 100644 --- a/packages/rocketchat-ui-message/client/message.js +++ b/packages/rocketchat-ui-message/client/message.js @@ -13,8 +13,7 @@ Template.message.helpers({ }, roleTags() { const user = Meteor.user(); - // test user -> settings -> preferences -> hideRoles - if (!RocketChat.settings.get('UI_DisplayRoles') || (user && ['settings', 'preferences', 'hideRoles'].reduce((obj, field) => typeof obj !== 'undefined' && obj[field], user))) { + if (!RocketChat.settings.get('UI_DisplayRoles') || RocketChat.getUserPreference(user, 'hideRoles')) { return []; } diff --git a/packages/rocketchat-ui-sidenav/client/roomList.js b/packages/rocketchat-ui-sidenav/client/roomList.js index 047a5138bfe2..17219a65d425 100644 --- a/packages/rocketchat-ui-sidenav/client/roomList.js +++ b/packages/rocketchat-ui-sidenav/client/roomList.js @@ -49,7 +49,8 @@ Template.roomList.helpers({ query.tokens = { $exists: false }; } - if (user && user.settings && user.settings.preferences && user.settings.preferences.roomsListExhibitionMode === 'unread') { + if (RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'unread') { + query.$or = [ {alert: {$ne: true}}, {hideUnreadStatus: true} @@ -98,8 +99,7 @@ Template.roomList.helpers({ }, showRoomCounter() { - const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences.roomCounterSidebar; + return RocketChat.getUserPreference(Meteor.user(), 'roomCounterSidebar'); } }); diff --git a/packages/rocketchat-ui-sidenav/client/sideNav.js b/packages/rocketchat-ui-sidenav/client/sideNav.js index d64de61c64ee..ee2ba5f98331 100644 --- a/packages/rocketchat-ui-sidenav/client/sideNav.js +++ b/packages/rocketchat-ui-sidenav/client/sideNav.js @@ -85,11 +85,7 @@ Template.sideNav.onCreated(function() { 'settings.preferences.mergeChannels': 1 } }); - let userPref = null; - if (user && user.settings && user.settings.preferences) { - userPref = user.settings.preferences.roomsListExhibitionMode === 'category' && user.settings.preferences.mergeChannels; - } - - this.mergedChannels.set((userPref != null) ? userPref : RocketChat.settings.get('UI_Merge_Channels_Groups')); + const userPref = RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'category' && RocketChat.getUserPreference(user, 'mergeChannels'); + this.mergedChannels.set(userPref ? userPref : RocketChat.settings.get('UI_Merge_Channels_Groups')); }); }); diff --git a/packages/rocketchat-ui/client/lib/chatMessages.js b/packages/rocketchat-ui/client/lib/chatMessages.js index 5da3d242eef0..a021a9deaa44 100644 --- a/packages/rocketchat-ui/client/lib/chatMessages.js +++ b/packages/rocketchat-ui/client/lib/chatMessages.js @@ -422,7 +422,7 @@ this.ChatMessages = class ChatMessages { keydown(rid, event) { const user = Meteor.user(); - const sendOnEnter = user && user.settings && user.settings.preferences && user.settings.preferences.sendOnEnter; + const sendOnEnter = RocketChat.getUserPreference(user, 'sendOnEnter'); const input = event.currentTarget; // const $input = $(input); const k = event.which; diff --git a/packages/rocketchat-ui/client/lib/notification.js b/packages/rocketchat-ui/client/lib/notification.js index 1b532f96f47c..c0e661107996 100644 --- a/packages/rocketchat-ui/client/lib/notification.js +++ b/packages/rocketchat-ui/client/lib/notification.js @@ -30,8 +30,7 @@ const KonchatNotification = { }); const user = Meteor.user(); - - const notificationDuration = notification.duration - 0 || user && user.settings && user.settings.preferences && user.settings.preferences.desktopNotificationDuration - 0 || RocketChat.settings.get('Desktop_Notifications_Duration'); + const notificationDuration = notification.duration - 0 || RocketChat.getUserPreference(user, 'desktopNotificationDuration') - 0; if (notificationDuration > 0) { setTimeout((() => n.close()), notificationDuration * 1000); } @@ -82,8 +81,8 @@ const KonchatNotification = { newMessage(rid) { if (!Session.equals(`user_${ Meteor.user().username }_status`, 'busy')) { const user = Meteor.user(); - const newMessageNotification = user && user.settings && user.settings.preferences && user.settings.preferences.newMessageNotification || 'chime'; - const audioVolume = user && user.settings && user.settings.preferences && user.settings.preferences.notificationsSoundVolume || 100; + const newMessageNotification = RocketChat.getUserPreference(user, 'newMessageNotification'); + const audioVolume = RocketChat.getUserPreference(user, 'notificationsSoundVolume'); const sub = ChatSubscription.findOne({ rid }, { fields: { audioNotificationValue: 1 } }); @@ -135,8 +134,8 @@ Meteor.startup(() => { 'settings.preferences.notificationsSoundVolume': 1 } }); - const newRoomNotification = user && user.settings && user.settings.preferences && user.settings.preferences.newRoomNotification || 'door'; - const audioVolume = user && user.settings && user.settings.preferences && user.settings.preferences.notificationsSoundVolume || 100; + const newRoomNotification = RocketChat.getUserPreference(user, 'newRoomNotification'); + const audioVolume = RocketChat.getUserPreference(user, 'notificationsSoundVolume'); if ((Session.get('newRoomSound') || []).length > 0) { Meteor.defer(function() { diff --git a/packages/rocketchat-ui/client/views/app/room.js b/packages/rocketchat-ui/client/views/app/room.js index f0cb61cf34c9..cf9991f42a8e 100644 --- a/packages/rocketchat-ui/client/views/app/room.js +++ b/packages/rocketchat-ui/client/views/app/room.js @@ -338,7 +338,7 @@ Template.room.helpers({ viewMode() { const user = Meteor.user(); - const viewMode = user && user.settings && user.settings.preferences && user.settings.preferences.viewMode; + const viewMode = RocketChat.getUserPreference(user, 'viewMode'); const modes = ['', 'cozy', 'compact']; return modes[viewMode] || modes[0]; }, @@ -349,12 +349,12 @@ Template.room.helpers({ hideUsername() { const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences.hideUsernames ? 'hide-usernames' : undefined; + return RocketChat.getUserPreference(user, 'hideUsernames') ? 'hide-usernames' : undefined; }, hideAvatar() { const user = Meteor.user(); - return user && user.settings && user.settings.preferences && user.settings.preferences.hideAvatars ? 'hide-avatars' : undefined; + return RocketChat.getUserPreference(user, 'hideAvatars') ? 'hide-avatars' : undefined; }, userCanDrop() { @@ -416,7 +416,7 @@ Template.room.events({ 'click .messages-container-main'() { const user = Meteor.user(); - if ((Template.instance().tabBar.getState() === 'opened') && user && user.settings && user.settings.preferences && user.settings.preferences.hideFlexTab) { + if ((Template.instance().tabBar.getState() === 'opened') && RocketChat.getUserPreference(user, 'hideFlexTab')) { Template.instance().tabBar.close(); } }, diff --git a/server/methods/channelsList.js b/server/methods/channelsList.js index f9e0cac56e76..5f06002743b8 100644 --- a/server/methods/channelsList.js +++ b/server/methods/channelsList.js @@ -62,7 +62,7 @@ Meteor.methods({ if (channelType !== 'public' && RocketChat.authz.hasPermission(Meteor.userId(), 'view-p-room')) { const user = Meteor.user(); - const userPref = user && user.settings && user.settings.preferences && user.settings.preferences.mergeChannels && user.settings.preferences.roomsListExhibitionMode === 'category'; + const userPref = RocketChat.getUserPreference(user, 'mergeChannels') && RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'category'; const globalPref = RocketChat.settings.get('UI_Merge_Channels_Groups'); const mergeChannels = userPref !== undefined ? userPref : globalPref; diff --git a/server/methods/saveUserPreferences.js b/server/methods/saveUserPreferences.js index 6eba48f79ef0..0e9a56c2bd21 100644 --- a/server/methods/saveUserPreferences.js +++ b/server/methods/saveUserPreferences.js @@ -33,10 +33,6 @@ Meteor.methods({ preferences.collapseMediaByDefault = settings.collapseMediaByDefault === '1' ? true : false; } - if (settings.unreadRoomsMode) { - preferences.unreadRoomsMode = settings.unreadRoomsMode === '1' ? true : false; - } - if (settings.autoImageLoad) { preferences.autoImageLoad = settings.autoImageLoad === '1' ? true : false; } @@ -50,11 +46,9 @@ Meteor.methods({ } else { delete preferences.mergeChannels; } - if (settings.unreadRoomsMode) { - preferences.unreadRoomsMode = settings.unreadRoomsMode === '1' ? true : false; - } preferences.roomsListExhibitionMode = ['category', 'unread', 'activity'].includes(settings.roomsListExhibitionMode) ? settings.roomsListExhibitionMode : 'category'; + if (settings.unreadAlert) { preferences.unreadAlert = settings.unreadAlert === '1' ? true : false; } @@ -66,9 +60,11 @@ Meteor.methods({ if (settings.audioNotifications) { preferences.audioNotifications = settings.audioNotifications; } + if (settings.desktopNotifications) { preferences.desktopNotifications = settings.desktopNotifications; } + if (settings.mobileNotifications) { preferences.mobileNotifications = settings.mobileNotifications; } @@ -78,14 +74,16 @@ Meteor.methods({ preferences.enableAutoAway = settings.enableAutoAway === '1'; - preferences.audioNotificationValue = settings.audioNotificationValue - 0; + if (settings.highlights) { + preferences.highlights = settings.highlights; + } + preferences.desktopNotificationDuration = settings.desktopNotificationDuration - 0; preferences.viewMode = settings.viewMode || 0; preferences.hideUsernames = settings.hideUsernames === '1'; preferences.hideRoles = settings.hideRoles === '1'; preferences.hideAvatars = settings.hideAvatars === '1'; preferences.hideFlexTab = settings.hideFlexTab === '1'; - preferences.highlights = settings.highlights; preferences.sendOnEnter = settings.sendOnEnter; preferences.roomCounterSidebar = settings.roomCounterSidebar === '1'; diff --git a/server/startup/migrations/v105.js b/server/startup/migrations/v105.js new file mode 100644 index 000000000000..1a491d1108b5 --- /dev/null +++ b/server/startup/migrations/v105.js @@ -0,0 +1,31 @@ +RocketChat.Migrations.add({ + version: 105, + up() { + if (RocketChat && RocketChat.models) { + if (RocketChat.models.Users) { + RocketChat.models.Users.find({ 'settings.preferences.unreadRoomsMode': { $exists: 1 } }).forEach(function(user) { + const newPreference = user.settings.preferences.unreadRoomsMode ? 'unread' : 'category'; + RocketChat.models.Users.update({ _id: user._id }, { $unset: { 'settings.preferences.unreadRoomsMode': 1 }, $set: { 'settings.preferences.roomsListExhibitionMode': newPreference } }); + }); + } + if (RocketChat.models.Settings) { + const settingsMap = { + 'Desktop_Notifications_Default_Alert': 'Accounts_Default_User_Preferences_desktopNotifications', + 'Mobile_Notifications_Default_Alert': 'Accounts_Default_User_Preferences_mobileNotifications', + 'Audio_Notifications_Default_Alert': 'Accounts_Default_User_Preferences_audioNotifications', + 'Desktop_Notifications_Duration': 'Accounts_Default_User_Preferences_desktopNotificationDuration', + 'Audio_Notifications_Value': undefined + }; + RocketChat.models.Settings.find({ _id: { $in: Object.keys(settingsMap) }}).forEach(oldSetting => { + const newSettingKey = settingsMap[oldSetting._id]; + const newSetting = newSettingKey && RocketChat.models.Settings.findOne({ _id: newSettingKey }); + + if (newSetting && newSetting.value !== oldSetting.value) { + RocketChat.models.Settings.update({ _id: newSettingKey }, { $set: { value: oldSetting.value } }); + } + RocketChat.models.Settings.remove({_id: oldSetting._id }); + }); + } + } + } +}); diff --git a/tests/end-to-end/ui/11-admin.js b/tests/end-to-end/ui/11-admin.js index 7ddd185c62a3..87a8eabbf842 100644 --- a/tests/end-to-end/ui/11-admin.js +++ b/tests/end-to-end/ui/11-admin.js @@ -637,12 +637,12 @@ describe('[Administration]', () => { before(() => { admin.generalButtonExpandNotifications.waitForVisible(5000); admin.generalButtonExpandNotifications.click(); - admin.generalNotificationDuration.waitForVisible(5000); - admin.generalNotificationDuration.scroll(); + admin.generalNotificationsMaxRoomMembers.waitForVisible(5000); + admin.generalNotificationsMaxRoomMembers.scroll(); }); - it('it should show the notifications durations field', () => { - admin.generalNotificationDuration.isVisible().should.be.true; + it('it should show the max room members field', () => { + admin.generalNotificationsMaxRoomMembers.isVisible().should.be.true; }); }); @@ -704,5 +704,251 @@ describe('[Administration]', () => { }); }); }); + + describe('[Accounts]', () => { + before(() => { + admin.settingsSearch.setValue('accounts'); + admin.accountsLink.waitForVisible(5000); + admin.accountsLink.click(); + admin.settingsSearch.setValue(''); + }); + + describe('default user preferences', () => { + before(() => { + if (admin.accountsButtonCollapseDefaultUserPreferences.isVisible()) { + admin.accountsButtonCollapseDefaultUserPreferences.click(); + } + admin.accountsButtonExpandDefaultUserPreferences.waitForVisible(5000); + admin.accountsButtonExpandDefaultUserPreferences.click(); + admin.accountsNotificationDuration.waitForVisible(5000); + }); + + it('it should show the enable auto away field', () => { + admin.accountsEnableAutoAwayTrue.scroll(); + admin.accountsEnableAutoAwayTrue.isVisible().should.be.true; + admin.accountsEnableAutoAwayFalse.isVisible().should.be.true; + }); + it('the enable auto away field value should be true', () => { + admin.accountsEnableAutoAwayTrue.isSelected().should.be.false; + admin.accountsEnableAutoAwayFalse.isSelected().should.be.true; + }); + + it('it should show the idle timeout limit field', () => { + admin.accountsIdleTimeoutLimit.click(); + admin.accountsIdleTimeoutLimit.isVisible().should.be.true; + }); + it('the idle timeout limit field value should be 0', () => { + admin.accountsIdleTimeoutLimit.getValue().should.equal('300000'); + }); + + it('it should show the notifications durations field', () => { + admin.accountsNotificationDuration.click(); + admin.accountsNotificationDuration.isVisible().should.be.true; + }); + it('the notification duration field value should be 0', () => { + admin.accountsNotificationDuration.getValue().should.equal('0'); + }); + + it('it should show the audio notifications select field', () => { + admin.accountsAudioNotifications.click(); + admin.accountsAudioNotifications.isVisible().should.be.true; + }); + it('the audio notifications field value should be mentions', () => { + admin.accountsAudioNotifications.getValue().should.equal('mentions'); + }); + + it('it should show the desktop audio notifications select field', () => { + admin.accountsDesktopNotifications.click(); + admin.accountsDesktopNotifications.isVisible().should.be.true; + }); + it('the desktop audio notifications field value should be mentions', () => { + admin.accountsDesktopNotifications.getValue().should.equal('mentions'); + }); + + it('it should show the mobile audio notifications select field', () => { + admin.accountsMobileNotifications.click(); + admin.accountsMobileNotifications.isVisible().should.be.true; + }); + it('the mobile audio notifications field value should be mentions', () => { + admin.accountsMobileNotifications.getValue().should.equal('mentions'); + }); + + it('it should show the unread tray icon alert field', () => { + admin.accountsUnreadAlertTrue.scroll(); + admin.accountsUnreadAlertTrue.isVisible().should.be.true; + admin.accountsUnreadAlertFalse.isVisible().should.be.true; + }); + it('the unread tray icon alert field value should be true', () => { + admin.accountsUnreadAlertTrue.isSelected().should.be.true; + admin.accountsUnreadAlertFalse.isSelected().should.be.false; + }); + + it('it should show the use emojis field', () => { + admin.accountsUseEmojisTrue.scroll(); + admin.accountsUseEmojisTrue.isVisible().should.be.true; + admin.accountsUseEmojisFalse.isVisible().should.be.true; + }); + it('the use emojis field value should be true', () => { + admin.accountsUseEmojisTrue.isSelected().should.be.true; + admin.accountsUseEmojisFalse.isSelected().should.be.false; + }); + + it('it should show the convert ascii to emoji field', () => { + admin.accountsConvertAsciiEmojiTrue.scroll(); + admin.accountsConvertAsciiEmojiTrue.isVisible().should.be.true; + admin.accountsConvertAsciiEmojiFalse.isVisible().should.be.true; + }); + it('the convert ascii to emoji field value should be true', () => { + admin.accountsConvertAsciiEmojiTrue.isSelected().should.be.true; + admin.accountsConvertAsciiEmojiFalse.isSelected().should.be.false; + }); + + it('it should show the auto load images field', () => { + admin.accountsAutoImageLoadTrue.scroll(); + admin.accountsAutoImageLoadTrue.isVisible().should.be.true; + admin.accountsAutoImageLoadFalse.isVisible().should.be.true; + }); + it('the auto load images field value should be true', () => { + admin.accountsAutoImageLoadTrue.isSelected().should.be.true; + admin.accountsAutoImageLoadFalse.isSelected().should.be.false; + }); + + it('it should show the save mobile bandwidth field', () => { + admin.accountsSaveMobileBandwidthTrue.scroll(); + admin.accountsSaveMobileBandwidthTrue.isVisible().should.be.true; + admin.accountsSaveMobileBandwidthFalse.isVisible().should.be.true; + }); + it('the save mobile bandwidth field value should be true', () => { + admin.accountsSaveMobileBandwidthTrue.isSelected().should.be.true; + admin.accountsSaveMobileBandwidthFalse.isSelected().should.be.false; + }); + + it('it should show the collapse embedded media by default field', () => { + admin.accountsCollapseMediaByDefaultTrue.scroll(); + admin.accountsCollapseMediaByDefaultTrue.isVisible().should.be.true; + admin.accountsCollapseMediaByDefaultFalse.isVisible().should.be.true; + }); + it('the collapse embedded media by default field value should be false', () => { + admin.accountsCollapseMediaByDefaultTrue.isSelected().should.be.false; + admin.accountsCollapseMediaByDefaultFalse.isSelected().should.be.true; + }); + + it('it should show the hide usernames field', () => { + admin.accountsHideUsernamesTrue.scroll(); + admin.accountsHideUsernamesTrue.isVisible().should.be.true; + admin.accountsHideUsernamesFalse.isVisible().should.be.true; + }); + it('the hide usernames field value should be false', () => { + admin.accountsHideUsernamesTrue.isSelected().should.be.false; + admin.accountsHideUsernamesFalse.isSelected().should.be.true; + }); + + it('it should show the hide roles field', () => { + admin.accountsHideRolesTrue.scroll(); + admin.accountsHideRolesTrue.isVisible().should.be.true; + admin.accountsHideRolesFalse.isVisible().should.be.true; + }); + it('the hide roles field value should be false', () => { + admin.accountsHideRolesTrue.isSelected().should.be.false; + admin.accountsHideRolesFalse.isSelected().should.be.true; + }); + + it('it should show the hide right sidebar with click field', () => { + admin.accountsHideFlexTabTrue.scroll(); + admin.accountsHideFlexTabTrue.isVisible().should.be.true; + admin.accountsHideFlexTabFalse.isVisible().should.be.true; + }); + it('the hide right sidebar with click field value should be false', () => { + admin.accountsHideFlexTabTrue.isSelected().should.be.false; + admin.accountsHideFlexTabFalse.isSelected().should.be.true; + }); + + it('it should show the hide avatars field', () => { + admin.accountsHideAvatarsTrue.scroll(); + admin.accountsHideAvatarsTrue.isVisible().should.be.true; + admin.accountsHideAvatarsFalse.isVisible().should.be.true; + }); + it('the hide avatars field value should be false', () => { + admin.accountsHideAvatarsTrue.isSelected().should.equal.false; + admin.accountsHideAvatarsFalse.isSelected().should.equal.true; + }); + + it('it should show the sidebar channel list mode field', () => { + admin.accountsRoomsListExhibitionMode.click(); + admin.accountsRoomsListExhibitionMode.isVisible().should.be.true; + }); + it('the sidebar channel list mode field value should be category', () => { + admin.accountsRoomsListExhibitionMode.getValue().should.equal('category'); + }); + + it('it should show the merge channels field', () => { + admin.accountsMergeChannelsTrue.scroll(); + admin.accountsMergeChannelsTrue.isVisible().should.be.true; + admin.accountsMergeChannelsFalse.isVisible().should.be.true; + }); + it('the merge channels field value should be false', () => { + admin.accountsMergeChannelsTrue.isSelected().should.be.false; + admin.accountsMergeChannelsFalse.isSelected().should.be.true; + }); + + it('it should show the enter key behavior field', () => { + admin.accountsSendOnEnter.click(); + admin.accountsSendOnEnter.isVisible().should.be.true; + }); + it('the enter key behavior field value should be normal', () => { + admin.accountsSendOnEnter.getValue().should.equal('normal'); + }); + + it('it should show the view mode field', () => { + admin.accountsViewMode.click(); + admin.accountsViewMode.isVisible().should.be.true; + }); + it('the view mode field value should be 0', () => { + admin.accountsViewMode.getValue().should.equal('0'); + }); + + it('it should show the offline email notification field', () => { + admin.accountsEmailNotificationMode.click(); + admin.accountsEmailNotificationMode.isVisible().should.be.true; + }); + it('the offline email notification field value should be all', () => { + admin.accountsEmailNotificationMode.getValue().should.equal('all'); + }); + + it('it should show the room counter sidebar field', () => { + admin.accountsRoomCounterSidebarTrue.scroll(); + admin.accountsRoomCounterSidebarTrue.isVisible().should.be.true; + admin.accountsRoomCounterSidebarFalse.isVisible().should.be.true; + }); + it('the room counter sidebar field value should be false', () => { + admin.accountsRoomCounterSidebarTrue.isSelected().should.be.false; + admin.accountsRoomCounterSidebarFalse.isSelected().should.be.true; + }); + + it('it should show the new room notification field', () => { + admin.accountsNewRoomNotification.click(); + admin.accountsNewRoomNotification.isVisible().should.be.true; + }); + it('the new room notification field value should be door', () => { + admin.accountsNewRoomNotification.getValue().should.equal('door'); + }); + + it('it should show the new message notification field', () => { + admin.accountsNewMessageNotification.click(); + admin.accountsNewMessageNotification.isVisible().should.be.true; + }); + it('the new message notification field value should be chime', () => { + admin.accountsNewMessageNotification.getValue().should.equal('chime'); + }); + + it('it should show the notification sound volume field', () => { + admin.accountsNotificationsSoundVolume.click(); + admin.accountsNotificationsSoundVolume.isVisible().should.be.true; + }); + it('the notification sound volume field value should be 100', () => { + admin.accountsNotificationsSoundVolume.getValue().should.equal('100'); + }); + }); + }); }); }); diff --git a/tests/pageobjects/administration.page.js b/tests/pageobjects/administration.page.js index 5cd27383d533..743bd2887ab9 100644 --- a/tests/pageobjects/administration.page.js +++ b/tests/pageobjects/administration.page.js @@ -107,8 +107,8 @@ class Administration extends Page { get generalIframeRecieveFalseReset() { return browser.element('.reset-setting[data-setting="Iframe_Integration_receive_enable"]'); } get generalIframeRecieveOrigin() { return browser.element('[name="Iframe_Integration_receive_origin"]'); } get generalIframeRecieveOriginReset() { return browser.element('.reset-setting[data-setting="Iframe_Integration_receive_origin"]'); } - get generalNotificationDuration() { return browser.element('[name="Desktop_Notifications_Duration"]'); } - get generalNotificationDurationReset() { return browser.element('.reset-setting[data-setting="Desktop_Notifications_Duration"]'); } + get generalNotificationsMaxRoomMembers() { return browser.element('[name="Notifications_Max_Room_Members"]'); } + get generalNotificationsMaxRoomMembersReset() { return browser.element('.reset-setting[data-setting="Notifications_Max_Room_Members"]'); } get generalRestApiUserLimit() { return browser.element('[name="API_User_Limit"]'); } get generalRestApiUserLimitReset() { return browser.element('.reset-setting[data-setting="API_User_Limit"]'); } get generalReportingTrue() { return browser.element('label:nth-of-type(1) [name="Statistics_reporting"]'); } @@ -122,8 +122,101 @@ class Administration extends Page { get generalUTF8NamesSlugFalse() { return browser.element('label:nth-of-type(2) [name="UTF8_Names_Slugify"]'); } get generalUTF8NamesSlugReset() { return browser.element('.reset-setting[data-setting="UTF8_Names_Slugify"]'); } + //accounts + get accountsButtonExpandDefaultUserPreferences() { return browser.element('.section:nth-of-type(3) .button.expand'); } + get accountsButtonCollapseDefaultUserPreferences() { return browser.element('.section:nth-of-type(3) .button.collapse'); } + + get accountsEnableAutoAwayTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_enableAutoAway"]'); } + get accountsEnableAutoAwayFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_enableAutoAway"]'); } + get accountsEnableAutoAwayReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_enableAutoAway"]'); } + + get accountsIdleTimeoutLimit() { return browser.element('[name="Accounts_Default_User_Preferences_idleTimeoutLimit"]'); } + get accountsIdleTimeoutLimitReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_idleTimeoutLimit"]'); } + + get accountsNotificationDuration() { return browser.element('[name="Accounts_Default_User_Preferences_desktopNotificationDuration"]'); } + get accountsNotificationDurationReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_desktopNotificationDuration"]'); } + + get accountsAudioNotifications() { return browser.element('[name="Accounts_Default_User_Preferences_audioNotifications"]'); } + get accountsAudioNotificationsReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_audioNotifications"]'); } + + get accountsDesktopNotifications() { return browser.element('[name="Accounts_Default_User_Preferences_desktopNotifications"]'); } + get accountsDesktopNotificationsReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_desktopNotifications"]'); } + + get accountsMobileNotifications() { return browser.element('[name="Accounts_Default_User_Preferences_mobileNotifications"]'); } + get accountsMobileNotificationsReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_mobileNotifications"]'); } + + get accountsUnreadAlertTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_unreadAlert"]'); } + get accountsUnreadAlertFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_unreadAlert"]'); } + get accountsUnreadAlertReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_unreadAlert"]'); } + + get accountsUseEmojisTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_useEmojis"]'); } + get accountsUseEmojisFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_useEmojis"]'); } + get accountsUseEmojisReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_useEmojis"]'); } + + get accountsConvertAsciiEmojiTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_convertAsciiEmoji"]'); } + get accountsConvertAsciiEmojiFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_convertAsciiEmoji"]'); } + get accountsConvertAsciiEmojiReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_convertAsciiEmoji"]'); } + + get accountsAutoImageLoadTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_autoImageLoad"]'); } + get accountsAutoImageLoadFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_autoImageLoad"]'); } + get accountsAutoImageLoadReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_autoImageLoad"]'); } + + get accountsSaveMobileBandwidthTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_saveMobileBandwidth"]'); } + get accountsSaveMobileBandwidthFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_saveMobileBandwidth"]'); } + get accountsSaveMobileBandwidthReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_saveMobileBandwidth"]'); } + + get accountsCollapseMediaByDefaultTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_collapseMediaByDefault"]'); } + get accountsCollapseMediaByDefaultFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_collapseMediaByDefault"]'); } + get accountsCollapseMediaByDefaultReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_collapseMediaByDefault"]'); } + + get accountsHideUsernamesTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_hideUsernames"]'); } + get accountsHideUsernamesFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_hideUsernames"]'); } + get accountsHideUsernamesReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_hideUsernames"]'); } + + get accountsHideRolesTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_hideRoles"]'); } + get accountsHideRolesFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_hideRoles"]'); } + get accountsHideRolesReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_hideRoles"]'); } + + get accountsHideFlexTabTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_hideFlexTab"]'); } + get accountsHideFlexTabFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_hideFlexTab"]'); } + get accountsHideFlexTabReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_hideFlexTab"]'); } + + get accountsHideAvatarsTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_hideAvatars"]'); } + get accountsHideAvatarsFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_hideAvatars"]'); } + get accountsHideAvatarsReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_hideAvatars"]'); } + + get accountsRoomsListExhibitionMode() { return browser.element('[name="Accounts_Default_User_Preferences_roomsListExhibitionMode"]'); } + get accountsRoomsListExhibitionModeReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_roomsListExhibitionMode"]'); } + + get accountsMergeChannelsTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_mergeChannels"]'); } + get accountsMergeChannelsFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_mergeChannels"]'); } + get accountsMergeChannelsReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_mergeChannels"]'); } + + get accountsSendOnEnter() { return browser.element('[name="Accounts_Default_User_Preferences_sendOnEnter"]'); } + get accountsSendOnEnterReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_sendOnEnter"]'); } + + get accountsViewMode() { return browser.element('[name="Accounts_Default_User_Preferences_viewMode"]'); } + get accountsViewModeReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_viewMode"]'); } + + get accountsEmailNotificationMode() { return browser.element('[name="Accounts_Default_User_Preferences_emailNotificationMode"]'); } + get accountsEmailNotificationModeReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_emailNotificationMode"]'); } + + get accountsRoomCounterSidebarTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_roomCounterSidebar"]'); } + get accountsRoomCounterSidebarFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_roomCounterSidebar"]'); } + get accountsRoomCounterSidebarReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_roomCounterSidebar"]'); } + + get accountsNewRoomNotification() { return browser.element('[name="Accounts_Default_User_Preferences_newRoomNotification"]'); } + get accountsNewRoomNotificationReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_newRoomNotification"]'); } + + get accountsNewMessageNotification() { return browser.element('[name="Accounts_Default_User_Preferences_newMessageNotification"]'); } + get accountsNewMessageNotificationReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_newMessageNotification"]'); } + + get accountsNotificationsSoundVolume() { return browser.element('[name="Accounts_Default_User_Preferences_notificationsSoundVolume"]'); } + get accountsNotificationsSoundVolumeReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_notificationsSoundVolume"]'); } + get accountsRealNameChangeTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_AllowRealNameChange"]'); } get accountsRealNameChangeFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_AllowRealNameChange"]'); } + get accountsUsernameChangeTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_AllowUsernameChange"]'); } get accountsUsernameChangeFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_AllowUsernameChange"]'); }