From c36bc62e49c494709cd9f063beb7f45e8ad08599 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Sat, 9 Jan 2021 01:06:02 -0300 Subject: [PATCH 1/2] [FIX] User registration updating wrong subscriptions (#20128) --- app/lib/server/functions/saveUserIdentity.js | 48 ++++++++++---------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/app/lib/server/functions/saveUserIdentity.js b/app/lib/server/functions/saveUserIdentity.js index a8e0eca2e7d7..929b2fb3c81a 100644 --- a/app/lib/server/functions/saveUserIdentity.js +++ b/app/lib/server/functions/saveUserIdentity.js @@ -38,34 +38,36 @@ export function saveUserIdentity(userId, { _id, name: rawName, username: rawUser } // if coming from old username, update all references - if (previousUsername && usernameChanged && typeof rawUsername !== 'undefined') { - Messages.updateAllUsernamesByUserId(user._id, username); - Messages.updateUsernameOfEditByUserId(user._id, username); - Messages.findByMention(previousUsername).forEach(function(msg) { - const updatedMsg = msg.msg.replace(new RegExp(`@${ previousUsername }`, 'ig'), `@${ username }`); - return Messages.updateUsernameAndMessageOfMentionByIdAndOldUsername(msg._id, previousUsername, username, updatedMsg); - }); - Rooms.replaceUsername(previousUsername, username); - Rooms.replaceMutedUsername(previousUsername, username); - Rooms.replaceUsernameOfUserByUserId(user._id, username); - Subscriptions.setUserUsernameByUserId(user._id, username); + if (previousUsername) { + if (usernameChanged && typeof rawUsername !== 'undefined') { + Messages.updateAllUsernamesByUserId(user._id, username); + Messages.updateUsernameOfEditByUserId(user._id, username); + Messages.findByMention(previousUsername).forEach(function(msg) { + const updatedMsg = msg.msg.replace(new RegExp(`@${ previousUsername }`, 'ig'), `@${ username }`); + return Messages.updateUsernameAndMessageOfMentionByIdAndOldUsername(msg._id, previousUsername, username, updatedMsg); + }); + Rooms.replaceUsername(previousUsername, username); + Rooms.replaceMutedUsername(previousUsername, username); + Rooms.replaceUsernameOfUserByUserId(user._id, username); + Subscriptions.setUserUsernameByUserId(user._id, username); - LivechatDepartmentAgents.replaceUsernameOfAgentByUserId(user._id, username); + LivechatDepartmentAgents.replaceUsernameOfAgentByUserId(user._id, username); - const fileStore = FileUpload.getStore('Avatars'); - const file = fileStore.model.findOneByName(previousUsername); - if (file) { - fileStore.model.updateFileNameById(file._id, username); + const fileStore = FileUpload.getStore('Avatars'); + const file = fileStore.model.findOneByName(previousUsername); + if (file) { + fileStore.model.updateFileNameById(file._id, username); + } } - } - // update other references if either the name or username has changed - if (usernameChanged || nameChanged) { - // update name and fname of 1-on-1 direct messages - Subscriptions.updateDirectNameAndFnameByName(previousUsername, rawUsername && username, rawName && name); + // update other references if either the name or username has changed + if (usernameChanged || nameChanged) { + // update name and fname of 1-on-1 direct messages + Subscriptions.updateDirectNameAndFnameByName(previousUsername, rawUsername && username, rawName && name); - // update name and fname of group direct messages - updateGroupDMsName(user); + // update name and fname of group direct messages + updateGroupDMsName(user); + } } return true; From c95e9fea0d46fd3cdd70586ec4e250862f01f214 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Sat, 9 Jan 2021 01:06:58 -0300 Subject: [PATCH 2/2] Bump version to 3.10.3 --- .docker/Dockerfile.rhel | 2 +- .github/history.json | 20 ++++++++++++++++++++ .snapcraft/resources/prepareRocketChat | 2 +- .snapcraft/snap/snapcraft.yaml | 2 +- HISTORY.md | 18 ++++++++++++++++++ app/utils/rocketchat.info | 2 +- package-lock.json | 2 +- package.json | 2 +- 8 files changed, 44 insertions(+), 6 deletions(-) diff --git a/.docker/Dockerfile.rhel b/.docker/Dockerfile.rhel index 0983d3a37827..993ac5499afa 100644 --- a/.docker/Dockerfile.rhel +++ b/.docker/Dockerfile.rhel @@ -1,6 +1,6 @@ FROM registry.access.redhat.com/ubi8/nodejs-12 -ENV RC_VERSION 3.10.2 +ENV RC_VERSION 3.10.3 MAINTAINER buildmaster@rocket.chat diff --git a/.github/history.json b/.github/history.json index e74847411eb8..3cecdc3b52df 100644 --- a/.github/history.json +++ b/.github/history.json @@ -53903,6 +53903,26 @@ ] } ] + }, + "3.10.3": { + "node_version": "12.18.4", + "npm_version": "6.14.8", + "apps_engine_version": "1.21.0-alpha.4235", + "mongo_versions": [ + "3.4", + "3.6", + "4.0" + ], + "pull_requests": [ + { + "pr": "20128", + "title": "[FIX] User registration updating wrong subscriptions", + "userLogin": "sampaiodiego", + "contributors": [ + "sampaiodiego" + ] + } + ] } } } \ No newline at end of file diff --git a/.snapcraft/resources/prepareRocketChat b/.snapcraft/resources/prepareRocketChat index 1abbf0b44e79..4be1d8d0837c 100755 --- a/.snapcraft/resources/prepareRocketChat +++ b/.snapcraft/resources/prepareRocketChat @@ -1,6 +1,6 @@ #!/bin/bash -curl -SLf "https://releases.rocket.chat/3.10.2/download/" -o rocket.chat.tgz +curl -SLf "https://releases.rocket.chat/3.10.3/download/" -o rocket.chat.tgz tar xf rocket.chat.tgz --strip 1 diff --git a/.snapcraft/snap/snapcraft.yaml b/.snapcraft/snap/snapcraft.yaml index b58a398ece1e..eba4d603428f 100644 --- a/.snapcraft/snap/snapcraft.yaml +++ b/.snapcraft/snap/snapcraft.yaml @@ -7,7 +7,7 @@ # 5. `snapcraft snap` name: rocketchat-server -version: 3.10.2 +version: 3.10.3 summary: Rocket.Chat server description: Have your own Slack like online chat, built with Meteor. https://rocket.chat/ confinement: strict diff --git a/HISTORY.md b/HISTORY.md index a0582c12d0f5..367a50951d98 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,4 +1,22 @@ +# 3.10.3 +`2021-01-09 ยท 1 ๐Ÿ› ยท 1 ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป` + +### Engine versions +- Node: `12.18.4` +- NPM: `6.14.8` +- MongoDB: `3.4, 3.6, 4.0` +- Apps-Engine: `1.21.0-alpha.4235` + +### ๐Ÿ› Bug fixes + + +- User registration updating wrong subscriptions ([#20128](https://github.com/RocketChat/Rocket.Chat/pull/20128)) + +### ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป Core Team ๐Ÿค“ + +- [@sampaiodiego](https://github.com/sampaiodiego) + # 3.10.2 `2021-01-08 ยท 1 ๐Ÿ› ยท 1 ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป` diff --git a/app/utils/rocketchat.info b/app/utils/rocketchat.info index 1396fdae4f61..2a0ac456ddb0 100644 --- a/app/utils/rocketchat.info +++ b/app/utils/rocketchat.info @@ -1,3 +1,3 @@ { - "version": "3.10.2" + "version": "3.10.3" } diff --git a/package-lock.json b/package-lock.json index 8a34b2e361df..819759e9ee95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "Rocket.Chat", - "version": "3.10.2", + "version": "3.10.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index dfb9e8060df5..14c1a594170f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Rocket.Chat", "description": "The Ultimate Open Source WebChat Platform", - "version": "3.10.2", + "version": "3.10.3", "author": { "name": "Rocket.Chat", "url": "https://rocket.chat/"