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 44e8f3fe4791..f2367bfc0d65 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1018,6 +1018,7 @@ "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_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-lib/server/startup/settings.js b/packages/rocketchat-lib/server/startup/settings.js index 05f9f9f86c4b..fb8b9079508a 100644 --- a/packages/rocketchat-lib/server/startup/settings.js +++ b/packages/rocketchat-lib/server/startup/settings.js @@ -185,7 +185,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/packages/rocketchat-ui-account/client/accountPreferences.html b/packages/rocketchat-ui-account/client/accountPreferences.html index ccdb736a037f..d7d50eedf8d2 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"}}
diff --git a/server/startup/migrations/v112.js b/server/startup/migrations/v112.js new file mode 100644 index 000000000000..60c5cb5b03a7 --- /dev/null +++ b/server/startup/migrations/v112.js @@ -0,0 +1,25 @@ +RocketChat.Migrations.add({ + 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) { + 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 } } + ); + }); + } + } + } +}); diff --git a/tests/end-to-end/ui/11-admin.js b/tests/end-to-end/ui/11-admin.js index 84399d392e38..d48070b8dc3e 100644 --- a/tests/end-to-end/ui/11-admin.js +++ b/tests/end-to-end/ui/11-admin.js @@ -739,8 +739,8 @@ describe('[Administration]', () => { 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('the idle timeout limit field value should be 300', () => { + admin.accountsIdleTimeoutLimit.getValue().should.equal('300'); }); it('it should show the notifications durations field', () => {