[FIX] Notification preferences being lost when switching view mode (#11295)

pull/11315/head^2
Diego Sampaio 8 years ago committed by GitHub
parent 40b9fcf729
commit fe4290be1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 65
      package-lock.json
  2. 6
      server/methods/saveUserPreferences.js
  3. 60
      server/startup/migrations/v129.js

65
package-lock.json generated

@ -1,6 +1,6 @@
{
"name": "Rocket.Chat",
"version": "0.66.0-develop",
"version": "0.67.0-develop",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -742,7 +742,7 @@
"autolinker": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/autolinker/-/autolinker-1.6.2.tgz",
"integrity": "sha1-Z66donLoCODY644Cy8jN4wOUdFc="
"integrity": "sha512-IKLGtYFb3jzGTtgCpb4bm//1sXmmmgmr0msKshhYoc7EsWmLCFvuyxLcEIfcZ5gbCgZGXrnXkOkcBblOFEnlog=="
},
"autoprefixer": {
"version": "8.6.0",
@ -2957,7 +2957,7 @@
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"dev": true,
"requires": {
"ms": "2.0.0"
@ -3002,7 +3002,7 @@
"mocha": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-4.1.0.tgz",
"integrity": "sha1-fYbPvPNcuCnidUwy4XNV7AUzh5Q=",
"integrity": "sha512-0RVnjg1HJsXY2YFDoTNzcc1NKhYuXKRrBAG2gDygmJJA136Cs2QlRliZG1mA0ap7cuaT30mw16luAeln+4RiNA==",
"dev": true,
"requires": {
"browser-stdout": "1.3.0",
@ -3020,13 +3020,13 @@
"commander": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
"integrity": "sha1-FXFS/R56bI2YpbcVzzdt+SgARWM=",
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==",
"dev": true
},
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"dev": true,
"requires": {
"fs.realpath": "1.0.0",
@ -3054,7 +3054,7 @@
"supports-color": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz",
"integrity": "sha1-iD992rwWUUKyphQn8zUt7RldGj4=",
"integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==",
"dev": true,
"requires": {
"has-flag": "2.0.0"
@ -4024,6 +4024,14 @@
"integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==",
"dev": true
},
"dbly-linked-list": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/dbly-linked-list/-/dbly-linked-list-0.2.0.tgz",
"integrity": "sha512-Ool7y15f6JRDs0YKx7Dh9uiTb1jS1SZLNdT3Y2q16DlaEghXbMsmODS/XittjR2xztt1gJUpz7jVxpqAPF8VGg==",
"requires": {
"lodash.isequal": "4.5.0"
}
},
"ddp-ejson": {
"version": "0.8.1-3",
"resolved": "https://registry.npmjs.org/ddp-ejson/-/ddp-ejson-0.8.1-3.tgz",
@ -6218,7 +6226,7 @@
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
@ -8178,7 +8186,7 @@
"is-resolvable": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz",
"integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=",
"integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==",
"dev": true
},
"is-retry-allowed": {
@ -8753,6 +8761,11 @@
"resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
"integrity": "sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY="
},
"lodash.isequal": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
"integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA="
},
"lodash.isinteger": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
@ -8776,7 +8789,7 @@
"lodash.merge": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz",
"integrity": "sha1-rcJdnLmbk5HFliTzefu6YNcRHVQ="
"integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ=="
},
"lodash.once": {
"version": "4.1.1",
@ -8944,7 +8957,7 @@
"mailsplit": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/mailsplit/-/mailsplit-4.1.2.tgz",
"integrity": "sha1-xhi8MRpM/IOyJqHtwbUD9akk0IM=",
"integrity": "sha512-5UWjUfhKlC4OR5PqZKcl4h7vnz2EP4M3Zg2SBbrztvAYX5lM/rA7tvaXkZ6zRcvK32Uul0GkRA037icDbiJIOw==",
"requires": {
"libbase64": "1.0.2",
"libmime": "3.1.0",
@ -8954,7 +8967,7 @@
"libbase64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/libbase64/-/libbase64-1.0.2.tgz",
"integrity": "sha1-L/E//mmx5AFZ9JNo4w0N2LsWNbU="
"integrity": "sha512-CyPjvTFbsGps2Sdvy9GVjSRPvUGpji8Hxb+iunp466guzxcd3QaK0k8Hur1sPkgD9FonW8V1z2F1y066YiliEg=="
}
}
},
@ -9195,7 +9208,7 @@
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "1.1.11"
}
@ -9601,7 +9614,7 @@
"npmlog": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
"integrity": "sha1-CKfyqL9zRgR3mp76StXMcXq7lUs=",
"integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==",
"requires": {
"are-we-there-yet": "1.1.5",
"console-control-strings": "1.1.0",
@ -10006,7 +10019,7 @@
"path-type": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz",
"integrity": "sha1-zvMdyOCho7sNEFwM2Xzzv0f0428=",
"integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==",
"requires": {
"pify": "3.0.0"
}
@ -10338,7 +10351,7 @@
"postcss-import": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-11.1.0.tgz",
"integrity": "sha1-Vck2LJGSmU7GiGXSJEGd8dspgfA=",
"integrity": "sha512-5l327iI75POonjxkXgdRCUS+AlzAdBx4pOvMEhTKTCjb1p8IEeVR9yx3cPbmN7LIWJLbfnIXxAhoB4jpD0c/Cw==",
"dev": true,
"requires": {
"postcss": "6.0.22",
@ -10387,7 +10400,7 @@
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"supports-color": {
@ -11275,6 +11288,14 @@
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-1.0.0.tgz",
"integrity": "sha1-YoYkIRLFtxL6ZU5SZlK/ahP/Bcs="
},
"queue-fifo": {
"version": "0.2.5",
"resolved": "https://registry.npmjs.org/queue-fifo/-/queue-fifo-0.2.5.tgz",
"integrity": "sha512-GrHy3RDy0BOEVjelr+htts/QJyZAJr+7m4TisCA+RlUSsegQT6EGOf+NyxLDhSRflFI5vq3aADFOR/tNZCasxg==",
"requires": {
"dbly-linked-list": "0.2.0"
}
},
"quick-lru": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-1.1.0.tgz",
@ -11814,7 +11835,7 @@
"retry-request": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/retry-request/-/retry-request-3.3.1.tgz",
"integrity": "sha1-+3EnYjWmF+l1Uem+c3q1uRWR+54=",
"integrity": "sha512-PjAmtWIxjNj4Co/6FRtBl8afRP3CxrrIAnUzb1dzydfROd+6xt7xAebFeskgQgkfFf8NmzrXIoaB3HxmswXyxw==",
"requires": {
"request": "2.87.0",
"through2": "2.0.3"
@ -13014,7 +13035,7 @@
"stylelint-order": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/stylelint-order/-/stylelint-order-0.8.1.tgz",
"integrity": "sha1-Nfca86FZVBVODpnlZGuj1vvjT40=",
"integrity": "sha512-8mp1P2wnI9XShYXVXDsxVigE2eXnc0C2O4ktbwUvTBwjCP4xZskIbUVxp1evSG3OK4R7hXVNl/2BnJCZkrcc/w==",
"dev": true,
"requires": {
"lodash": "4.17.10",
@ -13062,7 +13083,7 @@
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"supports-color": {
@ -13632,7 +13653,7 @@
"uc.micro": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.5.tgz",
"integrity": "sha1-DGXxX4FaoItWCmHOi023/8P0U3Y="
"integrity": "sha512-JoLI4g5zv5qNyT09f4YAvEZIIV1oOjqnewYg5D38dkQljIzpPT296dbIGvKro3digYI1bkb7W6EP1y4uDlmzLg=="
},
"uglify-js": {
"version": "2.8.29",
@ -14429,7 +14450,7 @@
"xml2js": {
"version": "0.4.19",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz",
"integrity": "sha1-aGwg8hMgnpSr8NG88e+qKRx4J6c=",
"integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==",
"requires": {
"sax": "1.2.1",
"xmlbuilder": "9.0.7"

@ -69,7 +69,7 @@ Meteor.methods({
// propagate changed notification preferences
Meteor.defer(() => {
if (oldDesktopNotifications !== settings.desktopNotifications) {
if (settings.desktopNotifications && oldDesktopNotifications !== settings.desktopNotifications) {
if (settings.desktopNotifications === 'default') {
RocketChat.models.Subscriptions.clearDesktopNotificationUserPreferences(user._id);
} else {
@ -77,7 +77,7 @@ Meteor.methods({
}
}
if (oldMobileNotifications !== settings.mobileNotifications) {
if (settings.mobileNotifications && oldMobileNotifications !== settings.mobileNotifications) {
if (settings.mobileNotifications === 'default') {
RocketChat.models.Subscriptions.clearMobileNotificationUserPreferences(user._id);
} else {
@ -85,7 +85,7 @@ Meteor.methods({
}
}
if (oldEmailNotifications !== settings.emailNotificationMode) {
if (settings.emailNotificationMode && oldEmailNotifications !== settings.emailNotificationMode) {
if (settings.emailNotificationMode === 'default') {
RocketChat.models.Subscriptions.clearEmailNotificationUserPreferences(user._id);
} else {

@ -0,0 +1,60 @@
RocketChat.Migrations.add({
version: 129,
up() {
RocketChat.models.Users.find({
$or: [
{ 'settings.preferences.desktopNotifications': { $exists: true, $ne: 'default' } },
{ 'settings.preferences.mobileNotifications': { $exists: true, $ne: 'default' } },
{ 'settings.preferences.emailNotificationMode': { $exists: true, $ne: 'default' } }
]
}, {
fields: {
'settings.preferences.desktopNotifications': 1,
'settings.preferences.mobileNotifications': 1,
'settings.preferences.emailNotificationMode': 1
}
}).forEach(user => {
if (user.settings.preferences.desktopNotifications && user.settings.preferences.desktopNotifications !== 'default') {
RocketChat.models.Subscriptions.update({
'u._id': user._id,
desktopPrefOrigin: 'user',
desktopNotifications: null
}, {
$set: {
desktopNotifications: user.settings.preferences.desktopNotifications
}
}, {
multi: true
});
}
if (user.settings.preferences.mobileNotifications && user.settings.preferences.mobileNotifications !== 'default') {
RocketChat.models.Subscriptions.update({
'u._id': user._id,
mobilePrefOrigin: 'user',
mobilePushNotifications: null
}, {
$set: {
mobilePushNotifications: user.settings.preferences.mobileNotifications
}
}, {
multi: true
});
}
if (user.settings.preferences.emailNotificationMode && user.settings.preferences.emailNotificationMode !== 'default') {
RocketChat.models.Subscriptions.update({
'u._id': user._id,
emailPrefOrigin: 'user',
emailNotifications: null
}, {
$set: {
emailNotifications: user.settings.preferences.emailNotificationMode === 'disabled' || user.settings.preferences.emailNotificationMode === 'nothing' ? 'nothing' : 'mentions'
}
}, {
multi: true
});
}
});
}
});
Loading…
Cancel
Save