From 09b82f4f3315466147b2cb0b158a7e0bd2cd9821 Mon Sep 17 00:00:00 2001 From: pierre-lehnen-rc <55164754+pierre-lehnen-rc@users.noreply.github.com> Date: Mon, 20 Apr 2020 09:04:19 -0300 Subject: [PATCH 01/11] [FIX] New user added by admin doesn't receive random password email (#17249) --- app/lib/server/functions/saveUser.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/lib/server/functions/saveUser.js b/app/lib/server/functions/saveUser.js index 6f365454eb88..dae0e6896d82 100644 --- a/app/lib/server/functions/saveUser.js +++ b/app/lib/server/functions/saveUser.js @@ -263,6 +263,10 @@ export const saveUser = function(userId, userData) { _sendUserEmail(settings.get('Accounts_UserAddedEmail_Subject'), html, userData); } + if (sendPassword) { + _sendUserEmail(settings.get('Password_Changed_Email_Subject'), passwordChangedHtml, userData); + } + userData._id = _id; if (settings.get('Accounts_SetDefaultAvatar') === true && userData.email) { From b2735d324f44138a867e409800cc88e49670ecf0 Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Mon, 20 Apr 2020 09:33:57 -0300 Subject: [PATCH 02/11] [FIX] Omnichannel room info panel opening whenever a message is sent (#17348) --- .../client/hooks/onCreateRoomTabBar.js | 29 +++++++++++++++++++ app/livechat/client/hooks/onRenderRoom.js | 25 ---------------- app/livechat/client/index.js | 2 +- app/ui/client/views/app/room.js | 6 ++-- 4 files changed, 34 insertions(+), 28 deletions(-) create mode 100644 app/livechat/client/hooks/onCreateRoomTabBar.js delete mode 100644 app/livechat/client/hooks/onRenderRoom.js diff --git a/app/livechat/client/hooks/onCreateRoomTabBar.js b/app/livechat/client/hooks/onCreateRoomTabBar.js new file mode 100644 index 000000000000..011122ef0d80 --- /dev/null +++ b/app/livechat/client/hooks/onCreateRoomTabBar.js @@ -0,0 +1,29 @@ +import { callbacks } from '../../../callbacks'; + +callbacks.add('onCreateRoomTabBar', (info) => { + const { tabBar, room } = info; + + if (!tabBar) { + return info; + } + + if (!room || !room.t || room.t !== 'l') { + return info; + } + + const button = tabBar.getButtons().find((button) => button.id === 'visitor-info'); + if (!button) { + return info; + } + + const { template, i18nTitle: label, icon } = button; + tabBar.setTemplate(template); + tabBar.setData({ + label, + icon, + }); + + tabBar.open(); + + return info; +}); diff --git a/app/livechat/client/hooks/onRenderRoom.js b/app/livechat/client/hooks/onRenderRoom.js deleted file mode 100644 index 459640953155..000000000000 --- a/app/livechat/client/hooks/onRenderRoom.js +++ /dev/null @@ -1,25 +0,0 @@ -import { callbacks } from '../../../callbacks'; - -callbacks.add('onRenderRoom', (instance, room) => { - if (!instance || !instance.tabBar) { - return; - } - - if (!room || !room.t || room.t !== 'l') { - return; - } - - const button = instance.tabBar.getButtons().find((button) => button.id === 'visitor-info'); - if (!button) { - return; - } - - const { template, i18nTitle: label, icon } = button; - instance.tabBar.setTemplate(template); - instance.tabBar.setData({ - label, - icon, - }); - - instance.tabBar.open(); -}); diff --git a/app/livechat/client/index.js b/app/livechat/client/index.js index a482ce7e293e..67a33ffb10eb 100644 --- a/app/livechat/client/index.js +++ b/app/livechat/client/index.js @@ -2,7 +2,7 @@ import '../lib/messageTypes'; import './roomType'; import './route'; import './ui'; -import './hooks/onRenderRoom'; +import './hooks/onCreateRoomTabBar'; import './startup/notifyUnreadRooms'; import './views/sideNav/livechat'; import './views/sideNav/livechatFlex'; diff --git a/app/ui/client/views/app/room.js b/app/ui/client/views/app/room.js index 8ea44dd8d5d1..d712249b34f0 100644 --- a/app/ui/client/views/app/room.js +++ b/app/ui/client/views/app/room.js @@ -1072,6 +1072,10 @@ Template.room.onCreated(function() { this.tabBar = new RocketChatTabBar(); this.tabBar.showGroup(FlowRouter.current().route.name); + callbacks.run('onCreateRoomTabBar', { + tabBar: this.tabBar, + room: Rooms.findOne(rid, { fields: { t: 1 } }), + }); this.hideLeaderHeader = new ReactiveVar(false); @@ -1378,8 +1382,6 @@ Template.room.onRendered(function() { if (!room) { return FlowRouter.go('home'); } - - callbacks.run('onRenderRoom', template, room); }); const observer = new ResizeObserver(template.sendToBottomIfNecessary); From d917c920e3a141ec2d32f8ce1eec121b3f4264cb Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Mon, 20 Apr 2020 09:38:45 -0300 Subject: [PATCH 03/11] [FIX] Web Client memory leak caused by the Emoji library (#17320) --- .../server/functions/hasPermission.js | 2 +- app/emoji-emojione/lib/rocketchat.js | 9 ++-- package-lock.json | 45 ++++++++++++++----- package.json | 2 +- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/app/authorization/server/functions/hasPermission.js b/app/authorization/server/functions/hasPermission.js index 7077e0220c9e..141b16008b99 100644 --- a/app/authorization/server/functions/hasPermission.js +++ b/app/authorization/server/functions/hasPermission.js @@ -5,7 +5,7 @@ import { Permissions, Users, Subscriptions } from '../../../models/server/raw'; const rolesHasPermission = mem(async (permission, roles) => { const result = await Permissions.findOne({ _id: permission, roles: { $in: roles } }); return !!result; -}); +}, process.env.TEST_MODE === 'true' ? { maxAge: 0 } : undefined); const getRoles = mem(async (uid, scope) => { const { roles: userRoles = [] } = await Users.findOne({ _id: uid }); diff --git a/app/emoji-emojione/lib/rocketchat.js b/app/emoji-emojione/lib/rocketchat.js index b9e9aafb33b3..8632dcdd4fd3 100644 --- a/app/emoji-emojione/lib/rocketchat.js +++ b/app/emoji-emojione/lib/rocketchat.js @@ -167,8 +167,9 @@ emojione.emojioneList[':asterisk_symbol:'] = { // fix for :+1: - had to replace all function that does its conversion: https://github.com/joypixels/emojione/blob/4.5.0/lib/js/emojione.js#L249 (function(ns) { - ns.shortnameConversionMap = mem(ns.shortnameConversionMap); - ns.unicodeCharRegex = mem(ns.unicodeCharRegex); + ns.shortnameConversionMap = mem(ns.shortnameConversionMap, { maxAge: 1000 }); + + ns.unicodeCharRegex = mem(ns.unicodeCharRegex, { maxAge: 1000 }); const convertShortName = mem(function(shortname) { // the fix is basically adding this .replace(/[+]/g, '\\$&') @@ -202,7 +203,7 @@ emojione.emojioneList[':asterisk_symbol:'] = { return `${ alt }`; } return `${ alt }`; - }); + }, { maxAge: 1000 }); const convertUnicode = mem(function(entire, m1, m2, m3) { const mappedUnicode = ns.mapUnicodeToShort(); @@ -228,7 +229,7 @@ emojione.emojioneList[':asterisk_symbol:'] = { return `${ m2 }${ alt }`; } return `${ m2 }${ alt }`; - }); + }, { maxAge: 1000 }); ns.shortnameToImage = function(str) { // replace regular shortnames first diff --git a/package-lock.json b/package-lock.json index de56102c8bf1..b8e5000e0022 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3032,6 +3032,23 @@ "pseudomap": "^1.0.2", "yallist": "^2.1.2" } + }, + "mem": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", + "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", + "dev": true, + "requires": { + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^2.0.0", + "p-is-promise": "^2.0.0" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true } } }, @@ -20595,13 +20612,19 @@ "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" }, "mem": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-4.1.0.tgz", - "integrity": "sha512-I5u6Q1x7wxO0kdOpYBB28xueHADYps5uty/zg936CiG8NTe5sJL8EjrCuLneuDW3PlMdZBGDIn8BirEVdovZvg==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-6.1.0.tgz", + "integrity": "sha512-RlbnLQgRHk5lwqTtpEkBTQ2ll/CG/iB+J4Hy2Wh97PjgZgXgWJWrFF+XXujh3UUVLvR4OOTgZzcWMMwnehlEUg==", "requires": { - "map-age-cleaner": "^0.1.1", - "mimic-fn": "^1.0.0", - "p-is-promise": "^2.0.0" + "map-age-cleaner": "^0.1.3", + "mimic-fn": "^3.0.0" + }, + "dependencies": { + "mimic-fn": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-3.0.0.tgz", + "integrity": "sha512-PiVO95TKvhiwgSwg1IdLYlCTdul38yZxZMIcnDSFIBUm4BNZha2qpQ4GpJ++15bHoKDtrW2D69lMfFwdFYtNZQ==" + } } }, "memoize-one": { @@ -21635,7 +21658,8 @@ "mimic-fn": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true }, "mimic-response": { "version": "1.0.1", @@ -23205,9 +23229,10 @@ "dev": true }, "p-is-promise": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.0.0.tgz", - "integrity": "sha512-pzQPhYMCAgLAKPWD2jC3Se9fEfrD9npNos0y150EeqZll7akhEgGhTW/slB6lHku8AvYGiJ+YJ5hfHKePPgFWg==" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", + "dev": true }, "p-limit": { "version": "2.0.0", diff --git a/package.json b/package.json index 508a8cd18525..a7ea843f53be 100644 --- a/package.json +++ b/package.json @@ -193,7 +193,7 @@ "lru-cache": "^5.1.1", "mailparser": "^2.4.3", "marked": "^0.6.1", - "mem": "4.1.0", + "mem": "^6.1.0", "meteor-node-stubs": "^1.0.0", "mime-db": "^1.40.0", "mime-type": "^3.0.7", From 646ccd92bb2048400e084d6dfd5dc348b7e6d204 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Wed, 22 Apr 2020 22:25:19 -0300 Subject: [PATCH 04/11] Regression: Fix mem usage with more than one argument (#17391) --- app/authorization/server/functions/hasPermission.js | 13 ++++++++----- app/models/client/models/Subscriptions.js | 4 ++-- app/ui-utils/client/lib/MessageAction.js | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/authorization/server/functions/hasPermission.js b/app/authorization/server/functions/hasPermission.js index 141b16008b99..6f5382496a22 100644 --- a/app/authorization/server/functions/hasPermission.js +++ b/app/authorization/server/functions/hasPermission.js @@ -3,15 +3,18 @@ import mem from 'mem'; import { Permissions, Users, Subscriptions } from '../../../models/server/raw'; const rolesHasPermission = mem(async (permission, roles) => { - const result = await Permissions.findOne({ _id: permission, roles: { $in: roles } }); + const result = await Permissions.findOne({ _id: permission, roles: { $in: roles } }, { projection: { _id: 1 } }); return !!result; -}, process.env.TEST_MODE === 'true' ? { maxAge: 0 } : undefined); +}, { + cacheKey: JSON.stringify, + ...process.env.TEST_MODE === 'true' && { maxAge: 0 }, +}); const getRoles = mem(async (uid, scope) => { - const { roles: userRoles = [] } = await Users.findOne({ _id: uid }); - const { roles: subscriptionsRoles = [] } = (scope && await Subscriptions.findOne({ rid: scope, 'u._id': uid }, { fields: { roles: 1 } })) || {}; + const { roles: userRoles = [] } = await Users.findOne({ _id: uid }, { projection: { roles: 1 } }); + const { roles: subscriptionsRoles = [] } = (scope && await Subscriptions.findOne({ rid: scope, 'u._id': uid }, { projection: { roles: 1 } })) || {}; return [...userRoles, ...subscriptionsRoles].sort((a, b) => a.localeCompare(b)); -}, { maxAge: 1000 }); +}, { maxAge: 1000, cacheKey: JSON.stringify }); export const clearCache = () => { mem.clear(getRoles); diff --git a/app/models/client/models/Subscriptions.js b/app/models/client/models/Subscriptions.js index 06e7effb6033..3564231773fd 100644 --- a/app/models/client/models/Subscriptions.js +++ b/app/models/client/models/Subscriptions.js @@ -19,7 +19,7 @@ Object.assign(Subscriptions, { const subscription = this.findOne(query, { fields: { roles: 1 } }); return subscription && Array.isArray(subscription.roles) && subscription.roles.includes(roleName); - }, { maxAge: 1000 }), + }, { maxAge: 1000, cacheKey: JSON.stringify }), findUsersInRoles: mem(function(roles, scope, options) { roles = [].concat(roles); @@ -41,7 +41,7 @@ Object.assign(Subscriptions, { })); return Users.find({ _id: { $in: users } }, options); - }, { maxAge: 1000 }), + }, { maxAge: 1000, cacheKey: JSON.stringify }), }); export { Subscriptions }; diff --git a/app/ui-utils/client/lib/MessageAction.js b/app/ui-utils/client/lib/MessageAction.js index 0aa6c7ed8d3b..98fa85880cf8 100644 --- a/app/ui-utils/client/lib/MessageAction.js +++ b/app/ui-utils/client/lib/MessageAction.js @@ -59,7 +59,7 @@ export const MessageAction = new class { } if (config.condition) { - config.condition = mem(config.condition, { maxAge: 1000 }); + config.condition = mem(config.condition, { maxAge: 1000, cacheKey: JSON.stringify }); } return Tracker.nonreactive(() => { From c9c137e58899bea6433ccf5159f0c5686e1ac536 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Thu, 23 Apr 2020 23:23:41 -0300 Subject: [PATCH 05/11] [FIX] Allowing blocking a user on channels (#17406) --- app/authorization/server/functions/canSendMessage.js | 9 ++++++--- app/lib/lib/roomTypes/private.js | 11 ++++++++--- app/lib/lib/roomTypes/public.js | 11 ++++++++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/authorization/server/functions/canSendMessage.js b/app/authorization/server/functions/canSendMessage.js index c303154e16b6..10f1a33c7281 100644 --- a/app/authorization/server/functions/canSendMessage.js +++ b/app/authorization/server/functions/canSendMessage.js @@ -1,6 +1,7 @@ import { canAccessRoomAsync } from './canAccessRoom'; import { hasPermissionAsync } from './hasPermission'; import { Subscriptions, Rooms } from '../../../models/server/raw'; +import { roomTypes, RoomMemberActions } from '../../../utils/server'; const subscriptionOptions = { projection: { @@ -16,9 +17,11 @@ export const canSendMessageAsync = async (rid, { uid, username, type }, extraDat throw new Error('error-not-allowed'); } - const subscription = await Subscriptions.findOneByRoomIdAndUserId(rid, uid, subscriptionOptions); - if (subscription && (subscription.blocked || subscription.blocker)) { - throw new Error('room_is_blocked'); + if (roomTypes.getConfig(room.t).allowMemberAction(room, RoomMemberActions.BLOCK)) { + const subscription = await Subscriptions.findOneByRoomIdAndUserId(rid, uid, subscriptionOptions); + if (subscription && (subscription.blocked || subscription.blocker)) { + throw new Error('room_is_blocked'); + } } if (room.ro === true && !await hasPermissionAsync(uid, 'post-readonly', rid)) { diff --git a/app/lib/lib/roomTypes/private.js b/app/lib/lib/roomTypes/private.js index 219ebbc8e9dd..54f669d3c096 100644 --- a/app/lib/lib/roomTypes/private.js +++ b/app/lib/lib/roomTypes/private.js @@ -4,7 +4,7 @@ import { ChatRoom, ChatSubscription } from '../../../models'; import { openRoom } from '../../../ui-utils'; import { settings } from '../../../settings'; import { hasAtLeastOnePermission, hasPermission } from '../../../authorization'; -import { getUserPreference, RoomSettingsEnum, RoomTypeConfig, RoomTypeRouteConfig, UiTextContext, roomTypes } from '../../../utils'; +import { getUserPreference, RoomSettingsEnum, RoomTypeConfig, RoomTypeRouteConfig, UiTextContext, roomTypes, RoomMemberActions } from '../../../utils'; import { getRoomAvatarURL } from '../../../utils/lib/getRoomAvatarURL'; import { getAvatarURL } from '../../../utils/lib/getAvatarURL'; @@ -98,8 +98,13 @@ export class PrivateRoomType extends RoomTypeConfig { } } - allowMemberAction(/* room, action */) { - return true; + allowMemberAction(room, action) { + switch (action) { + case RoomMemberActions.BLOCK: + return false; + default: + return true; + } } enableMembersListProfile() { diff --git a/app/lib/lib/roomTypes/public.js b/app/lib/lib/roomTypes/public.js index 8732e6d13d9c..70b2dc3fd41a 100644 --- a/app/lib/lib/roomTypes/public.js +++ b/app/lib/lib/roomTypes/public.js @@ -4,7 +4,7 @@ import { openRoom } from '../../../ui-utils'; import { ChatRoom, ChatSubscription } from '../../../models'; import { settings } from '../../../settings'; import { hasAtLeastOnePermission } from '../../../authorization'; -import { getUserPreference, RoomTypeConfig, RoomTypeRouteConfig, RoomSettingsEnum, UiTextContext } from '../../../utils'; +import { getUserPreference, RoomTypeConfig, RoomTypeRouteConfig, RoomSettingsEnum, UiTextContext, RoomMemberActions } from '../../../utils'; import { getAvatarURL } from '../../../utils/lib/getAvatarURL'; export class PublicRoomRoute extends RoomTypeRouteConfig { @@ -113,8 +113,13 @@ export class PublicRoomType extends RoomTypeConfig { } } - allowMemberAction(/* room, action */) { - return true; + allowMemberAction(room, action) { + switch (action) { + case RoomMemberActions.BLOCK: + return false; + default: + return true; + } } getUiText(context) { From 0cf1d4871d00bd084d929bc05e6275699ee2cc33 Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Fri, 24 Apr 2020 14:48:17 -0300 Subject: [PATCH 06/11] [FIX] Bot Agents not being able to get Omnichannel Inquiries (#17404) --- app/livechat/server/lib/Helper.js | 12 ++++++++++++ app/livechat/server/methods/takeInquiry.js | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/livechat/server/lib/Helper.js b/app/livechat/server/lib/Helper.js index a29b47eade1e..c44e50ca9ab4 100644 --- a/app/livechat/server/lib/Helper.js +++ b/app/livechat/server/lib/Helper.js @@ -296,3 +296,15 @@ export const checkServiceStatus = ({ guest, agent }) => { return Livechat.online(guest.department); }; + +export const userCanTakeInquiry = (user) => { + check(user, Match.ObjectIncluding({ + status: String, + statusLivechat: String, + roles: [String], + })); + + const { roles, status, statusLivechat } = user; + // TODO: hasRole when the user has already been fetched from DB + return (status !== 'offline' && statusLivechat === 'available') || roles.includes('bot'); +}; diff --git a/app/livechat/server/methods/takeInquiry.js b/app/livechat/server/methods/takeInquiry.js index e6a557eee011..abb006593ef8 100644 --- a/app/livechat/server/methods/takeInquiry.js +++ b/app/livechat/server/methods/takeInquiry.js @@ -3,6 +3,7 @@ import { Meteor } from 'meteor/meteor'; import { hasPermission } from '../../../authorization'; import { Users, LivechatInquiry } from '../../../models/server'; import { RoutingManager } from '../lib/RoutingManager'; +import { userCanTakeInquiry } from '../lib/Helper'; Meteor.methods({ 'livechat:takeInquiry'(inquiryId) { @@ -16,10 +17,9 @@ Meteor.methods({ throw new Meteor.Error('error-not-allowed', 'Inquiry already taken', { method: 'livechat:takeInquiry' }); } - const user = Users.findOneById(Meteor.userId()); - const { status, statusLivechat } = user; - if (status === 'offline' || statusLivechat !== 'available') { - throw new Meteor.Error('error-agent-offline', 'Agent offline', { method: 'livechat:takeInquiry' }); + const user = Users.findOneById(Meteor.userId(), { fields: { _id: 1, username: 1, roles: 1, status: 1, statusLivechat: 1 } }); + if (!userCanTakeInquiry(user)) { + throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'livechat:takeInquiry' }); } const agent = { From 9bd843039a1a3a590a55b7f04b82daa8b337ccf7 Mon Sep 17 00:00:00 2001 From: Fabian Strachanski Date: Fri, 24 Apr 2020 23:06:12 +0200 Subject: [PATCH 07/11] [FIX] LDAP Sync error (#17417) --- app/ldap/server/loginHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ldap/server/loginHandler.js b/app/ldap/server/loginHandler.js index f4c3901c16ca..a0c0f893e8cf 100644 --- a/app/ldap/server/loginHandler.js +++ b/app/ldap/server/loginHandler.js @@ -143,7 +143,7 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) { } // Create new user - const result = addLdapUser(ldapUser, username, loginRequest.ldapPass); + const result = addLdapUser(ldapUser, username, loginRequest.ldapPass, ldap); if (result instanceof Error) { throw result; From e4ef21cac515f8347f97cb410f429fdd2bc6d605 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Fri, 24 Apr 2020 18:06:57 -0300 Subject: [PATCH 08/11] [FIX] Empty Incoming webhook script field (#17422) --- app/ui/client/lib/codeMirror/codeMirrorComponent.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/ui/client/lib/codeMirror/codeMirrorComponent.js b/app/ui/client/lib/codeMirror/codeMirrorComponent.js index 42d5c9c50f38..3c728deb9826 100644 --- a/app/ui/client/lib/codeMirror/codeMirrorComponent.js +++ b/app/ui/client/lib/codeMirror/codeMirrorComponent.js @@ -16,6 +16,15 @@ Template.CodeMirror.onRendered(async function() { const textarea = this.find('textarea'); const editor = CodeMirror.fromTextArea(textarea, options); + this.autorun((c) => { + const { code } = Template.currentData(); + if (code === undefined) { + return; + } + c.stop(); + editor.setValue(code); + }); + CodeMirrors[this.data.id || 'code-mirror-textarea'] = editor; if (this.data && this.data.editorOnBlur) { this.data.editorOnBlur(this.data.name); From a76b37d561b6ef4f3b2a68e7453250c64ae158c1 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 27 Apr 2020 11:06:28 -0300 Subject: [PATCH 09/11] Regression: Add missing cacheKey to mem (#17430) --- app/emoji-emojione/lib/rocketchat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/emoji-emojione/lib/rocketchat.js b/app/emoji-emojione/lib/rocketchat.js index 8632dcdd4fd3..9c5ee3412a92 100644 --- a/app/emoji-emojione/lib/rocketchat.js +++ b/app/emoji-emojione/lib/rocketchat.js @@ -229,7 +229,7 @@ emojione.emojioneList[':asterisk_symbol:'] = { return `${ m2 }${ alt }`; } return `${ m2 }${ alt }`; - }, { maxAge: 1000 }); + }, { maxAge: 1000, cacheKey: JSON.stringify }); ns.shortnameToImage = function(str) { // replace regular shortnames first From 97117f73daa2e5c026813db86659da58ce825b15 Mon Sep 17 00:00:00 2001 From: pierre-lehnen-rc <55164754+pierre-lehnen-rc@users.noreply.github.com> Date: Mon, 27 Apr 2020 16:46:46 -0300 Subject: [PATCH 10/11] [FIX] LDAP error when trying to add room with spaces in the name (#17453) --- app/ldap/server/sync.js | 2 +- app/models/server/models/Rooms.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/ldap/server/sync.js b/app/ldap/server/sync.js index 9778bad9a3dc..dd9a359c4715 100644 --- a/app/ldap/server/sync.js +++ b/app/ldap/server/sync.js @@ -317,7 +317,7 @@ export function mapLDAPGroupsToChannels(ldap, ldapUser, user) { } for (const channel of channels) { - let room = Rooms.findOneByName(channel); + let room = Rooms.findOneByNonValidatedName(channel); if (!room) { room = createRoomForSync(channel); } diff --git a/app/models/server/models/Rooms.js b/app/models/server/models/Rooms.js index d7a244e68008..cc8eb72e751a 100644 --- a/app/models/server/models/Rooms.js +++ b/app/models/server/models/Rooms.js @@ -4,6 +4,7 @@ import s from 'underscore.string'; import { Base } from './_Base'; import Messages from './Messages'; import Subscriptions from './Subscriptions'; +import { getValidRoomName } from '../../../utils'; export class Rooms extends Base { constructor(...args) { @@ -255,6 +256,22 @@ export class Rooms extends Base { return this.findOne(query, options); } + findOneByNonValidatedName(name, options) { + const room = this.findOneByName(name, options); + if (room) { + return room; + } + + let channelName = s.trim(name); + try { + channelName = getValidRoomName(channelName, null, { allowDuplicates: true }); + } catch (e) { + console.error(e); + } + + return this.findOneByName(channelName, options); + } + findOneByName(name, options) { const query = { name }; From 4c38b6432bced8d94911f6ebd3487f2b99a2f41d Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 27 Apr 2020 17:03:32 -0300 Subject: [PATCH 11/11] Bump version to 3.1.2 --- .docker/Dockerfile.rhel | 2 +- .github/history.json | 95 +++++++++++++++++++++++++++++++++++++++ HISTORY.md | 73 ++++++++++++++++++++++++------ app/utils/rocketchat.info | 2 +- package.json | 2 +- 5 files changed, 157 insertions(+), 17 deletions(-) diff --git a/.docker/Dockerfile.rhel b/.docker/Dockerfile.rhel index 87cd8371574b..9369e091a32b 100644 --- a/.docker/Dockerfile.rhel +++ b/.docker/Dockerfile.rhel @@ -1,6 +1,6 @@ FROM registry.access.redhat.com/rhscl/nodejs-8-rhel7 -ENV RC_VERSION 3.1.1 +ENV RC_VERSION 3.1.2 MAINTAINER buildmaster@rocket.chat diff --git a/.github/history.json b/.github/history.json index 0a3e4abf62ba..f93ed35ca2ef 100644 --- a/.github/history.json +++ b/.github/history.json @@ -42492,6 +42492,101 @@ ] } ] + }, + "3.1.2": { + "pull_requests": [ + { + "pr": "17453", + "title": "[FIX] LDAP error when trying to add room with spaces in the name", + "userLogin": "pierre-lehnen-rc", + "milestone": "3.1.2", + "contributors": [ + "pierre-lehnen-rc" + ] + }, + { + "pr": "17430", + "title": "Regression: Add missing cacheKey to mem", + "userLogin": "sampaiodiego", + "milestone": "3.1.2", + "contributors": [ + "sampaiodiego" + ] + }, + { + "pr": "17422", + "title": "[FIX] Empty Incoming webhook script field ", + "userLogin": "ggazzo", + "milestone": "3.1.2", + "contributors": [ + "ggazzo" + ] + }, + { + "pr": "17417", + "title": "[FIX] LDAP Sync error", + "userLogin": "fastrde", + "milestone": "3.1.2", + "contributors": [ + "fastrde" + ] + }, + { + "pr": "17404", + "title": "[FIX] Bot Agents not being able to get Omnichannel Inquiries", + "userLogin": "renatobecker", + "milestone": "3.1.2", + "contributors": [ + "renatobecker" + ] + }, + { + "pr": "17406", + "title": "[FIX] Allowing blocking a user on channels", + "userLogin": "sampaiodiego", + "milestone": "3.1.2", + "contributors": [ + "sampaiodiego" + ] + }, + { + "pr": "17391", + "title": "Regression: Fix mem usage with more than one argument", + "userLogin": "sampaiodiego", + "milestone": "3.1.2", + "contributors": [ + "sampaiodiego" + ] + }, + { + "pr": "17320", + "title": "[FIX] Web Client memory leak caused by the Emoji rendering", + "userLogin": "ggazzo", + "milestone": "3.1.2", + "contributors": [ + "ggazzo", + "web-flow" + ] + }, + { + "pr": "17348", + "title": "[FIX] Omnichannel room info panel opening whenever a message is sent", + "userLogin": "renatobecker", + "milestone": "3.1.2", + "contributors": [ + "renatobecker" + ] + }, + { + "pr": "17249", + "title": "[FIX] New user added by admin doesn't receive random password email", + "userLogin": "pierre-lehnen-rc", + "milestone": "3.1.2", + "contributors": [ + "pierre-lehnen-rc" + ] + } + ] } } } \ No newline at end of file diff --git a/HISTORY.md b/HISTORY.md index 16782fa4ff99..9197d657fe1f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,4 +1,47 @@ +# 3.1.2 +`2020-04-27 ยท 8 ๐Ÿ› ยท 2 ๐Ÿ” ยท 5 ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป` + +### ๐Ÿ› Bug fixes + + +- LDAP error when trying to add room with spaces in the name ([#17453](https://github.com/RocketChat/Rocket.Chat/pull/17453)) + +- Empty Incoming webhook script field ([#17422](https://github.com/RocketChat/Rocket.Chat/pull/17422)) + +- LDAP Sync error ([#17417](https://github.com/RocketChat/Rocket.Chat/pull/17417) by [@fastrde](https://github.com/fastrde)) + +- Bot Agents not being able to get Omnichannel Inquiries ([#17404](https://github.com/RocketChat/Rocket.Chat/pull/17404)) + +- Allowing blocking a user on channels ([#17406](https://github.com/RocketChat/Rocket.Chat/pull/17406)) + +- Web Client memory leak caused by the Emoji rendering ([#17320](https://github.com/RocketChat/Rocket.Chat/pull/17320)) + +- Omnichannel room info panel opening whenever a message is sent ([#17348](https://github.com/RocketChat/Rocket.Chat/pull/17348)) + +- New user added by admin doesn't receive random password email ([#17249](https://github.com/RocketChat/Rocket.Chat/pull/17249)) + +
+๐Ÿ” Minor changes + + +- Regression: Add missing cacheKey to mem ([#17430](https://github.com/RocketChat/Rocket.Chat/pull/17430)) + +- Regression: Fix mem usage with more than one argument ([#17391](https://github.com/RocketChat/Rocket.Chat/pull/17391)) + +
+ +### ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป Contributors ๐Ÿ˜ + +- [@fastrde](https://github.com/fastrde) + +### ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป Core Team ๐Ÿค“ + +- [@ggazzo](https://github.com/ggazzo) +- [@pierre-lehnen-rc](https://github.com/pierre-lehnen-rc) +- [@renatobecker](https://github.com/renatobecker) +- [@sampaiodiego](https://github.com/sampaiodiego) + # 3.1.1 `2020-04-14 ยท 8 ๐Ÿ› ยท 1 ๐Ÿ” ยท 6 ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป` @@ -54,12 +97,12 @@ ### ๐ŸŽ‰ New features +- **ENTERPRISE:** Engagement Dashboard ([#16960](https://github.com/RocketChat/Rocket.Chat/pull/16960)) + - Sort channel directory listing by latest message ([#16604](https://github.com/RocketChat/Rocket.Chat/pull/16604) by [@subham103](https://github.com/subham103)) - Direct message between multiple users ([#16761](https://github.com/RocketChat/Rocket.Chat/pull/16761)) -- [ENTERPRISE] Engagement Dashboard ([#16960](https://github.com/RocketChat/Rocket.Chat/pull/16960)) - - Synchronize saml roles to local user (#16152) ([#16158](https://github.com/RocketChat/Rocket.Chat/pull/16158) by [@col-panic](https://github.com/col-panic)) - Route to get updated roles after a date ([#16610](https://github.com/RocketChat/Rocket.Chat/pull/16610) by [@ashwaniYDV](https://github.com/ashwaniYDV)) @@ -77,6 +120,7 @@ - Two Factor authentication via email ([#15949](https://github.com/RocketChat/Rocket.Chat/pull/15949)) - Translation via MS translate ([#16363](https://github.com/RocketChat/Rocket.Chat/pull/16363) by [@mrsimpson](https://github.com/mrsimpson)) + Adds Microsoft's translation service (https://translator.microsoft.com/) as a provider for translation of messages. In addition to implementing the interface (similar to google and DeepL), a small change has been done in order to display the translation provider on the UI. @@ -99,6 +143,7 @@ - Directory page refactored, new user's bio field ([#17043](https://github.com/RocketChat/Rocket.Chat/pull/17043)) - Merge Sort List and View Mode menus and improve its UI/UX ([#17103](https://github.com/RocketChat/Rocket.Chat/pull/17103)) + ![image](https://user-images.githubusercontent.com/5263975/78036622-e8db2a80-7340-11ea-91d0-65728eabdcb6.png) - Add omnichannel external frame feature ([#17038](https://github.com/RocketChat/Rocket.Chat/pull/17038)) @@ -216,6 +261,7 @@ - Slackbridge-import command doesn't work ([#16645](https://github.com/RocketChat/Rocket.Chat/pull/16645) by [@antkaz](https://github.com/antkaz)) - Language country has been ignored on translation load ([#16757](https://github.com/RocketChat/Rocket.Chat/pull/16757)) + Languages including country variations like `pt-BR` were ignoring the country party because the user's preference has been saved in lowercase `pt-br` causing the language to not match the available languages. Now we enforce the uppercase of the country part when loading the language. - Cannot edit Profile when Full Name is empty and not required ([#16744](https://github.com/RocketChat/Rocket.Chat/pull/16744)) @@ -1619,7 +1665,6 @@ ### Engine versions - Node: `8.15.1` - NPM: `6.9.0` -- MongoDB: `` ### ๐Ÿ› Bug fixes @@ -6211,9 +6256,9 @@ ### โš ๏ธ BREAKING CHANGES -- Update the default port of the Prometheus exporter ([#11351](https://github.com/RocketChat/Rocket.Chat/pull/11351) by [@thaiphv](https://github.com/thaiphv)) +- **IMPROVE:** New emails design ([#12009](https://github.com/RocketChat/Rocket.Chat/pull/12009)) -- [IMPROVE] New emails design ([#12009](https://github.com/RocketChat/Rocket.Chat/pull/12009)) +- Update the default port of the Prometheus exporter ([#11351](https://github.com/RocketChat/Rocket.Chat/pull/11351) by [@thaiphv](https://github.com/thaiphv)) ### ๐ŸŽ‰ New features @@ -8746,7 +8791,7 @@ ### ๐Ÿ› Bug fixes -- [i18n] add room type translation support for room-changed-privacy message ([#9369](https://github.com/RocketChat/Rocket.Chat/pull/9369) by [@cyclops24](https://github.com/cyclops24)) +- **i18n:** add room type translation support for room-changed-privacy message ([#9369](https://github.com/RocketChat/Rocket.Chat/pull/9369) by [@cyclops24](https://github.com/cyclops24)) - Fix livechat register form ([#9452](https://github.com/RocketChat/Rocket.Chat/pull/9452)) @@ -9157,6 +9202,10 @@ ### ๐Ÿ› Bug fixes +- **i18n:** My Profile & README.md links ([#8270](https://github.com/RocketChat/Rocket.Chat/pull/8270) by [@Rzeszow](https://github.com/Rzeszow)) + +- **PL:** Polish translation ([#7989](https://github.com/RocketChat/Rocket.Chat/pull/7989) by [@Rzeszow](https://github.com/Rzeszow)) + - Can't react on Read Only rooms even when enabled ([#8925](https://github.com/RocketChat/Rocket.Chat/pull/8925) by [@karlprieb](https://github.com/karlprieb)) - CAS does not share secrets when operating multiple server instances ([#8654](https://github.com/RocketChat/Rocket.Chat/pull/8654) by [@AmShaegar13](https://github.com/AmShaegar13)) @@ -9345,8 +9394,6 @@ - Attachment icons alignment in LTR and RTL ([#8271](https://github.com/RocketChat/Rocket.Chat/pull/8271) by [@cyclops24](https://github.com/cyclops24)) -- [i18n] My Profile & README.md links ([#8270](https://github.com/RocketChat/Rocket.Chat/pull/8270) by [@Rzeszow](https://github.com/Rzeszow)) - - Incorrect URL for login terms when using prefix ([#8211](https://github.com/RocketChat/Rocket.Chat/pull/8211) by [@Darkneon](https://github.com/Darkneon)) - Scrollbar not using new style ([#8190](https://github.com/RocketChat/Rocket.Chat/pull/8190)) @@ -9391,8 +9438,6 @@ - Recent emojis not updated when adding via text ([#7998](https://github.com/RocketChat/Rocket.Chat/pull/7998)) -- [PL] Polish translation ([#7989](https://github.com/RocketChat/Rocket.Chat/pull/7989) by [@Rzeszow](https://github.com/Rzeszow)) - - Chat box no longer auto-focuses when typing ([#7984](https://github.com/RocketChat/Rocket.Chat/pull/7984)) - Fix the status on the members list ([#7963](https://github.com/RocketChat/Rocket.Chat/pull/7963)) @@ -10017,6 +10062,10 @@ ### ๐Ÿ› Bug fixes +- **PL:** Polish translation ([#7989](https://github.com/RocketChat/Rocket.Chat/pull/7989) by [@Rzeszow](https://github.com/Rzeszow)) + +- **i18n:** My Profile & README.md links ([#8270](https://github.com/RocketChat/Rocket.Chat/pull/8270) by [@Rzeszow](https://github.com/Rzeszow)) + - File upload on multi-instances using a path prefix ([#7855](https://github.com/RocketChat/Rocket.Chat/pull/7855) by [@Darkneon](https://github.com/Darkneon)) - Fix migration 100 ([#7863](https://github.com/RocketChat/Rocket.Chat/pull/7863)) @@ -10147,8 +10196,6 @@ - Recent emojis not updated when adding via text ([#7998](https://github.com/RocketChat/Rocket.Chat/pull/7998)) -- [PL] Polish translation ([#7989](https://github.com/RocketChat/Rocket.Chat/pull/7989) by [@Rzeszow](https://github.com/Rzeszow)) - - Fix email on mention ([#7754](https://github.com/RocketChat/Rocket.Chat/pull/7754)) - RTL ([#8112](https://github.com/RocketChat/Rocket.Chat/pull/8112)) @@ -10223,8 +10270,6 @@ - Attachment icons alignment in LTR and RTL ([#8271](https://github.com/RocketChat/Rocket.Chat/pull/8271) by [@cyclops24](https://github.com/cyclops24)) -- [i18n] My Profile & README.md links ([#8270](https://github.com/RocketChat/Rocket.Chat/pull/8270) by [@Rzeszow](https://github.com/Rzeszow)) - - some placeholder and phrase traslation fix ([#8269](https://github.com/RocketChat/Rocket.Chat/pull/8269) by [@cyclops24](https://github.com/cyclops24)) - "Channel Setting" buttons alignment in RTL ([#8266](https://github.com/RocketChat/Rocket.Chat/pull/8266) by [@cyclops24](https://github.com/cyclops24)) diff --git a/app/utils/rocketchat.info b/app/utils/rocketchat.info index 67bc530e7a14..38a729757434 100644 --- a/app/utils/rocketchat.info +++ b/app/utils/rocketchat.info @@ -1,3 +1,3 @@ { - "version": "3.1.1" + "version": "3.1.2" } diff --git a/package.json b/package.json index a7ea843f53be..9e1e84d8cd1e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Rocket.Chat", "description": "The Ultimate Open Source WebChat Platform", - "version": "3.1.1", + "version": "3.1.2", "author": { "name": "Rocket.Chat", "url": "https://rocket.chat/"