From 5ab7af28a7154a16ac1b577c7cd73d093e779aa5 Mon Sep 17 00:00:00 2001 From: mpdbl Date: Wed, 12 Jun 2019 16:24:30 +0200 Subject: [PATCH 01/10] added default and user specific setting for desktop notification --- app/lib/server/startup/settings.js | 5 +++++ app/ui-account/client/accountPreferences.html | 7 +++++++ app/ui-account/client/accountPreferences.js | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/app/lib/server/startup/settings.js b/app/lib/server/startup/settings.js index ae78b61fce324..5585ae0334cfc 100644 --- a/app/lib/server/startup/settings.js +++ b/app/lib/server/startup/settings.js @@ -217,6 +217,11 @@ settings.addGroup('Accounts', function() { public: true, i18nLabel: 'Notification_Duration', }); + this.add('Accounts_Default_User_Preferences_desktopNotificationRequireInteraction', false, { + type: 'boolean', + public: true, + i18nLabel: 'Notification_RequireInteraction', + }); this.add('Accounts_Default_User_Preferences_audioNotifications', 'mentions', { type: 'select', values: [ diff --git a/app/ui-account/client/accountPreferences.html b/app/ui-account/client/accountPreferences.html index 76e95a26c0388..bcb4bdf57e5b6 100644 --- a/app/ui-account/client/accountPreferences.html +++ b/app/ui-account/client/accountPreferences.html @@ -102,6 +102,13 @@

{{_ "Notifications"}}

{{/if}} +
+ +
+ + +
+
diff --git a/app/ui-account/client/accountPreferences.js b/app/ui-account/client/accountPreferences.js index 247fc07851798..d05427a055fc7 100644 --- a/app/ui-account/client/accountPreferences.js +++ b/app/ui-account/client/accountPreferences.js @@ -87,6 +87,13 @@ Template.accountPreferences.helpers({ defaultDesktopNotificationDuration() { return settings.get('Accounts_Default_User_Preferences_desktopNotificationDuration'); }, + desktopNotificationRequireInteraction() { + const userPref = getUserPreference(Meteor.userId(), 'desktopNotificationRequireInteraction', 'undefined'); + return userPref !== 'undefined' ? userPref : undefined; + }, + defaultDesktopNotificationRequireInteraction() { + return settings.get('Accounts_Default_User_Preferences_desktopNotificationRequireInteraction'); + }, idleTimeLimit() { return getUserPreference(Meteor.userId(), 'idleTimeLimit'); }, @@ -165,6 +172,7 @@ Template.accountPreferences.onCreated(function() { data.autoImageLoad = JSON.parse($('input[name=autoImageLoad]:checked').val()); data.emailNotificationMode = $('select[name=emailNotificationMode]').val(); data.desktopNotificationDuration = $('input[name=desktopNotificationDuration]').val() === '' ? settings.get('Accounts_Default_User_Preferences_desktopNotificationDuration') : parseInt($('input[name=desktopNotificationDuration]').val()); + data.desktopNotificationRequireInteraction = $('input[name=desktopNotificationRequireInteraction]:checked').val() === undefined ? settings.get('Accounts_Default_User_Preferences_desktopNotificationRequireInteraction') : ($('input[name=desktopNotificationRequireInteraction]:checked').val() === 'true' ? true : false);//($('input[name=desktopNotificationRequireInteraction]:checked').val() !== true ? false : true); data.desktopNotifications = $('#desktopNotifications').find('select').val(); data.mobileNotifications = $('#mobileNotifications').find('select').val(); data.unreadAlert = JSON.parse($('#unreadAlert').find('input:checked').val()); From 2b850aeb4d812e79dc3195e25f1bc94f8ec653c3 Mon Sep 17 00:00:00 2001 From: mpdbl Date: Wed, 12 Jun 2019 16:26:17 +0200 Subject: [PATCH 02/10] added parameter to REST API endpoint users.setPreferences require user interaction setting of desktop notifications --- app/api/server/v1/users.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/api/server/v1/users.js b/app/api/server/v1/users.js index 1cf3926f035df..2d9d02b03bc8d 100644 --- a/app/api/server/v1/users.js +++ b/app/api/server/v1/users.js @@ -436,6 +436,7 @@ API.v1.addRoute('users.setPreferences', { authRequired: true }, { enableAutoAway: Match.Maybe(Boolean), highlights: Match.Maybe(Array), desktopNotificationDuration: Match.Maybe(Number), + desktopNotificationRequireInteraction: Match.Maybe(Boolean), messageViewMode: Match.Maybe(Number), hideUsernames: Match.Maybe(Boolean), hideRoles: Match.Maybe(Boolean), From 1a5b2c5cbd67afc33f3b3b26f90a8a4f5f7de78b Mon Sep 17 00:00:00 2001 From: mpdbl Date: Wed, 12 Jun 2019 16:28:53 +0200 Subject: [PATCH 03/10] added usage of user specific setting 'desktopNotificationRequireInteraction' --- app/ui/client/lib/notification.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/ui/client/lib/notification.js b/app/ui/client/lib/notification.js index 253ce7f7da72d..a73d4402dc27c 100644 --- a/app/ui/client/lib/notification.js +++ b/app/ui/client/lib/notification.js @@ -40,6 +40,7 @@ export const KonchatNotification = { tag: notification.payload._id, silent: true, canReply: true, + requireInteraction: getUserPreference(Meteor.userId(), 'desktopNotificationRequireInteraction'), }); const notificationDuration = notification.duration - 0 || getUserPreference(Meteor.userId(), 'desktopNotificationDuration') - 0; From 490e478aea47805154f0d4a9203dd96988498837 Mon Sep 17 00:00:00 2001 From: mpdbl Date: Thu, 13 Jun 2019 15:32:55 +0200 Subject: [PATCH 04/10] added descriptions for user preference and default setting --- app/lib/server/startup/settings.js | 1 + app/ui-account/client/accountPreferences.html | 1 + 2 files changed, 2 insertions(+) diff --git a/app/lib/server/startup/settings.js b/app/lib/server/startup/settings.js index 5585ae0334cfc..e533c392a727f 100644 --- a/app/lib/server/startup/settings.js +++ b/app/lib/server/startup/settings.js @@ -221,6 +221,7 @@ settings.addGroup('Accounts', function() { type: 'boolean', public: true, i18nLabel: 'Notification_RequireInteraction', + i18nDescription: "Notification_RequireInteraction_Description", }); this.add('Accounts_Default_User_Preferences_audioNotifications', 'mentions', { type: 'select', diff --git a/app/ui-account/client/accountPreferences.html b/app/ui-account/client/accountPreferences.html index bcb4bdf57e5b6..d60c59f54fcc3 100644 --- a/app/ui-account/client/accountPreferences.html +++ b/app/ui-account/client/accountPreferences.html @@ -107,6 +107,7 @@

{{_ "Notifications"}}

+
{{_ "Only_works_with_chrome_version_greater_50"}}
From 3d05a84f86566955f28b3b2bd3087ba07f3a76db Mon Sep 17 00:00:00 2001 From: mpdbl Date: Thu, 13 Jun 2019 15:37:19 +0200 Subject: [PATCH 05/10] add descriptions and label texts --- packages/rocketchat-i18n/i18n/de-IN.i18n.json | 5 ++++- packages/rocketchat-i18n/i18n/de.i18n.json | 5 ++++- packages/rocketchat-i18n/i18n/en.i18n.json | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/rocketchat-i18n/i18n/de-IN.i18n.json b/packages/rocketchat-i18n/i18n/de-IN.i18n.json index b3d2851cb0403..ca0d15a683a81 100644 --- a/packages/rocketchat-i18n/i18n/de-IN.i18n.json +++ b/packages/rocketchat-i18n/i18n/de-IN.i18n.json @@ -2152,6 +2152,8 @@ "Not_Imported_Messages_Title": "Der Import folgender Nachrichten schlug fehl", "Notification_Desktop_Default_For": "Desktop-Benachrichtigungen anzeigen für", "Notification_Duration": "Benachrichtigungsdauer", + "Notification_RequireInteraction": "Desktop-Benachrichtigung nach Interaktion ausblenden", + "Notification_RequireInteraction_Description": "Verwendung nur mit Chrome Browser Version > 50 möglich. Verwendet den Parameter requireInteraction um die Anzeigedauer der Desktop-Benachrichtigung bis zur Benutzerinteraktion zu verlängern.", "Notification_Mobile_Default_For": "Mobile Benachrichtigungen anzeigen für", "Notifications": "Benachrichtigungen", "Notifications_Always_Notify_Mobile": "Immer das Mobiltelefon benachrichtigen", @@ -2200,6 +2202,7 @@ "Only_authorized_users_can_write_new_messages": "Nur Authentifizierte Benutzer können neue Nachrichten schreiben", "Only_from_users": "Löscht nur den Inhalt dieser Benutzer", "Only_On_Desktop": "Desktop Modus (senden mit der Eingabeaste nur auf dem Desktop PC)", + "Only_works_with_chrome_version_greater_50": "Funktioniert nur mit Chrome Browser Versionen > 50", "Only_you_can_see_this_message": "Nur Du kannst diese Nachricht sehen", "Oops!": "Hoppla", "Oops_page_not_found": "Hoppla, Seite nicht gefunden", @@ -3246,4 +3249,4 @@ "Your_question": "Deine Frage", "Your_server_link": "Dein Server-Link", "Your_workspace_is_ready": "Dein Arbeitsbereich ist einsatzbereit 🎉" -} \ 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 7a984a63e8b22..ce55573e2709e 100644 --- a/packages/rocketchat-i18n/i18n/de.i18n.json +++ b/packages/rocketchat-i18n/i18n/de.i18n.json @@ -2162,6 +2162,8 @@ "Not_Imported_Messages_Title": "Der Import folgender Nachrichten schlug fehl", "Notification_Desktop_Default_For": "Desktop-Benachrichtigungen anzeigen für", "Notification_Duration": "Benachrichtigungsdauer", + "Notification_RequireInteraction": "Benachrichtigung erst nach Benutzerinteraktion ausblenden", + "Notification_RequireInteraction_Description": "Verwendung nur mit Chrome Browser Version > 50 möglich. Verwendet den Parameter requireInteraction um die Anzeigedauer der Desktop-Benachrichtigung bis zur Benutzerinteraktion zu verlängern.", "Notification_Mobile_Default_For": "Mobile Benachrichtigungen anzeigen für", "Notifications": "Benachrichtigungen", "Notifications_Always_Notify_Mobile": "Immer das Mobiltelefon benachrichtigen", @@ -2210,6 +2212,7 @@ "Only_authorized_users_can_write_new_messages": "Nur Authentifizierte Benutzer können neue Nachrichten schreiben", "Only_from_users": "Löscht nur den Inhalt dieser Benutzer (lassen Sie den Inhalt leer)", "Only_On_Desktop": "Desktop Modus (senden mit der Eingabeaste nur auf dem Desktop PC)", + "Only_works_with_chrome_version_greater_50": "Funktioniert nur mit Chrome Browser Versionen > 50", "Only_you_can_see_this_message": "Nur Sie können diese Nachricht sehen", "Oops!": "Hoppla", "Oops_page_not_found": "Hoppla, Seite nicht gefunden", @@ -3259,4 +3262,4 @@ "Your_question": "Ihre Frage", "Your_server_link": "Ihre Serververbindung", "Your_workspace_is_ready": "Ihr Arbeitsbereich ist einsatzbereit 🎉" -} \ No newline at end of file +} diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 64bf88bd3887c..da981a34c529f 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -2214,6 +2214,7 @@ "Only_authorized_users_can_write_new_messages": "Only authorized users can write new messages", "Only_from_users": "Only prune content from these users (leave empty to prune everyone's content)", "Only_On_Desktop": "Desktop mode (only sends with enter on desktop)", + "Only_works_with_chrome_version_greater_50": "Only works with Chrome browser versions > 50", "Only_you_can_see_this_message": "Only you can see this message", "Oops!": "Oops", "Oops_page_not_found": "Oops, page not found", From 5be9b1007ab9278561e7afe01c41535001432fd2 Mon Sep 17 00:00:00 2001 From: mpdbl Date: Thu, 13 Jun 2019 15:50:49 +0200 Subject: [PATCH 06/10] corrected String delimiter --- app/lib/server/startup/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/server/startup/settings.js b/app/lib/server/startup/settings.js index e533c392a727f..64729e9e9a3aa 100644 --- a/app/lib/server/startup/settings.js +++ b/app/lib/server/startup/settings.js @@ -221,7 +221,7 @@ settings.addGroup('Accounts', function() { type: 'boolean', public: true, i18nLabel: 'Notification_RequireInteraction', - i18nDescription: "Notification_RequireInteraction_Description", + i18nDescription: 'Notification_RequireInteraction_Description', }); this.add('Accounts_Default_User_Preferences_audioNotifications', 'mentions', { type: 'select', From eecb20703f8678a4c8e459a78e91f57e7136b71d Mon Sep 17 00:00:00 2001 From: mpdbl Date: Thu, 13 Jun 2019 16:38:55 +0200 Subject: [PATCH 07/10] changes due to missing compliance with lint rules --- app/ui-account/client/accountPreferences.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/ui-account/client/accountPreferences.js b/app/ui-account/client/accountPreferences.js index d05427a055fc7..80c27618162c3 100644 --- a/app/ui-account/client/accountPreferences.js +++ b/app/ui-account/client/accountPreferences.js @@ -172,7 +172,6 @@ Template.accountPreferences.onCreated(function() { data.autoImageLoad = JSON.parse($('input[name=autoImageLoad]:checked').val()); data.emailNotificationMode = $('select[name=emailNotificationMode]').val(); data.desktopNotificationDuration = $('input[name=desktopNotificationDuration]').val() === '' ? settings.get('Accounts_Default_User_Preferences_desktopNotificationDuration') : parseInt($('input[name=desktopNotificationDuration]').val()); - data.desktopNotificationRequireInteraction = $('input[name=desktopNotificationRequireInteraction]:checked').val() === undefined ? settings.get('Accounts_Default_User_Preferences_desktopNotificationRequireInteraction') : ($('input[name=desktopNotificationRequireInteraction]:checked').val() === 'true' ? true : false);//($('input[name=desktopNotificationRequireInteraction]:checked').val() !== true ? false : true); data.desktopNotifications = $('#desktopNotifications').find('select').val(); data.mobileNotifications = $('#mobileNotifications').find('select').val(); data.unreadAlert = JSON.parse($('#unreadAlert').find('input:checked').val()); @@ -190,6 +189,12 @@ Template.accountPreferences.onCreated(function() { data.hideRoles = JSON.parse($('#hideRoles').find('input:checked').val()); } + if ($('input[name=desktopNotificationRequireInteraction]:checked').val() === undefined) { + data.desktopNotificationRequireInteraction = settings.get('Accounts_Default_User_Preferences_desktopNotificationRequireInteraction'); + } else { + data.desktopNotificationRequireInteraction = JSON.parse($('input[name=desktopNotificationRequireInteraction]:checked').val()); + } + // if highlights changed we need page reload const highlights = getUserPreference(Meteor.userId(), 'highlights'); if (highlights && highlights.join('\n') !== data.highlights.join('\n')) { From 890a6f9f52cef7e8962eaf0d134098cb600441a4 Mon Sep 17 00:00:00 2001 From: mpdbl Date: Thu, 13 Jun 2019 17:05:38 +0200 Subject: [PATCH 08/10] added settings label and description --- packages/rocketchat-i18n/i18n/en.i18n.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index da981a34c529f..a1bf3a8ffbcb7 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -2166,6 +2166,8 @@ "Not_Imported_Messages_Title": "The following messages were not imported successfully", "Notification_Desktop_Default_For": "Show Desktop Notifications For", "Notification_Duration": "Notification Duration", + "Notification_RequireInteraction": "Close Desktop Notifications after user interaction", + "Notification_RequireInteraction_Description": "Works only with Chrome browser versions > 50. Utilizes the parameter requireInteraction to show the desktop notification to indefinite until the user interacts with it.", "Notification_Mobile_Default_For": "Push Mobile Notifications For", "Notifications": "Notifications", "Notifications_Always_Notify_Mobile": "Always notify mobile", From a228a2fd2aef70168f8fe42ce038d3d6c3503bf0 Mon Sep 17 00:00:00 2001 From: mpdbl Date: Mon, 17 Jun 2019 08:36:55 +0200 Subject: [PATCH 09/10] added missing parameter desktopNotificationRequireInteraction for tests --- tests/data/user.js | 1 + tests/end-to-end/api/00-miscellaneous.js | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/data/user.js b/tests/data/user.js index a43f4a4310d47..52f88dfd64fd9 100644 --- a/tests/data/user.js +++ b/tests/data/user.js @@ -24,6 +24,7 @@ export const preferences = { enableAutoAway: true, highlights: [], desktopNotificationDuration: 0, + desktopNotificationRequireInteraction: false, messageViewMode: 0, hideUsernames: false, hideRoles: false, diff --git a/tests/end-to-end/api/00-miscellaneous.js b/tests/end-to-end/api/00-miscellaneous.js index 3a6773fa2bac4..32fc0632192bb 100644 --- a/tests/end-to-end/api/00-miscellaneous.js +++ b/tests/end-to-end/api/00-miscellaneous.js @@ -125,6 +125,7 @@ describe('miscellaneous', function() { 'enableAutoAway', // 'highlights', 'desktopNotificationDuration', + 'desktopNotificationRequireInteraction', 'messageViewMode', 'hideUsernames', 'hideRoles', From 0e2c8ea24b96263502f5e7ddee0ed2b5a31a9f10 Mon Sep 17 00:00:00 2001 From: mpDBL Date: Mon, 15 Jul 2019 15:16:25 +0200 Subject: [PATCH 10/10] updated descriptive texts for user setting --- packages/rocketchat-i18n/i18n/de-IN.i18n.json | 2 +- packages/rocketchat-i18n/i18n/de.i18n.json | 2 +- packages/rocketchat-i18n/i18n/en.i18n.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/rocketchat-i18n/i18n/de-IN.i18n.json b/packages/rocketchat-i18n/i18n/de-IN.i18n.json index ca0d15a683a81..665f07e54b39b 100644 --- a/packages/rocketchat-i18n/i18n/de-IN.i18n.json +++ b/packages/rocketchat-i18n/i18n/de-IN.i18n.json @@ -2152,7 +2152,7 @@ "Not_Imported_Messages_Title": "Der Import folgender Nachrichten schlug fehl", "Notification_Desktop_Default_For": "Desktop-Benachrichtigungen anzeigen für", "Notification_Duration": "Benachrichtigungsdauer", - "Notification_RequireInteraction": "Desktop-Benachrichtigung nach Interaktion ausblenden", + "Notification_RequireInteraction": "Der Benutzer muss mit der Desktop-Benachrichtigung interagieren um diese auszublenden", "Notification_RequireInteraction_Description": "Verwendung nur mit Chrome Browser Version > 50 möglich. Verwendet den Parameter requireInteraction um die Anzeigedauer der Desktop-Benachrichtigung bis zur Benutzerinteraktion zu verlängern.", "Notification_Mobile_Default_For": "Mobile Benachrichtigungen anzeigen für", "Notifications": "Benachrichtigungen", diff --git a/packages/rocketchat-i18n/i18n/de.i18n.json b/packages/rocketchat-i18n/i18n/de.i18n.json index ce55573e2709e..e77cc572f58b0 100644 --- a/packages/rocketchat-i18n/i18n/de.i18n.json +++ b/packages/rocketchat-i18n/i18n/de.i18n.json @@ -2162,7 +2162,7 @@ "Not_Imported_Messages_Title": "Der Import folgender Nachrichten schlug fehl", "Notification_Desktop_Default_For": "Desktop-Benachrichtigungen anzeigen für", "Notification_Duration": "Benachrichtigungsdauer", - "Notification_RequireInteraction": "Benachrichtigung erst nach Benutzerinteraktion ausblenden", + "Notification_RequireInteraction": "Benutzerinteraktion notwendig um Benachrichtigung auszublenden", "Notification_RequireInteraction_Description": "Verwendung nur mit Chrome Browser Version > 50 möglich. Verwendet den Parameter requireInteraction um die Anzeigedauer der Desktop-Benachrichtigung bis zur Benutzerinteraktion zu verlängern.", "Notification_Mobile_Default_For": "Mobile Benachrichtigungen anzeigen für", "Notifications": "Benachrichtigungen", diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 09c689e32c273..260435e22d4d9 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -2179,7 +2179,7 @@ "Not_Imported_Messages_Title": "The following messages were not imported successfully", "Notification_Desktop_Default_For": "Show Desktop Notifications For", "Notification_Duration": "Notification Duration", - "Notification_RequireInteraction": "Close Desktop Notifications after user interaction", + "Notification_RequireInteraction": "Require Interaction to Dismiss Desktop Notification", "Notification_RequireInteraction_Description": "Works only with Chrome browser versions > 50. Utilizes the parameter requireInteraction to show the desktop notification to indefinite until the user interacts with it.", "Notification_Mobile_Default_For": "Push Mobile Notifications For", "Notifications": "Notifications",