From b308a7f32537a0eccb3bc7625f1671b6956efeb9 Mon Sep 17 00:00:00 2001 From: Kai Alexander Fischer Date: Wed, 21 Feb 2018 23:41:01 +0100 Subject: [PATCH 01/10] Changed Idle Time Limit from milliseconds to seconds to make it more handy to use. --- client/startup/startup.js | 6 +++--- packages/rocketchat-i18n/i18n/en.i18n.json | 2 +- packages/rocketchat-lib/server/startup/settings.js | 2 +- tests/end-to-end/ui/11-admin.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/startup/startup.js b/client/startup/startup.js index 8279db3373a5..4a92434be37c 100644 --- a/client/startup/startup.js +++ b/client/startup/startup.js @@ -91,17 +91,17 @@ Meteor.startup(function() { } }; - const defaultIdleTimeLimit = 300000; + const defaultIdleTimeLimit = 300; Meteor.subscribe('userData', function() { const user = Meteor.user(); const userLanguage = user && user.language ? user.language : window.defaultUserLanguage(); if (!userHasPreferences(user)) { - UserPresence.awayTime = defaultIdleTimeLimit; + UserPresence.awayTime = defaultIdleTimeLimit * 1000; UserPresence.start(); } else { - UserPresence.awayTime = user.settings.preferences.idleTimeLimit || defaultIdleTimeLimit; + UserPresence.awayTime = (user.settings.preferences.idleTimeLimit || defaultIdleTimeLimit) * 1000; if (user.settings.preferences.hasOwnProperty('enableAutoAway')) { user.settings.preferences.enableAutoAway && UserPresence.start(); diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 743ec575c97e..fc11c8c7230b 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -999,7 +999,7 @@ "IssueLinks_LinkTemplate": "Template for issue links", "IssueLinks_LinkTemplate_Description": "Template for issue links; %s will be replaced by the issue number.", "It_works": "It works", - "Idle_Time_Limit": "Idle Time Limit", + "Idle_Time_Limit": "Idle Time Limit (Sec.)", "italics": "italics", "Jitsi_Chrome_Extension": "Chrome Extension Id", "Jitsi_Enable_Channels": "Enable in Channels", diff --git a/packages/rocketchat-lib/server/startup/settings.js b/packages/rocketchat-lib/server/startup/settings.js index 42f4bb23f84b..770711e26654 100644 --- a/packages/rocketchat-lib/server/startup/settings.js +++ b/packages/rocketchat-lib/server/startup/settings.js @@ -177,7 +177,7 @@ RocketChat.settings.addGroup('Accounts', function() { 'public': true, i18nLabel: 'Enable_Auto_Away' }); - this.add('Accounts_Default_User_Preferences_idleTimeoutLimit', 300000, { + this.add('Accounts_Default_User_Preferences_idleTimeoutLimit', 300, { type: 'int', 'public': true, i18nLabel: 'Idle_Time_Limit' diff --git a/tests/end-to-end/ui/11-admin.js b/tests/end-to-end/ui/11-admin.js index 4db35c992377..854e193580af 100644 --- a/tests/end-to-end/ui/11-admin.js +++ b/tests/end-to-end/ui/11-admin.js @@ -740,7 +740,7 @@ describe('[Administration]', () => { admin.accountsIdleTimeoutLimit.isVisible().should.be.true; }); it('the idle timeout limit field value should be 0', () => { - admin.accountsIdleTimeoutLimit.getValue().should.equal('300000'); + admin.accountsIdleTimeoutLimit.getValue().should.equal('300'); }); it('it should show the notifications durations field', () => { From 13cfcdb94e27c9e85f1e4bd5bbfb207c2e7646b3 Mon Sep 17 00:00:00 2001 From: Kai Alexander Fischer Date: Wed, 21 Feb 2018 23:41:42 +0100 Subject: [PATCH 02/10] Database Migration to convert Idle Time Limit from milliseconds to seconds. --- server/startup/migrations/v108.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 server/startup/migrations/v108.js diff --git a/server/startup/migrations/v108.js b/server/startup/migrations/v108.js new file mode 100644 index 000000000000..d7713a9ee92c --- /dev/null +++ b/server/startup/migrations/v108.js @@ -0,0 +1,26 @@ +RocketChat.Migrations.add({ + version: 108, + up() { + if (RocketChat && RocketChat.models) { + + if (RocketChat.models.Settings) { + const setting = RocketChat.models.Settings.findOne({ _id: 'Accounts_Default_User_Preferences_idleTimeoutLimit' }); + if (setting && setting.value) { + RocketChat.models.Settings.update( + { _id: 'Accounts_Default_User_Preferences_idleTimeoutLimit' }, + { $set: { value: setting.value / 1000 } } + ); + } + } + + if (RocketChat.models.Users) { + RocketChat.models.Users.find({ 'settings.preferences.idleTimeLimit': { $exists: 1 } }).forEach(function(user) { + RocketChat.models.Users.update( + { _id: user._id }, + { $set: { 'settings.preferences.idleTimeLimit': user.settings.preferences.idleTimeLimit / 1000 } } + ); + }); + } + } + } +}); \ No newline at end of file From c66cd346d272b993cf970f1a0f2c62628194374b Mon Sep 17 00:00:00 2001 From: Kai Alexander Fischer Date: Thu, 22 Feb 2018 00:20:04 +0100 Subject: [PATCH 03/10] Added a new line at the end of the migration file --- server/startup/migrations/v108.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/startup/migrations/v108.js b/server/startup/migrations/v108.js index d7713a9ee92c..b2466b3b8a69 100644 --- a/server/startup/migrations/v108.js +++ b/server/startup/migrations/v108.js @@ -23,4 +23,4 @@ RocketChat.Migrations.add({ } } } -}); \ No newline at end of file +}); From 9b56f3cbbb7be4a2704f016db62c006a3f4445c4 Mon Sep 17 00:00:00 2001 From: Kai Alexander Fischer Date: Thu, 22 Feb 2018 01:15:43 +0100 Subject: [PATCH 04/10] Add Idle Time Limit description --- packages/rocketchat-i18n/i18n/en.i18n.json | 3 ++- packages/rocketchat-ui-account/client/accountPreferences.html | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index fc11c8c7230b..5416eb02c14d 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -999,7 +999,8 @@ "IssueLinks_LinkTemplate": "Template for issue links", "IssueLinks_LinkTemplate_Description": "Template for issue links; %s will be replaced by the issue number.", "It_works": "It works", - "Idle_Time_Limit": "Idle Time Limit (Sec.)", + "Idle_Time_Limit": "Idle Time Limit", + "Idle_Time_Limit_Description": "Period of time until status changes to away. Value needs to be in seconds.", "italics": "italics", "Jitsi_Chrome_Extension": "Chrome Extension Id", "Jitsi_Enable_Channels": "Enable in Channels", diff --git a/packages/rocketchat-ui-account/client/accountPreferences.html b/packages/rocketchat-ui-account/client/accountPreferences.html index 9fdde67ee0cf..df5b9a08908f 100644 --- a/packages/rocketchat-ui-account/client/accountPreferences.html +++ b/packages/rocketchat-ui-account/client/accountPreferences.html @@ -43,6 +43,7 @@

{{_ "User_Presence"}}

{{else}} {{/if}} +
{{_ "Idle_Time_Limit_Description"}}
From 9ba12a2843b2f6cfc039803e5ee9a01e73116bea Mon Sep 17 00:00:00 2001 From: Kai Alexander Fischer Date: Tue, 27 Mar 2018 19:46:20 +0200 Subject: [PATCH 05/10] Changed migration version number from 108 to 109 to resolve merge conflict --- server/startup/migrations/{v108.js => v109.js} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename server/startup/migrations/{v108.js => v109.js} (98%) diff --git a/server/startup/migrations/v108.js b/server/startup/migrations/v109.js similarity index 98% rename from server/startup/migrations/v108.js rename to server/startup/migrations/v109.js index b2466b3b8a69..69bb099c4e82 100644 --- a/server/startup/migrations/v108.js +++ b/server/startup/migrations/v109.js @@ -1,5 +1,5 @@ RocketChat.Migrations.add({ - version: 108, + version: 109, up() { if (RocketChat && RocketChat.models) { From 74f316f2618f6219cbe728f25b304c8d364ea925 Mon Sep 17 00:00:00 2001 From: Kai Alexander Fischer Date: Tue, 27 Mar 2018 20:38:11 +0200 Subject: [PATCH 06/10] Rerun tests --- server/startup/migrations/v109.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/startup/migrations/v109.js b/server/startup/migrations/v109.js index 69bb099c4e82..9f51e999e032 100644 --- a/server/startup/migrations/v109.js +++ b/server/startup/migrations/v109.js @@ -11,7 +11,7 @@ RocketChat.Migrations.add({ { $set: { value: setting.value / 1000 } } ); } - } + }a if (RocketChat.models.Users) { RocketChat.models.Users.find({ 'settings.preferences.idleTimeLimit': { $exists: 1 } }).forEach(function(user) { From eebdba115b041aef117148063d06979006bde012 Mon Sep 17 00:00:00 2001 From: Kai Alexander Fischer Date: Tue, 27 Mar 2018 20:38:36 +0200 Subject: [PATCH 07/10] Rerun tests --- server/startup/migrations/v109.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/startup/migrations/v109.js b/server/startup/migrations/v109.js index 9f51e999e032..69bb099c4e82 100644 --- a/server/startup/migrations/v109.js +++ b/server/startup/migrations/v109.js @@ -11,7 +11,7 @@ RocketChat.Migrations.add({ { $set: { value: setting.value / 1000 } } ); } - }a + } if (RocketChat.models.Users) { RocketChat.models.Users.find({ 'settings.preferences.idleTimeLimit': { $exists: 1 } }).forEach(function(user) { From f6327c643a019c6cc96a67067a09ccbe0a5bdbe1 Mon Sep 17 00:00:00 2001 From: Kai Alexander Fischer Date: Sun, 1 Apr 2018 23:42:16 +0200 Subject: [PATCH 08/10] Changed migration version number, as there has been a merge conflict again. --- server/startup/migrations/{v109.js => v110.js} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename server/startup/migrations/{v109.js => v110.js} (98%) diff --git a/server/startup/migrations/v109.js b/server/startup/migrations/v110.js similarity index 98% rename from server/startup/migrations/v109.js rename to server/startup/migrations/v110.js index 69bb099c4e82..50c780286012 100644 --- a/server/startup/migrations/v109.js +++ b/server/startup/migrations/v110.js @@ -1,5 +1,5 @@ RocketChat.Migrations.add({ - version: 109, + version: 110, up() { if (RocketChat && RocketChat.models) { From 7e63a7d1a9dc39de6271063c812f7c80a4ab1d12 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 17 Apr 2018 17:22:39 -0300 Subject: [PATCH 09/10] Change migrasion version to 112 --- server/startup/migrations/{v110.js => v112.js} | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) rename server/startup/migrations/{v110.js => v112.js} (98%) diff --git a/server/startup/migrations/v110.js b/server/startup/migrations/v112.js similarity index 98% rename from server/startup/migrations/v110.js rename to server/startup/migrations/v112.js index 50c780286012..60c5cb5b03a7 100644 --- a/server/startup/migrations/v110.js +++ b/server/startup/migrations/v112.js @@ -1,8 +1,7 @@ RocketChat.Migrations.add({ - version: 110, + version: 112, up() { if (RocketChat && RocketChat.models) { - if (RocketChat.models.Settings) { const setting = RocketChat.models.Settings.findOne({ _id: 'Accounts_Default_User_Preferences_idleTimeoutLimit' }); if (setting && setting.value) { From 6679f82b425c5ad5354fa5ab7716f416265e1028 Mon Sep 17 00:00:00 2001 From: Bradley Hilton Date: Tue, 17 Apr 2018 22:12:40 -0500 Subject: [PATCH 10/10] Update the idle timeout test description to 300 --- tests/end-to-end/ui/11-admin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end-to-end/ui/11-admin.js b/tests/end-to-end/ui/11-admin.js index ffa6185ea086..d48070b8dc3e 100644 --- a/tests/end-to-end/ui/11-admin.js +++ b/tests/end-to-end/ui/11-admin.js @@ -739,7 +739,7 @@ describe('[Administration]', () => { admin.accountsIdleTimeoutLimit.click(); admin.accountsIdleTimeoutLimit.isVisible().should.be.true; }); - it('the idle timeout limit field value should be 0', () => { + it('the idle timeout limit field value should be 300', () => { admin.accountsIdleTimeoutLimit.getValue().should.equal('300'); });