Skip to content

Commit

Permalink
[NEW] Implements user's preferences helper function
Browse files Browse the repository at this point in the history
- The function returns one of three values:
  1 - The user's preference (user.settings.preferences.<preference>)
  2 - The default system setting value (Default_User_Preferences_<preference>)
  3 - A default value passed as argument to the function

- Besides the introduction of the helper function:
  - Removes unused preferences (user.settings.preferences.unreadRoomsMode, user.settings.preferences.audioNotificationValue) and creates migration script (v105)
  - Implements some simple tests
  • Loading branch information
goiaba committed Dec 11, 2017
1 parent 4d46831 commit c7dcc51
Show file tree
Hide file tree
Showing 49 changed files with 799 additions and 287 deletions.
2 changes: 1 addition & 1 deletion client/startup/unread.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '•';
}
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-emoji-emojione/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-emoji/client/emojiParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-highlight-words/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 3 additions & 3 deletions packages/rocketchat-i18n/i18n/ca.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:<br/><code>{\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}</code> ",
"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",
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
9 changes: 4 additions & 5 deletions packages/rocketchat-i18n/i18n/cs.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"Accounts_CustomFields_Description": "Validní JSON obsahující klíče polí s nastavením. Například:<br/><code>{\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}</code>",
"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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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í",
Expand Down Expand Up @@ -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í"
}
}
7 changes: 3 additions & 4 deletions packages/rocketchat-i18n/i18n/de.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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: <br/>\n<code>{\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}</code>",
"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.",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:<br/><code>{\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}</code> ",
"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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-i18n/i18n/fr.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 :<br/>\n<code>{\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}</code> ",
"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é",
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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"
}
}
4 changes: 2 additions & 2 deletions packages/rocketchat-i18n/i18n/pl.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
4 changes: 4 additions & 0 deletions packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:<br/><code>{\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}</code> ",
"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",
Expand Down
Loading

0 comments on commit c7dcc51

Please sign in to comment.