From a165253edac15269047ce008a3136ee6c9d5cd5b Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 1 Aug 2017 10:25:21 -0300 Subject: [PATCH 01/32] Bump version to 0.58.0-rc.0 --- .docker/Dockerfile | 2 +- .sandstorm/sandstorm-pkgdef.capnp | 2 +- .travis/snap.sh | 2 +- HISTORY.md | 126 ++++++++++++++++++++++++ package.json | 2 +- packages/rocketchat-lib/rocketchat.info | 2 +- 6 files changed, 131 insertions(+), 5 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 8fe9e14c21b2..0b3876f7963f 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,6 +1,6 @@ FROM rocketchat/base:4 -ENV RC_VERSION 0.58.0-develop +ENV RC_VERSION 0.58.0-rc.0 MAINTAINER buildmaster@rocket.chat diff --git a/.sandstorm/sandstorm-pkgdef.capnp b/.sandstorm/sandstorm-pkgdef.capnp index eb803ec95457..ae5b72f4362f 100644 --- a/.sandstorm/sandstorm-pkgdef.capnp +++ b/.sandstorm/sandstorm-pkgdef.capnp @@ -21,7 +21,7 @@ const pkgdef :Spk.PackageDefinition = ( appVersion = 62, # Increment this for every release. - appMarketingVersion = (defaultText = "0.58.0-develop"), + appMarketingVersion = (defaultText = "0.58.0-rc.0"), # Human-readable representation of appVersion. Should match the way you # identify versions of your app in documentation and marketing. diff --git a/.travis/snap.sh b/.travis/snap.sh index 5bb61d473ecf..683a032d696b 100755 --- a/.travis/snap.sh +++ b/.travis/snap.sh @@ -17,7 +17,7 @@ elif [[ $TRAVIS_TAG ]]; then RC_VERSION=$TRAVIS_TAG else CHANNEL=edge - RC_VERSION=0.58.0-develop + RC_VERSION=0.58.0-rc.0 fi echo "Preparing to trigger a snap release for $CHANNEL channel" diff --git a/HISTORY.md b/HISTORY.md index b0dd35a2e5f2..b4fe7b347e98 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,129 @@ + +# 0.58.0-rc.0 (2017-08-01) + + +### BREAKING CHANGES + +- [#7556](https://github.com/RocketChat/Rocket.Chat/pull/7556) Remove Sandstorm login method + + +### New Features + +- [#7279](https://github.com/RocketChat/Rocket.Chat/pull/7279) /help slashcommand +- [#7479](https://github.com/RocketChat/Rocket.Chat/pull/7479) Add admin and user setting for notifications [#4339](https://github.com/RocketChat/Rocket.Chat/issue/4339) +- [#7529](https://github.com/RocketChat/Rocket.Chat/pull/7529) Add close button to flex tabs +- [#6564](https://github.com/RocketChat/Rocket.Chat/pull/6564) Add customFields in rooms/get method +- [#7211](https://github.com/RocketChat/Rocket.Chat/pull/7211) Add instance id to response headers +- [#7569](https://github.com/RocketChat/Rocket.Chat/pull/7569) Add reaction to the last message when get the shortcut +: +- [#7327](https://github.com/RocketChat/Rocket.Chat/pull/7327) Add ref="noopener noreferrer" to Markdown links +- [#7520](https://github.com/RocketChat/Rocket.Chat/pull/7520) Add room type identifier to room list header +- [#6753](https://github.com/RocketChat/Rocket.Chat/pull/6753) Add setting to change User Agent of OEmbed calls +- [#7525](https://github.com/RocketChat/Rocket.Chat/pull/7525) Add toolbar buttons for iframe API +- [#7324](https://github.com/RocketChat/Rocket.Chat/pull/7324) Adding support for piwik sub domain settings +- [#7564](https://github.com/RocketChat/Rocket.Chat/pull/7564) Adds preference to one-click-to-direct-message and basic functionality +- [#7273](https://github.com/RocketChat/Rocket.Chat/pull/7273) Adds settings to limit chain of quotes +- [#7214](https://github.com/RocketChat/Rocket.Chat/pull/7214) Allow channel property in the integrations returned content +- [#7595](https://github.com/RocketChat/Rocket.Chat/pull/7595) Allow special chars on room names +- [#7561](https://github.com/RocketChat/Rocket.Chat/pull/7561) Closes tab bar on mobile when leaving room +- [#7517](https://github.com/RocketChat/Rocket.Chat/pull/7517) Configurable Volume for Notifications [#6087](https://github.com/RocketChat/Rocket.Chat/issue/6087) +- [#7326](https://github.com/RocketChat/Rocket.Chat/pull/7326) Do not rate limit bots on createDirectMessage +- [#7309](https://github.com/RocketChat/Rocket.Chat/pull/7309) Edit user permissions +- [#7448](https://github.com/RocketChat/Rocket.Chat/pull/7448) flex-tab now is side by side with message list +- [#7311](https://github.com/RocketChat/Rocket.Chat/pull/7311) Force use of MongoDB for spotlight queries +- [#7232](https://github.com/RocketChat/Rocket.Chat/pull/7232) New error message when opening a direct chat with yourself +- [#7477](https://github.com/RocketChat/Rocket.Chat/pull/7477) Option to select unread count behavior +- [#7589](https://github.com/RocketChat/Rocket.Chat/pull/7589) Option to select unread count style +- [#7242](https://github.com/RocketChat/Rocket.Chat/pull/7242) Real permissions names and descriptions +- [#7523](https://github.com/RocketChat/Rocket.Chat/pull/7523) Room type and recipient data for global event +- [#7334](https://github.com/RocketChat/Rocket.Chat/pull/7334) Search users also by email in toolbar +- [#7580](https://github.com/RocketChat/Rocket.Chat/pull/7580) Show different shape for alert numbers when have mentions +- [#7559](https://github.com/RocketChat/Rocket.Chat/pull/7559) Show emojis and file uploads on notifications +- [#7526](https://github.com/RocketChat/Rocket.Chat/pull/7526) Show room leader at top of chat when user scrolls down. Set and unset leader as admin. +- [#7496](https://github.com/RocketChat/Rocket.Chat/pull/7496) Update meteor to 1.5.1 + + +### Bug Fixes + +- [#7209](https://github.com/RocketChat/Rocket.Chat/pull/7209) "requirePasswordChange" property not being saved when set to false +- [#7472](https://github.com/RocketChat/Rocket.Chat/pull/7472) Always set LDAP properties on login +- [#7390](https://github.com/RocketChat/Rocket.Chat/pull/7390) custom soundEdit.html +- [#7347](https://github.com/RocketChat/Rocket.Chat/pull/7347) Don't @ mention when doing reply in DM +- [#7513](https://github.com/RocketChat/Rocket.Chat/pull/7513) Don't save user to DB when a custom field is invalid +- [#7622](https://github.com/RocketChat/Rocket.Chat/pull/7622) Error when acessing settings before ready +- [#7624](https://github.com/RocketChat/Rocket.Chat/pull/7624) Error when updating message with an empty attachment array +- [#7395](https://github.com/RocketChat/Rocket.Chat/pull/7395) file upload broken when running in subdirectory https://github.com… +- [#7582](https://github.com/RocketChat/Rocket.Chat/pull/7582) Fix admin room list show the correct i18n type +- [#7444](https://github.com/RocketChat/Rocket.Chat/pull/7444) Fix Anonymous User +- [#7207](https://github.com/RocketChat/Rocket.Chat/pull/7207) Fix Block Delete Message After (n) Minutes +- [#7617](https://github.com/RocketChat/Rocket.Chat/pull/7617) Fix Custom Fields Crashing on Register +- [#7431](https://github.com/RocketChat/Rocket.Chat/pull/7431) Fix Emails in User Admin View +- [#7195](https://github.com/RocketChat/Rocket.Chat/pull/7195) Fix emoji picker translations +- [#7187](https://github.com/RocketChat/Rocket.Chat/pull/7187) Fix error on image preview due to undefined description|title +- [#7469](https://github.com/RocketChat/Rocket.Chat/pull/7469) Fix file upload on Slack import +- [#7322](https://github.com/RocketChat/Rocket.Chat/pull/7322) Fix geolocation button +- [#7486](https://github.com/RocketChat/Rocket.Chat/pull/7486) Fix hiding flex-tab on embedded view +- [#7190](https://github.com/RocketChat/Rocket.Chat/pull/7190) Fix i18n issue with compound language name +- [#7317](https://github.com/RocketChat/Rocket.Chat/pull/7317) Fix issue [#7316](https://github.com/RocketChat/Rocket.Chat/issue/7316) (send real names) +- [#7535](https://github.com/RocketChat/Rocket.Chat/pull/7535) Fix Join Channel Without Preview Room Permission +- [#7320](https://github.com/RocketChat/Rocket.Chat/pull/7320) Fix jump to unread button +- [#7270](https://github.com/RocketChat/Rocket.Chat/pull/7270) Fix not being able to add more than 2 default rooms +- [#7208](https://github.com/RocketChat/Rocket.Chat/pull/7208) Fix oembed previews not being shown +- [#7432](https://github.com/RocketChat/Rocket.Chat/pull/7432) Fix Private Channel List Submit +- [#7321](https://github.com/RocketChat/Rocket.Chat/pull/7321) Fix Secret Url +- [#7403](https://github.com/RocketChat/Rocket.Chat/pull/7403) Fix Unread Bar Disappearing +- [#7392](https://github.com/RocketChat/Rocket.Chat/pull/7392) Fix Word Placement Anywhere on WebHooks +- [#7230](https://github.com/RocketChat/Rocket.Chat/pull/7230) Fixes scope error preventing file upload errors from being dismissed +- [#7555](https://github.com/RocketChat/Rocket.Chat/pull/7555) Improve build script example +- [#7471](https://github.com/RocketChat/Rocket.Chat/pull/7471) Issue [#7365](https://github.com/RocketChat/Rocket.Chat/issue/7365): added check for the existence of a parameter in the CAS URL +- [#7253](https://github.com/RocketChat/Rocket.Chat/pull/7253) Loads of console.log for CacheCollections +- [#7554](https://github.com/RocketChat/Rocket.Chat/pull/7554) Look for livechat visitor IP address on X-Forwarded-For header +- [#7379](https://github.com/RocketChat/Rocket.Chat/pull/7379) Message being displayed unescaped +- [#7621](https://github.com/RocketChat/Rocket.Chat/pull/7621) Message box on safari +- [#7533](https://github.com/RocketChat/Rocket.Chat/pull/7533) Missing eventName in unUser +- [#7325](https://github.com/RocketChat/Rocket.Chat/pull/7325) Modernize rate limiting of sendMessage +- [#7487](https://github.com/RocketChat/Rocket.Chat/pull/7487) Prevent new room status from playing when user status changes +- [#7354](https://github.com/RocketChat/Rocket.Chat/pull/7354) Remove warning about 2FA support being unavailable in mobile apps +- [#7557](https://github.com/RocketChat/Rocket.Chat/pull/7557) Revert emojione package version upgrade +- [#7443](https://github.com/RocketChat/Rocket.Chat/pull/7443) S3 uploads not working for custom URLs +- [#7562](https://github.com/RocketChat/Rocket.Chat/pull/7562) Stop logging mentions object to console +- [#7376](https://github.com/RocketChat/Rocket.Chat/pull/7376) Sweet-Alert modal popup position on mobile devices +- [#7404](https://github.com/RocketChat/Rocket.Chat/pull/7404) sweetalert alignment on mobile +- [#7620](https://github.com/RocketChat/Rocket.Chat/pull/7620) The username not being allowed to be passed into the user.setAvatar +- [#7319](https://github.com/RocketChat/Rocket.Chat/pull/7319) Translation of word Away to Ausente instead of ausente in (PT,PT-BR) +- [#7355](https://github.com/RocketChat/Rocket.Chat/pull/7355) Update node-engine in Snap to latest v4 LTS relase: 4.8.3 +- [#7623](https://github.com/RocketChat/Rocket.Chat/pull/7623) Uploading an unknown file type erroring out +- [#7538](https://github.com/RocketChat/Rocket.Chat/pull/7538) URL parse error fix for issue [#7169](https://github.com/RocketChat/Rocket.Chat/issue/7169) +- [#7199](https://github.com/RocketChat/Rocket.Chat/pull/7199) Use I18n on "File Uploaded" +- [#7353](https://github.com/RocketChat/Rocket.Chat/pull/7353) Use regular require() for postcss plugins +- [#7394](https://github.com/RocketChat/Rocket.Chat/pull/7394) Use UTF8 setting for /create command +- [#7572](https://github.com/RocketChat/Rocket.Chat/pull/7572) User avatar image background +- [#7212](https://github.com/RocketChat/Rocket.Chat/pull/7212) Users and Channels list not respecting permissions +- [#7218](https://github.com/RocketChat/Rocket.Chat/pull/7218) Vague error message when creating integration and rocket.cat is deleted + + +
+Others + +- [#7608](https://github.com/RocketChat/Rocket.Chat/pull/7608) Add missing parts of `one click to direct message` +- [#7492](https://github.com/RocketChat/Rocket.Chat/pull/7492) Better Issue Template +- [#7380](https://github.com/RocketChat/Rocket.Chat/pull/7380) dependencies upgrade +- [#7363](https://github.com/RocketChat/Rocket.Chat/pull/7363) Develop sync +- [#7590](https://github.com/RocketChat/Rocket.Chat/pull/7590) Develop sync +- [#7500](https://github.com/RocketChat/Rocket.Chat/pull/7500) Develop sync +- [#7308](https://github.com/RocketChat/Rocket.Chat/pull/7308) Escape error messages +- [#7615](https://github.com/RocketChat/Rocket.Chat/pull/7615) Improve link parser using tokens +- [#7616](https://github.com/RocketChat/Rocket.Chat/pull/7616) Improve login error messages +- [#7578](https://github.com/RocketChat/Rocket.Chat/pull/7578) Improve room leader +- [#7594](https://github.com/RocketChat/Rocket.Chat/pull/7594) LingoHub based on develop +- [#7362](https://github.com/RocketChat/Rocket.Chat/pull/7362) LingoHub based on develop +- [#7613](https://github.com/RocketChat/Rocket.Chat/pull/7613) LingoHub based on develop +- [#7428](https://github.com/RocketChat/Rocket.Chat/pull/7428) Run avatar migration on startup +- [#1](https://github.com/RocketChat/Rocket.Chat/pull/1) update +- [#7287](https://github.com/RocketChat/Rocket.Chat/pull/7287) update meteor to 1.5.0 +
+ + + ## 0.57.2 (2017-07-14) diff --git a/package.json b/package.json index cf1f1913a863..19ab5a478b8c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Rocket.Chat", "description": "The Ultimate Open Source WebChat Platform", - "version": "0.58.0-develop", + "version": "0.58.0-rc.0", "author": { "name": "Rocket.Chat", "url": "https://rocket.chat/" diff --git a/packages/rocketchat-lib/rocketchat.info b/packages/rocketchat-lib/rocketchat.info index 62923a4bec41..4151e52a28f7 100644 --- a/packages/rocketchat-lib/rocketchat.info +++ b/packages/rocketchat-lib/rocketchat.info @@ -1,3 +1,3 @@ { - "version": "0.58.0-develop" + "version": "0.58.0-rc.0" } From c6ea6a43d50bc84cf2ca46b7868ef20472a5afb9 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 8 Aug 2017 14:54:47 -0300 Subject: [PATCH 02/32] Merge pull request #7639 from RocketChat/all-messages-email [FIX] Wrong email subject when "All Messages" setting enabled --- packages/rocketchat-i18n/i18n/en.i18n.json | 1 + .../server/lib/sendEmailOnMessage.js | 87 +++++++++---------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 8f89a01f3d01..87eba5102aaa 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1134,6 +1134,7 @@ "Offline_form_unavailable_message": "Offline form unavailable message", "Offline_Link_Message": "GO TO MESSAGE", "Offline_Mention_Email": "You have been mentioned by __user__ in #__room__", + "Offline_Mention_All_Email": "__user__ has posted a message in #__room__", "Offline_message": "Offline message", "Offline_success_message": "Offline success message", "Offline_unavailable": "Offline unavailable", diff --git a/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js b/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js index 8ed92b4eced0..94258f5ae1aa 100644 --- a/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js +++ b/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js @@ -10,30 +10,6 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { return message; } - let emailSubject; - const usersToSendEmail = {}; - const directMessage = room.t === 'd'; - - if (directMessage) { - usersToSendEmail[message.rid.replace(message.u._id, '')] = 1; - - emailSubject = TAPi18n.__('Offline_DM_Email', { - user: message.u.username - }); - - } else { - if (message.mentions) { - message.mentions.forEach(function(mention) { - usersToSendEmail[mention._id] = 1; - }); - } - - emailSubject = TAPi18n.__('Offline_Mention_Email', { - user: message.u.username, - room: room.name - }); - } - const getMessageLink = (room, sub) => { const roomPath = RocketChat.roomTypes.getRouteLink(room.t, sub); const path = Meteor.absoluteUrl(roomPath ? roomPath.replace(/^\//, '') : ''); @@ -63,28 +39,33 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { const footer = RocketChat.placeholders.replace(RocketChat.settings.get('Email_Footer') || ''); messageHTML = messageHTML.replace(/\n/gm, '
'); - RocketChat.models.Subscriptions.findWithSendEmailByRoomId(room._id).forEach((sub) => { - if (sub.disableNotifications) { - delete usersToSendEmail[sub.u._id]; - } else { - switch (sub.emailNotifications) { - case 'all': - usersToSendEmail[sub.u._id] = 'force'; - break; - case 'mentions': - if (usersToSendEmail[sub.u._id]) { - usersToSendEmail[sub.u._id] = 'force'; - } - break; - case 'nothing': - delete usersToSendEmail[sub.u._id]; - break; - case 'default': - break; + const usersToSendEmail = {}; + if (room.t === 'd') { + usersToSendEmail[message.rid.replace(message.u._id, '')] = 'direct'; + } else { + RocketChat.models.Subscriptions.findWithSendEmailByRoomId(room._id).forEach((sub) => { + if (sub.disableNotifications) { + return delete usersToSendEmail[sub.u._id]; } - } - }); + const emailNotifications = sub.emailNotifications; + + if (emailNotifications !== 'nothing') { + const mentionedUser = message.mentions.find((mention) => { + return mention._id === sub.u._id; + }); + + if (emailNotifications === 'mentions' || mentionedUser) { + return usersToSendEmail[sub.u._id] = 'mention'; + } + + if (emailNotifications === 'all') { + return usersToSendEmail[sub.u._id] = 'all'; + } + } + delete usersToSendEmail[sub.u._id]; + }); + } const userIdsToSendEmail = Object.keys(usersToSendEmail); let defaultLink; @@ -114,6 +95,24 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { return; } + let emailSubject; + switch (usersToSendEmail[user._id]) { + case 'all': + emailSubject = TAPi18n.__('Offline_Mention_All_Email', { + user: message.u.username, + room: room.name || room.label + }); + break; + case 'direct': + emailSubject = TAPi18n.__('Offline_DM_Email', { user: message.u.username }); + break; + case 'mention': + emailSubject = TAPi18n.__('Offline_Mention_Email', { + user: message.u.username, + room: room.name + }); + break; + } user.emails.some((email) => { if (email.verified) { email = { From dee7ffe0cdebf9de9153bbf35917cf37dd7ad63b Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 8 Aug 2017 14:53:35 -0300 Subject: [PATCH 03/32] Merge pull request #7652 from RocketChat/fix-fileupload-title [FIX] Only use "File Uploaded" prefix on files --- .../rocketchat-file-upload/server/methods/sendFileMessage.js | 1 + .../client/messageAttachment.html | 2 +- .../client/messageAttachment.js | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/rocketchat-file-upload/server/methods/sendFileMessage.js b/packages/rocketchat-file-upload/server/methods/sendFileMessage.js index 681b487bdfe2..59bf7d82b568 100644 --- a/packages/rocketchat-file-upload/server/methods/sendFileMessage.js +++ b/packages/rocketchat-file-upload/server/methods/sendFileMessage.js @@ -24,6 +24,7 @@ Meteor.methods({ const attachment = { title: file.name, + type: 'file', description: file.description, title_link: fileUrl, title_link_download: true diff --git a/packages/rocketchat-message-attachments/client/messageAttachment.html b/packages/rocketchat-message-attachments/client/messageAttachment.html index abd6e39cea4b..1682692df2be 100644 --- a/packages/rocketchat-message-attachments/client/messageAttachment.html +++ b/packages/rocketchat-message-attachments/client/messageAttachment.html @@ -30,7 +30,7 @@ {{#if title}}
{{#if title_link}} - {{_ "Attachment_File_Uploaded"}} : {{title}} + {{#if isFile}} {{_ "Attachment_File_Uploaded"}}: {{/if}}{{title}} {{#if title_link_download}} {{/if}} diff --git a/packages/rocketchat-message-attachments/client/messageAttachment.js b/packages/rocketchat-message-attachments/client/messageAttachment.js index 3542ca4a0468..c4d641427b76 100644 --- a/packages/rocketchat-message-attachments/client/messageAttachment.js +++ b/packages/rocketchat-message-attachments/client/messageAttachment.js @@ -70,5 +70,9 @@ Template.messageAttachment.helpers({ }, injectIndex(data, previousIndex, index) { data.index = `${ previousIndex }.attachments.${ index }`; + }, + + isFile() { + return this.type === 'file'; } }); From 16bfbb251ebb8e46478ebce8d23af23429b4b466 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 8 Aug 2017 14:52:06 -0300 Subject: [PATCH 04/32] Merge pull request #7644 from jangmarker/ref-to-rel-fix [FIX] Markdown noopener/noreferrer: use correct HTML attribute --- packages/rocketchat-markdown/markdown.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/rocketchat-markdown/markdown.js b/packages/rocketchat-markdown/markdown.js index fd477c6e905b..2bcb60d1cd2b 100644 --- a/packages/rocketchat-markdown/markdown.js +++ b/packages/rocketchat-markdown/markdown.js @@ -57,7 +57,7 @@ class MarkdownClass { // Support ![alt text](http://image url) msg = msg.replace(new RegExp(`!\\[([^\\]]+)\\]\\(((?:${ schemes }):\\/\\/[^\\)]+)\\)`, 'gm'), function(match, title, url) { const target = url.indexOf(Meteor.absoluteUrl()) === 0 ? '' : '_blank'; - const html = `
`; + const html = `
`; if (message && message.tokens) { const token = `=!=${ Random.id() }=!=`; @@ -76,13 +76,13 @@ class MarkdownClass { // Support [Text](http://link) msg = msg.replace(new RegExp(`\\[([^\\]]+)\\]\\(((?:${ schemes }):\\/\\/[^\\)]+)\\)`, 'gm'), function(match, title, url) { const target = url.indexOf(Meteor.absoluteUrl()) === 0 ? '' : '_blank'; - return `${ _.escapeHTML(title) }`; + return `${ _.escapeHTML(title) }`; }); // Support msg = msg.replace(new RegExp(`(?:<|<)((?:${ schemes }):\\/\\/[^\\|]+)\\|(.+?)(?=>|>)(?:>|>)`, 'gm'), (match, url, title) => { const target = url.indexOf(Meteor.absoluteUrl()) === 0 ? '' : '_blank'; - return `${ _.escapeHTML(title) }`; + return `${ _.escapeHTML(title) }`; }); if (typeof window !== 'undefined' && window !== null ? window.rocketDebug : undefined) { console.log('Markdown', msg); } From c995ba204d455d1e05d95f2b23ec602f17c4d915 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 8 Aug 2017 14:33:07 -0300 Subject: [PATCH 05/32] Merge pull request #7687 from RocketChat/fix-first-hit-on-room-url [FIX] Fix room load on first hit --- packages/rocketchat-ui-master/client/main.js | 4 +++ packages/rocketchat-ui-master/package.js | 1 + .../rocketchat-ui/client/lib/RoomManager.js | 29 ++++++++++--------- packages/rocketchat-ui/package.js | 1 + 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/rocketchat-ui-master/client/main.js b/packages/rocketchat-ui-master/client/main.js index 2a2b9efe015d..378e3edc1bd1 100644 --- a/packages/rocketchat-ui-master/client/main.js +++ b/packages/rocketchat-ui-master/client/main.js @@ -105,6 +105,7 @@ Template.body.onRendered(function() { } }); +RocketChat.mainReady = new ReactiveVar(false); Template.main.helpers({ siteName() { return RocketChat.settings.get('Site_Name'); @@ -132,6 +133,9 @@ Template.main.helpers({ const settingsReady = RocketChat.settings.cachedCollection.ready.get(); const ready = (Meteor.userId() == null) || (routerReady && subscriptionsReady && settingsReady); RocketChat.CachedCollectionManager.syncEnabled = ready; + Meteor.defer(() => { + RocketChat.mainReady.set(ready); + }); return ready; }, hasUsername() { diff --git a/packages/rocketchat-ui-master/package.js b/packages/rocketchat-ui-master/package.js index 4a0509d0723d..06bbb49d90dd 100644 --- a/packages/rocketchat-ui-master/package.js +++ b/packages/rocketchat-ui-master/package.js @@ -20,6 +20,7 @@ Package.onUse(function(api) { 'ecmascript', 'templating', 'underscore', + 'reactive-var', 'rocketchat:lib', 'meteorhacks:inject-initial' ]); diff --git a/packages/rocketchat-ui/client/lib/RoomManager.js b/packages/rocketchat-ui/client/lib/RoomManager.js index 32c998e0132f..6b9fa7031083 100644 --- a/packages/rocketchat-ui/client/lib/RoomManager.js +++ b/packages/rocketchat-ui/client/lib/RoomManager.js @@ -12,7 +12,7 @@ const RoomManager = new function() { Object.keys(openedRooms).forEach(typeName => { const record = openedRooms[typeName]; if (record.active !== true || record.ready === true) { return; } - const ready = CachedChatRoom.ready.get() && CachedChatSubscription.ready.get() === true; + const ready = CachedChatRoom.ready.get() && RocketChat.mainReady.get(); if (ready !== true) { return; } const user = Meteor.user(); @@ -256,18 +256,19 @@ Tracker.autorun(function() { return connectionWasOnline = connected; }); -// Reload rooms after login -let currentUsername = undefined; -Tracker.autorun(() => { - const user = Meteor.user(); - if ((currentUsername === undefined) && ((user != null ? user.username : undefined) != null)) { - currentUsername = user.username; - RoomManager.closeAllRooms(); - return FlowRouter._current.route.callAction(FlowRouter._current); - } -}); +Meteor.startup(() => { + + // Reload rooms after login + let currentUsername = undefined; + Tracker.autorun(() => { + const user = Meteor.user(); + if ((currentUsername === undefined) && ((user != null ? user.username : undefined) != null)) { + currentUsername = user.username; + RoomManager.closeAllRooms(); + FlowRouter.reload(); + } + }); -Meteor.startup(() => ChatMessage.find().observe({ removed(record) { if (RoomManager.getOpenedRoomByRid(record.rid) != null) { @@ -282,8 +283,8 @@ Meteor.startup(() => } } } - }) -); + }); +}); const onDeleteMessageStream = msg => ChatMessage.remove({_id: msg._id}); diff --git a/packages/rocketchat-ui/package.js b/packages/rocketchat-ui/package.js index 200ff32d6daf..160baa292206 100644 --- a/packages/rocketchat-ui/package.js +++ b/packages/rocketchat-ui/package.js @@ -22,6 +22,7 @@ Package.onUse(function(api) { 'templating', 'underscore', 'rocketchat:lib', + 'rocketchat:ui-master', 'raix:push', 'raix:ui-dropped-event' ]); From 9407587023505113ed6f5b05eb1dde164ee309a0 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Mon, 7 Aug 2017 14:35:11 -0300 Subject: [PATCH 06/32] Merge pull request #7658 from RocketChat/unread-count-for-direct-messages [NEW] Add unread options for direct messages --- packages/rocketchat-i18n/i18n/en.i18n.json | 4 +- .../server/lib/notifyUsersOnMessage.js | 38 ++++++++++++------- .../rocketchat-lib/server/startup/settings.js | 13 +++++++ 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 87eba5102aaa..40b470db31ee 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -986,6 +986,7 @@ "Members_List": "Members List", "Mentions": "Mentions", "Mentions_default": "Mentions (default)", + "Mentions_only": "Mentions only", "Message": "Message", "Message_AllowBadWordsFilter": "Allow Message bad words filtering", "Message_AllowDeleting": "Allow Message Deleting", @@ -1745,6 +1746,7 @@ "Unnamed": "Unnamed", "Unpin_Message": "Unpin Message", "Unread_Count": "Unread Count", + "Unread_Count_DM": "Unread Count for Direct Messages", "Unread_Tray_Icon_Alert": "Unread Tray Icon Alert", "Unread_Messages": "Unread Messages", "Unread_Rooms": "Unread Rooms", @@ -1916,4 +1918,4 @@ "your_message_optional": "your message (optional)", "Your_password_is_wrong": "Your password is wrong!", "Your_push_was_sent_to_s_devices": "Your push was sent to %s devices" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js b/packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js index b14089ad6cb3..efe67344d3ca 100644 --- a/packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js +++ b/packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js @@ -68,22 +68,34 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { } }); - const unreadCount = RocketChat.settings.get('Unread_Count'); + if (room.t === 'd') { + const unreadCountDM = RocketChat.settings.get('Unread_Count_DM'); - if (toAll || toHere) { - let incUnread = 0; - if (['all_messages', 'group_mentions_only', 'user_and_group_mentions_only'].includes(unreadCount)) { - incUnread = 1; + if (unreadCountDM === 'all_messages') { + RocketChat.models.Subscriptions.incUnreadForRoomIdExcludingUserId(room._id, message.u._id); + } else if (toAll || toHere) { + RocketChat.models.Subscriptions.incGroupMentionsAndUnreadForRoomIdExcludingUserId(room._id, message.u._id, 1, 1); + } else if ((mentionIds && mentionIds.length > 0) || (highlightsIds && highlightsIds.length > 0)) { + RocketChat.models.Subscriptions.incUserMentionsAndUnreadForRoomIdAndUserIds(room._id, _.compact(_.unique(mentionIds.concat(highlightsIds))), 1, 1); } - RocketChat.models.Subscriptions.incGroupMentionsAndUnreadForRoomIdExcludingUserId(room._id, message.u._id, 1, incUnread); - } else if ((mentionIds && mentionIds.length > 0) || (highlightsIds && highlightsIds.length > 0)) { - let incUnread = 0; - if (['all_messages', 'user_mentions_only', 'user_and_group_mentions_only'].includes(unreadCount)) { - incUnread = 1; + } else { + const unreadCount = RocketChat.settings.get('Unread_Count'); + + if (toAll || toHere) { + let incUnread = 0; + if (['all_messages', 'group_mentions_only', 'user_and_group_mentions_only'].includes(unreadCount)) { + incUnread = 1; + } + RocketChat.models.Subscriptions.incGroupMentionsAndUnreadForRoomIdExcludingUserId(room._id, message.u._id, 1, incUnread); + } else if ((mentionIds && mentionIds.length > 0) || (highlightsIds && highlightsIds.length > 0)) { + let incUnread = 0; + if (['all_messages', 'user_mentions_only', 'user_and_group_mentions_only'].includes(unreadCount)) { + incUnread = 1; + } + RocketChat.models.Subscriptions.incUserMentionsAndUnreadForRoomIdAndUserIds(room._id, _.compact(_.unique(mentionIds.concat(highlightsIds))), 1, incUnread); + } else if (unreadCount === 'all_messages') { + RocketChat.models.Subscriptions.incUnreadForRoomIdExcludingUserId(room._id, message.u._id); } - RocketChat.models.Subscriptions.incUserMentionsAndUnreadForRoomIdAndUserIds(room._id, _.compact(_.unique(mentionIds.concat(highlightsIds))), 1, incUnread); - } else if (unreadCount === 'all_messages') { - RocketChat.models.Subscriptions.incUnreadForRoomIdExcludingUserId(room._id, message.u._id); } } diff --git a/packages/rocketchat-lib/server/startup/settings.js b/packages/rocketchat-lib/server/startup/settings.js index 420c1db656c2..325ff3d7e747 100644 --- a/packages/rocketchat-lib/server/startup/settings.js +++ b/packages/rocketchat-lib/server/startup/settings.js @@ -373,6 +373,19 @@ RocketChat.settings.addGroup('General', function() { ], 'public': true }); + this.add('Unread_Count_DM', 'all_messages', { + type: 'select', + values: [ + { + key: 'all_messages', + i18nLabel: 'All_messages' + }, { + key: 'mentions_only', + i18nLabel: 'Mentions_only' + } + ], + 'public': true + }); this.add('CDN_PREFIX', '', { type: 'string', 'public': true From 3481352f0d68868552d411c621f45a1857b18d10 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Wed, 2 Aug 2017 10:46:12 -0300 Subject: [PATCH 07/32] Merge pull request #7630 from RocketChat/hotfix/wrong-snippet-name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [FIX] Wrong render of snippet’s name --- packages/rocketchat-message-snippet/client/messageType.js | 2 +- .../client/tabBar/views/snippetMessage.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rocketchat-message-snippet/client/messageType.js b/packages/rocketchat-message-snippet/client/messageType.js index f6fa6da3399f..c1f1573a3d78 100644 --- a/packages/rocketchat-message-snippet/client/messageType.js +++ b/packages/rocketchat-message-snippet/client/messageType.js @@ -4,7 +4,7 @@ Meteor.startup(function() { system: true, message: 'Snippeted_a_message', data(message) { - const snippetLink = `${ message.snippetName }`; + const snippetLink = `${ _.escapeHTML(message.snippetName) }`; return { snippetLink }; } }); diff --git a/packages/rocketchat-message-snippet/client/tabBar/views/snippetMessage.js b/packages/rocketchat-message-snippet/client/tabBar/views/snippetMessage.js index 2f4d0967e5ed..323c71c91ff7 100644 --- a/packages/rocketchat-message-snippet/client/tabBar/views/snippetMessage.js +++ b/packages/rocketchat-message-snippet/client/tabBar/views/snippetMessage.js @@ -13,6 +13,6 @@ Template.snippetMessage.helpers({ } }, body() { - return `${ this.snippetName }`; + return `${ _.escapeHTML(this.snippetName) }`; } }); From b03c93baa72b5a8b5fa6bb2634e65a64273f758e Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Wed, 2 Aug 2017 10:45:41 -0300 Subject: [PATCH 08/32] Merge pull request #7629 from RocketChat/fix-chatbox-growth [FIX] Fix messagebox growth --- .../rocketchat-theme/client/imports/base.css | 23 +++++-------------- .../rocketchat-ui/client/lib/chatMessages.js | 14 +---------- .../rocketchat-ui/client/views/app/room.js | 5 ---- 3 files changed, 7 insertions(+), 35 deletions(-) diff --git a/packages/rocketchat-theme/client/imports/base.css b/packages/rocketchat-theme/client/imports/base.css index 255a7f722e0d..730ed35c4891 100644 --- a/packages/rocketchat-theme/client/imports/base.css +++ b/packages/rocketchat-theme/client/imports/base.css @@ -1568,11 +1568,8 @@ label.required::after { flex-flow: row nowrap; padding: 0 10px 0 20px; border-width: 0 0 1px; - z-index: 100; - top: 0; - left: 0; - width: 100%; height: calc(var(--header-min-height) + 1px); + flex-shrink: 0; &.visible h2 { overflow: visible; @@ -2130,15 +2127,14 @@ label.required::after { .messages-container { position: relative; - height: 100%; - width: 100%; - top: 0; - left: 0; - z-index: 1; + flex: 1; + display: flex; + flex-direction: column; &-wrapper { height: 100%; display: flex; + flex-grow: 1; } &-main { @@ -2175,12 +2171,7 @@ label.required::after { & .footer { padding: 8px 20px 0; border-width: 1px 0 0; - z-index: 100; - bottom: 0; - left: 0; - width: 100%; - min-height: var(--footer-min-height); - height: 130px; + flex-shrink: 0; } & .message-form { @@ -2534,7 +2525,6 @@ label.required::after { .messages-box { position: relative; overflow: hidden; - width: 100%; flex-grow: 1; & .message-cog-container .message-action.jump-to-search-message { @@ -3273,7 +3263,6 @@ body:not(.is-cordova) { &.opened .flex-tab { display: block; - height: calc(100% - 61px); /* --header-height */ } } diff --git a/packages/rocketchat-ui/client/lib/chatMessages.js b/packages/rocketchat-ui/client/lib/chatMessages.js index 896944449476..f0046e918df9 100644 --- a/packages/rocketchat-ui/client/lib/chatMessages.js +++ b/packages/rocketchat-ui/client/lib/chatMessages.js @@ -13,13 +13,6 @@ this.ChatMessages = class ChatMessages { this.bindEvents(); } - resize() { - let dif = (RocketChat.Layout.isEmbedded() ? 0 : 60) + $('.messages-container').find('footer').outerHeight(); - dif += $('.announcement').length > 0 ? 40 : 0; - return $('.messages-box').css({ - height: `calc(100% - ${ dif }px)`}); - } - getEditingIndex(element) { const msgs = this.wrapper.get(0).querySelectorAll('.own:not(.system)'); let index = 0; @@ -361,11 +354,7 @@ this.ChatMessages = class ChatMessages { bindEvents() { if (this.wrapper && this.wrapper.length) { - return $('.input-message').autogrow({ - postGrowCallback: () => { - return this.resize(); - } - }); + $('.input-message').autogrow(); } } @@ -416,7 +405,6 @@ this.ChatMessages = class ChatMessages { const input = event.currentTarget; // const $input = $(input); const k = event.which; - this.resize(input); if (k === 13) { if (sendOnEnter == null || sendOnEnter === 'normal' || sendOnEnter === 'desktop' && Meteor.Device.isDesktop()) { diff --git a/packages/rocketchat-ui/client/views/app/room.js b/packages/rocketchat-ui/client/views/app/room.js index 38f9151d97d1..cca77b686a86 100644 --- a/packages/rocketchat-ui/client/views/app/room.js +++ b/packages/rocketchat-ui/client/views/app/room.js @@ -175,11 +175,6 @@ Template.room.helpers({ showAnnouncement() { const roomData = Session.get(`roomData${ this._id }`); if (!roomData) { return false; } - Meteor.defer(() => { - if (window.chatMessages && window.chatMessages[roomData._id]) { - return window.chatMessages[roomData._id].resize(); - } - }); return (roomData.announcement !== undefined) && (roomData.announcement !== ''); }, From 16926f838695bdd297e581239820dff60eed4f70 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 8 Aug 2017 15:18:24 -0300 Subject: [PATCH 09/32] Bump version to 0.58.0-rc.1 --- .docker/Dockerfile | 2 +- .sandstorm/sandstorm-pkgdef.capnp | 2 +- .travis/snap.sh | 2 +- HISTORY.md | 20 ++++++++++++++++++++ package.json | 2 +- packages/rocketchat-lib/rocketchat.info | 2 +- 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 0b3876f7963f..f881f9a4757e 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,6 +1,6 @@ FROM rocketchat/base:4 -ENV RC_VERSION 0.58.0-rc.0 +ENV RC_VERSION 0.58.0-rc.1 MAINTAINER buildmaster@rocket.chat diff --git a/.sandstorm/sandstorm-pkgdef.capnp b/.sandstorm/sandstorm-pkgdef.capnp index ae5b72f4362f..6bd042b4eeba 100644 --- a/.sandstorm/sandstorm-pkgdef.capnp +++ b/.sandstorm/sandstorm-pkgdef.capnp @@ -21,7 +21,7 @@ const pkgdef :Spk.PackageDefinition = ( appVersion = 62, # Increment this for every release. - appMarketingVersion = (defaultText = "0.58.0-rc.0"), + appMarketingVersion = (defaultText = "0.58.0-rc.1"), # Human-readable representation of appVersion. Should match the way you # identify versions of your app in documentation and marketing. diff --git a/.travis/snap.sh b/.travis/snap.sh index 683a032d696b..0194ea5247ee 100755 --- a/.travis/snap.sh +++ b/.travis/snap.sh @@ -17,7 +17,7 @@ elif [[ $TRAVIS_TAG ]]; then RC_VERSION=$TRAVIS_TAG else CHANNEL=edge - RC_VERSION=0.58.0-rc.0 + RC_VERSION=0.58.0-rc.1 fi echo "Preparing to trigger a snap release for $CHANNEL channel" diff --git a/HISTORY.md b/HISTORY.md index b4fe7b347e98..ecd3194fdb6a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,23 @@ + +# 0.58.0-rc.1 (2017-08-08) + + +### New Features + +- [#7658](https://github.com/RocketChat/Rocket.Chat/pull/7658) Add unread options for direct messages + + +### Bug Fixes + +- [#7629](https://github.com/RocketChat/Rocket.Chat/pull/7629) Fix messagebox growth +- [#7687](https://github.com/RocketChat/Rocket.Chat/pull/7687) Fix room load on first hit +- [#7644](https://github.com/RocketChat/Rocket.Chat/pull/7644) Markdown noopener/noreferrer: use correct HTML attribute +- [#7652](https://github.com/RocketChat/Rocket.Chat/pull/7652) Only use "File Uploaded" prefix on files +- [#7639](https://github.com/RocketChat/Rocket.Chat/pull/7639) Wrong email subject when "All Messages" setting enabled +- [#7630](https://github.com/RocketChat/Rocket.Chat/pull/7630) Wrong render of snippet’s name + + + # 0.58.0-rc.0 (2017-08-01) diff --git a/package.json b/package.json index 19ab5a478b8c..cb32add63cd2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Rocket.Chat", "description": "The Ultimate Open Source WebChat Platform", - "version": "0.58.0-rc.0", + "version": "0.58.0-rc.1", "author": { "name": "Rocket.Chat", "url": "https://rocket.chat/" diff --git a/packages/rocketchat-lib/rocketchat.info b/packages/rocketchat-lib/rocketchat.info index 4151e52a28f7..1823723cd7b6 100644 --- a/packages/rocketchat-lib/rocketchat.info +++ b/packages/rocketchat-lib/rocketchat.info @@ -1,3 +1,3 @@ { - "version": "0.58.0-rc.0" + "version": "0.58.0-rc.1" } From a1ae6693e67537c33a534d1a8150d8016b0bd9f6 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 25 Jul 2017 19:06:53 -0300 Subject: [PATCH 10/32] Merge pull request #7555 from RocketChat/improve-build-example [FIX] Improve build script example --- example-build-run.sh | 32 ++++++++++++++++++++++++++++++++ example-build.sh | 16 ---------------- 2 files changed, 32 insertions(+), 16 deletions(-) create mode 100755 example-build-run.sh delete mode 100755 example-build.sh diff --git a/example-build-run.sh b/example-build-run.sh new file mode 100755 index 000000000000..ddd41734de8e --- /dev/null +++ b/example-build-run.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -x +set -euvo pipefail +IFS=$'\n\t' + +# Requies Node.js version 4.x +# Do not run as root + +DEPLOY_DIR=/var/www/rocket.chat + +### BUILD +meteor npm install + +# on the very first build, meteor build command should fail due to a bug on emojione package (related to phantomjs installation) +# the command below forces the error to happen before build command (not needed on subsequent builds) +set +e +meteor add rocketchat:lib +set -e + +meteor build --server-only --directory $DEPLOY_DIR + +### RUN +cd $DEPLOY_DIR/bundle/programs/server +npm install + +cd $DEPLOY_DIR/bundle +NODE_ENV=production \ +PORT=3000 \ +ROOT_URL=http://localhost:3000 \ +MONGO_URL=mongodb://localhost:27017/rocketchat \ +MONGO_OPLOG_URL=mongodb://localhost:27017/local \ +node main.js diff --git a/example-build.sh b/example-build.sh deleted file mode 100755 index 06ac62461246..000000000000 --- a/example-build.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -x -set -euvo pipefail -IFS=$'\n\t' - -# Build -export NODE_ENV=production -meteor add rocketchat:internal-hubot -meteor build --server https://demo.rocket.chat --directory /var/www/rocket.chat - -# Run -export METEOR_SETTINGS=$(cat settings.json) -cd /var/www/rocket.chat/bundle/programs/server -npm install -cd /var/www/rocket.chat/current -pm2 startOrRestart /var/www/rocket.chat/current/pm2.json From eba75aaaf37e57887414d125111ad4cadc440f9e Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 25 Jul 2017 19:05:35 -0300 Subject: [PATCH 11/32] Merge pull request #7535 from RocketChat/fix-preview-channel [FIX] Fix Join Channel Without Preview Room Permission --- packages/rocketchat-ui/client/lib/RoomHistoryManager.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/rocketchat-ui/client/lib/RoomHistoryManager.js b/packages/rocketchat-ui/client/lib/RoomHistoryManager.js index 21b9bbc8306a..ecaa080b6f14 100644 --- a/packages/rocketchat-ui/client/lib/RoomHistoryManager.js +++ b/packages/rocketchat-ui/client/lib/RoomHistoryManager.js @@ -51,11 +51,12 @@ export const RoomHistoryManager = new class { typeName = (curRoomDoc != null ? curRoomDoc.t : undefined) + (curRoomDoc != null ? curRoomDoc.name : undefined); } - return Meteor.call('loadHistory', rid, ts, limit, ls, function(err, result) { + Meteor.call('loadHistory', rid, ts, limit, ls, function(err, result) { if (err) { return; } let previousHeight; + const {messages = []} = result; room.unreadNotLoaded.set(result.unreadNotLoaded); room.firstUnread.set(result.firstUnread); @@ -64,7 +65,7 @@ export const RoomHistoryManager = new class { previousHeight = wrapper.scrollHeight; } - result.messages.forEach(item => { + messages.forEach(item => { if (item.t !== 'command') { const roles = [ (item.u && item.u._id && UserRoles.findOne(item.u._id, { fields: { roles: 1 }})) || {}, @@ -87,8 +88,8 @@ export const RoomHistoryManager = new class { room.isLoading.set(false); if (room.loaded == null) { room.loaded = 0; } - room.loaded += result.messages.length; - if (result.messages.length < limit) { + room.loaded += messages.length; + if (messages.length < limit) { return room.hasMore.set(false); } }); From 112baa031ed26e8249e39fdbc77afe0ecc77b33b Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Wed, 26 Jul 2017 21:49:07 -0300 Subject: [PATCH 12/32] Merge pull request #7533 from Darkneon/fix-missing-eventname-in-unUser [FIX] Missing eventName in unUser --- packages/rocketchat-lib/client/Notifications.js | 4 ++-- .../app/client/lib/fromApp/Notifications.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/rocketchat-lib/client/Notifications.js b/packages/rocketchat-lib/client/Notifications.js index 4a474c9aec24..d0bb34ec04c5 100644 --- a/packages/rocketchat-lib/client/Notifications.js +++ b/packages/rocketchat-lib/client/Notifications.js @@ -79,8 +79,8 @@ RocketChat.Notifications = new class { unRoom(room, eventName, callback) { return this.streamRoom.removeListener(`${ room }/${ eventName }`, callback); } - unUser(callback) { - return this.streamUser.removeListener(Meteor.userId(), callback); + unUser(eventName, callback) { + return this.streamUser.removeListener(`${ Meteor.userId() }/${ eventName }`, callback); } }; diff --git a/packages/rocketchat-livechat/app/client/lib/fromApp/Notifications.js b/packages/rocketchat-livechat/app/client/lib/fromApp/Notifications.js index d33705486995..4c919a20b0d6 100644 --- a/packages/rocketchat-livechat/app/client/lib/fromApp/Notifications.js +++ b/packages/rocketchat-livechat/app/client/lib/fromApp/Notifications.js @@ -72,8 +72,8 @@ this.Notifications = new class { unRoom(room, eventName, callback) { return this.streamRoom.removeListener(`${ room }/${ eventName }`, callback); } - unUser(callback) { - return this.streamUser.removeListener(Meteor.userId(), callback); + unUser(eventName, callback) { + return this.streamUser.removeListener(`${ Meteor.userId() }/${ eventName }`, callback); } }; From 304be18d9942d384add775f5e80522e5b2eddaff Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Fri, 14 Jul 2017 16:18:43 -0300 Subject: [PATCH 13/32] Merge pull request #7444 from RocketChat/anonymous-user-join [FIX] Fix Anonymous User --- .../client/tabs/membersList.js | 2 +- .../rocketchat-ui-message/client/message.js | 4 ++-- .../client/messageBox.js | 24 ++++++++++++++++++- .../rocketchat-ui/client/views/app/room.js | 14 +++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/packages/rocketchat-ui-flextab/client/tabs/membersList.js b/packages/rocketchat-ui-flextab/client/tabs/membersList.js index f6a92be62667..b43181a6d527 100644 --- a/packages/rocketchat-ui-flextab/client/tabs/membersList.js +++ b/packages/rocketchat-ui-flextab/client/tabs/membersList.js @@ -26,7 +26,7 @@ Template.membersList.helpers({ const roomUsers = Template.instance().users.get(); const room = ChatRoom.findOne(this.rid); const roomMuted = (room != null ? room.muted : undefined) || []; - const userUtcOffset = Meteor.user().utcOffset; + const userUtcOffset = Meteor.user() && Meteor.user().utcOffset; let totalOnline = 0; let users = roomUsers.map(function(user) { let utcOffset; diff --git a/packages/rocketchat-ui-message/client/message.js b/packages/rocketchat-ui-message/client/message.js index 6925a48df807..31baf239bf26 100644 --- a/packages/rocketchat-ui-message/client/message.js +++ b/packages/rocketchat-ui-message/client/message.js @@ -13,7 +13,7 @@ Template.message.helpers({ roleTags() { const user = Meteor.user(); // test user -> settings -> preferences -> hideRoles - if (!RocketChat.settings.get('UI_DisplayRoles') || ['settings', 'preferences', 'hideRoles'].reduce((obj, field) => typeof obj !== 'undefined' && obj[field], user)) { + if (!RocketChat.settings.get('UI_DisplayRoles') || (user && ['settings', 'preferences', 'hideRoles'].reduce((obj, field) => typeof obj !== 'undefined' && obj[field], user))) { return []; } @@ -205,7 +205,7 @@ Template.message.helpers({ return true; }, reactions() { - const userUsername = Meteor.user().username; + const userUsername = Meteor.user() && Meteor.user().username; return Object.keys(this.reactions||{}).map(emoji => { const reaction = this.reactions[emoji]; const total = reaction.usernames.length; diff --git a/packages/rocketchat-ui-message/client/messageBox.js b/packages/rocketchat-ui-message/client/messageBox.js index add30a122142..49c221a52e49 100644 --- a/packages/rocketchat-ui-message/client/messageBox.js +++ b/packages/rocketchat-ui-message/client/messageBox.js @@ -54,7 +54,7 @@ Template.messageBox.helpers({ return RocketChat.settings.get('Message_ShowFormattingTips') && (RocketChat.Markdown || RocketChat.MarkdownCode || katexSyntax()); }, canJoin() { - return RocketChat.roomTypes.verifyShowJoinLink(this._id); + return Meteor.userId() && RocketChat.roomTypes.verifyShowJoinLink(this._id); }, joinCodeRequired() { const code = Session.get(`roomData${ this._id }`); @@ -179,6 +179,13 @@ Template.messageBox.helpers({ }, showSandstorm() { return Meteor.settings['public'].sandstorm && !Meteor.isCordova; + }, + + anonymousRead() { + return (Meteor.userId() == null) && RocketChat.settings.get('Accounts_AllowAnonymousRead') === true; + }, + anonymousWrite() { + return (Meteor.userId() == null) && RocketChat.settings.get('Accounts_AllowAnonymousRead') === true && RocketChat.settings.get('Accounts_AllowAnonymousWrite') === true; } }); @@ -248,6 +255,21 @@ Template.messageBox.events({ } }); }, + + 'click .register'(event) { + event.stopPropagation(); + event.preventDefault(); + return Session.set('forceLogin', true); + }, + 'click .register-anonymous'(event) { + event.stopPropagation(); + event.preventDefault(); + return Meteor.call('registerUser', {}, function(error, loginData) { + if (loginData && loginData.token) { + return Meteor.loginWithToken(loginData.token); + } + }); + }, 'focus .input-message'(event, instance) { KonchatNotification.removeRoomNotification(this._id); chatMessages[this._id].input = instance.find('.input-message'); diff --git a/packages/rocketchat-ui/client/views/app/room.js b/packages/rocketchat-ui/client/views/app/room.js index 4cbaffd48873..e4e98104d550 100644 --- a/packages/rocketchat-ui/client/views/app/room.js +++ b/packages/rocketchat-ui/client/views/app/room.js @@ -224,11 +224,16 @@ Template.room.helpers({ return true; } + if (RocketChat.settings.get('Accounts_AllowAnonymousRead') === true) { + return true; + } + if (RocketChat.authz.hasAllPermission('preview-c-room')) { return true; } return (RocketChat.models.Subscriptions.findOne({rid: this._id}) != null); + } }); @@ -393,11 +398,17 @@ Template.room.events({ }, 'click .flex-tab .user-image > button'(e, instance) { + if (!Meteor.userId()) { + return; + } instance.tabBar.open(); return instance.setUserDetail(this.user.username); }, 'click .user-card-message'(e, instance) { + if (!Meteor.userId()) { + return; + } const roomData = Session.get(`roomData${ this._arguments[1].rid }`); if (RocketChat.Layout.isEmbedded()) { @@ -465,6 +476,9 @@ Template.room.events({ }, 'click .mention-link'(e, instance) { + if (!Meteor.userId()) { + return; + } const channel = $(e.currentTarget).data('channel'); if (channel != null) { if (RocketChat.Layout.isEmbedded()) { From cfa26a9acc585bf18b0671f4712345a4db1702b6 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Fri, 14 Jul 2017 16:27:34 -0300 Subject: [PATCH 14/32] Merge pull request #7395 from ryoshimizu/fix-file-upload-broken-when-running-in-subdir-6679 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [FIX] file upload broken when running in subdirectory https://github.com… --- packages/rocketchat-cors/cors.js | 6 +++--- packages/rocketchat-file-upload/server/lib/requests.js | 3 ++- packages/rocketchat-lib/client/lib/settings.js | 4 ++-- .../rocketchat-lib/lib/startup/settingsOnLoadSiteUrl.js | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/rocketchat-cors/cors.js b/packages/rocketchat-cors/cors.js index 9b07501d8d3e..6af8bc100344 100644 --- a/packages/rocketchat-cors/cors.js +++ b/packages/rocketchat-cors/cors.js @@ -2,7 +2,7 @@ import url from 'url'; -WebApp.rawConnectHandlers.use(function(req, res, next) { +WebApp.rawConnectHandlers.use(Meteor.bindEnvironment(function(req, res, next) { if (req._body) { return next(); } @@ -12,7 +12,7 @@ WebApp.rawConnectHandlers.use(function(req, res, next) { if (req.headers['content-type'] !== '' && req.headers['content-type'] !== undefined) { return next(); } - if (req.url.indexOf('/ufs/') === 0) { + if (req.url.indexOf(`${ __meteor_runtime_config__.ROOT_URL_PATH_PREFIX }/ufs/`) === 0) { return next(); } @@ -36,7 +36,7 @@ WebApp.rawConnectHandlers.use(function(req, res, next) { return next(); }); -}); +})); WebApp.rawConnectHandlers.use(function(req, res, next) { if (/^\/(api|_timesync|sockjs|tap-i18n|__cordova)(\/|$)/.test(req.url)) { diff --git a/packages/rocketchat-file-upload/server/lib/requests.js b/packages/rocketchat-file-upload/server/lib/requests.js index 1f759a2defef..175397de6fdb 100644 --- a/packages/rocketchat-file-upload/server/lib/requests.js +++ b/packages/rocketchat-file-upload/server/lib/requests.js @@ -7,7 +7,8 @@ RocketChat.settings.get('FileUpload_ProtectFiles', function(key, value) { protectedFiles = value; }); -WebApp.connectHandlers.use('/file-upload/', function(req, res, next) { +WebApp.connectHandlers.use(`${ __meteor_runtime_config__.ROOT_URL_PATH_PREFIX }/file-upload/`, function(req, res, next) { + const match = /^\/([^\/]+)\/(.*)/.exec(req.url); if (match[1]) { diff --git a/packages/rocketchat-lib/client/lib/settings.js b/packages/rocketchat-lib/client/lib/settings.js index 0f0c946ecd81..e2a769a7608d 100644 --- a/packages/rocketchat-lib/client/lib/settings.js +++ b/packages/rocketchat-lib/client/lib/settings.js @@ -59,8 +59,8 @@ Meteor.startup(function() { return c.stop(); } Meteor.setTimeout(function() { - if (__meteor_runtime_config__.ROOT_URL !== location.origin) { - const currentUrl = location.origin + __meteor_runtime_config__.ROOT_URL_PATH_PREFIX; + const currentUrl = location.origin + __meteor_runtime_config__.ROOT_URL_PATH_PREFIX; + if (__meteor_runtime_config__.ROOT_URL !== currentUrl) { swal({ type: 'warning', title: t('Warning'), diff --git a/packages/rocketchat-lib/lib/startup/settingsOnLoadSiteUrl.js b/packages/rocketchat-lib/lib/startup/settingsOnLoadSiteUrl.js index 17014a7dbe9b..8e4c7d987e6f 100644 --- a/packages/rocketchat-lib/lib/startup/settingsOnLoadSiteUrl.js +++ b/packages/rocketchat-lib/lib/startup/settingsOnLoadSiteUrl.js @@ -10,10 +10,10 @@ RocketChat.settings.get('Site_Url', function(key, value) { host = match[1]; // prefix = match[2].replace(/\/$/, ''); } - __meteor_runtime_config__.ROOT_URL = host; + __meteor_runtime_config__.ROOT_URL = value; if (Meteor.absoluteUrl.defaultOptions && Meteor.absoluteUrl.defaultOptions.rootUrl) { - Meteor.absoluteUrl.defaultOptions.rootUrl = host; + Meteor.absoluteUrl.defaultOptions.rootUrl = value; } if (Meteor.isServer) { RocketChat.hostname = host.replace(/^https?:\/\//, ''); From cd4a7c2f4b453f083324d39a6be21623fd9d77e2 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Fri, 14 Jul 2017 16:29:35 -0300 Subject: [PATCH 15/32] Merge pull request #7394 from RocketChat/fix-create-room-slashcommand [FIX] Use UTF8 setting for /create command --- packages/rocketchat-slashcommands-create/server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/rocketchat-slashcommands-create/server.js b/packages/rocketchat-slashcommands-create/server.js index 4c1ed3963259..a64262065c95 100644 --- a/packages/rocketchat-slashcommands-create/server.js +++ b/packages/rocketchat-slashcommands-create/server.js @@ -12,12 +12,13 @@ function Create(command, params, item) { return result; } - const regexp = /#?([\d-_\w]+)/g; + const regexp = new RegExp(RocketChat.settings.get('UTF8_Names_Validation')); + if (command !== 'create' || !Match.test(params, String)) { return; } let channel = regexp.exec(params.trim()); - channel = channel ? channel[1] : ''; + channel = channel ? channel[0] : ''; if (channel === '') { return; } From 658cda78d16d4be65cfc91e6168051349169aa6a Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Fri, 14 Jul 2017 16:31:53 -0300 Subject: [PATCH 16/32] Merge pull request #7390 from rasos/patch-3 [FIX] custom soundEdit.html --- packages/rocketchat-custom-sounds/admin/soundEdit.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rocketchat-custom-sounds/admin/soundEdit.html b/packages/rocketchat-custom-sounds/admin/soundEdit.html index 4de2d2f85193..3c25ca522b0d 100644 --- a/packages/rocketchat-custom-sounds/admin/soundEdit.html +++ b/packages/rocketchat-custom-sounds/admin/soundEdit.html @@ -13,7 +13,7 @@

{{_ "Custom_Sound_Add"}}

- +