Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into new/…
Browse files Browse the repository at this point in the history
…rewrite_admin_sidebar

* 'develop' of github.com:RocketChat/Rocket.Chat:
  [FIX] When the message is too long declining to send as an attachment does not restore the content into the composer (#16332)
  [IMPROVE][Federation] Add support for _tcp and protocol DNS entries (#17818)
  Fix the update check not working (#17809)
  Add Apps-Engine to Engine Versions on History (#17810)
  [FIX] Link preview containing HTML encoded chars (#16512)
  [FIX] Email link "go to message" being incorrectly escaped (#17803)
  [FIX] Error when re-installing an App (#17789)
  Update Apps-Engine version (#17804)
  Fix invalid develop payload to release service (#17799)
  • Loading branch information
gabriellsh committed Jun 4, 2020
2 parents 147908f + 46856e4 commit 2a8f351
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .circleci/update-releases.sh
Expand Up @@ -3,7 +3,7 @@ set -euvo pipefail
IFS=$'\n\t'

curl -H "Content-Type: application/json" -H "X-Update-Token: $UPDATE_TOKEN" -d \
"{\"commit\": \"$CIRCLE_SHA1\", \"tag\": \"$CIRCLE_TAG\", \"branch\": \"$CIRCLE_BRANCH\", \"artifactName\": \"$ARTIFACT_NAME\", \"releaseType\": \"$RC_RELEASE\" }" \
"{\"commit\": \"$CIRCLE_SHA1\", \"tag\": \"$RC_VERSION\", \"branch\": \"$CIRCLE_BRANCH\", \"artifactName\": \"$ARTIFACT_NAME\", \"releaseType\": \"$RC_RELEASE\" }" \
https://releases.rocket.chat/update

# Makes build fail if the release isn't there
Expand Down
18 changes: 18 additions & 0 deletions .houston/metadata.js
Expand Up @@ -36,8 +36,24 @@ const getNodeNpmVersions = async function({ version, git, request }) {
return {};
};

const getAppsEngineVersion = async function({ version, git }) {
try {
const packageJson = await git.show([`${ version }:package-lock.json`]);
const { dependencies } = JSON.parse(packageJson);
const { version: appsEngineVersion } = dependencies['@rocket.chat/apps-engine'];

return appsEngineVersion;
} catch (e) {
console.error(e);
}

return undefined;
};

module.exports = async function({ version, git, request }) {
const mongo_versions = await getMongoVersion({ version, git });
const apps_engine_version = await getAppsEngineVersion({ version, git });

const {
node_version,
npm_version,
Expand All @@ -46,6 +62,8 @@ module.exports = async function({ version, git, request }) {
return {
node_version,
npm_version,
apps_engine_version,
mongo_versions,
};
};

3 changes: 3 additions & 0 deletions .houston/templates/versions.hbs
Expand Up @@ -10,4 +10,7 @@
{{#if release.mongo_versions}}
- MongoDB: `{{ join release.mongo_versions ', ' }}`
{{/if}}
{{#if release.apps_engine_version}}
- Apps-Engine: `{{ release.apps_engine_version }}`
{{/if}}
{{/if}}
3 changes: 2 additions & 1 deletion app/apps/client/admin/appManage.js
Expand Up @@ -405,7 +405,8 @@ Template.appManage.events({
_app.set('working', true);

try {
const { status } = await Apps.updateApp(appId, _app.get('marketplaceVersion'));
const method = _app.get('installed') ? 'updateApp' : 'installApp';
const { status } = await Apps[method](appId, _app.get('marketplaceVersion'));
warnStatusChange(_app.get('name'), status);
} catch (error) {
handleAPIError(error);
Expand Down
7 changes: 6 additions & 1 deletion app/apps/client/admin/helpers.js
Expand Up @@ -19,6 +19,11 @@ const appErroredStatuses = [
AppStatus.INVALID_LICENSE_DISABLED,
];

const subscriptionActiveStatuses = [
'trialing',
'active',
];

export const handleAPIError = (error) => {
console.error(error);
const message = (error.xhr && error.xhr.responseJSON && error.xhr.responseJSON.error) || error.message;
Expand Down Expand Up @@ -298,7 +303,7 @@ export const appButtonProps = ({
};
}

const canTrial = purchaseType === 'subscription' && !subscriptionInfo.status;
const canTrial = purchaseType === 'subscription' && !subscriptionActiveStatuses.includes(subscriptionInfo.status);
if (canTrial) {
return {
action: 'purchase',
Expand Down
49 changes: 44 additions & 5 deletions app/federation/server/lib/dns.js
Expand Up @@ -29,15 +29,20 @@ export function registerWithHub(peerDomain, url, publicKey) {

export function searchHub(peerDomain) {
try {
logger.dns.debug(`searchHub: peerDomain=${ peerDomain }`);

// If there is no DNS entry for that, get from the Hub
const { data: { peer } } = federationRequest('GET', `${ hubUrl }/api/v1/peers?search=${ peerDomain }`);

if (!peer) {
logger.dns.debug(`searchHub: could not find peerDomain=${ peerDomain }`);
throw federationErrors.peerCouldNotBeRegisteredWithHub('dns.registerWithHub');
}

const { url, public_key: publicKey } = peer;

logger.dns.debug(`searchHub: found peerDomain=${ peerDomain } url=${ url }`);

return {
url,
peerDomain,
Expand All @@ -55,13 +60,14 @@ export function search(peerDomain) {
throw federationErrors.disabled('dns.search');
}

logger.dns.debug(`search: ${ peerDomain }`);
logger.dns.debug(`search: peerDomain=${ peerDomain }`);

let srvEntries = [];
let protocol = '';

// Search by HTTPS first
try {
logger.dns.debug(`search: peerDomain=${ peerDomain } srv=_rocketchat._https.${ peerDomain }`);
srvEntries = dnsResolveSRV(`_rocketchat._https.${ peerDomain }`);
protocol = 'https';
} catch (err) {
Expand All @@ -71,31 +77,64 @@ export function search(peerDomain) {
// If there is not entry, try with http
if (!srvEntries.length) {
try {
logger.dns.debug(`search: peerDomain=${ peerDomain } srv=_rocketchat._http.${ peerDomain }`);
srvEntries = dnsResolveSRV(`_rocketchat._http.${ peerDomain }`);
protocol = 'http';
} catch (err) {
// Ignore errors when looking for DNS entries
}
}

// If there is not entry, try with tcp
if (!srvEntries.length) {
try {
logger.dns.debug(`search: peerDomain=${ peerDomain } srv=_rocketchat._tcp.${ peerDomain }`);
srvEntries = dnsResolveSRV(`_rocketchat._tcp.${ peerDomain }`);
protocol = 'https'; // https is the default

// Then, also try to get the protocol
logger.dns.debug(`search: peerDomain=${ peerDomain } txt=rocketchat-tcp-protocol.${ peerDomain }`);
protocol = dnsResolveTXT(`rocketchat-tcp-protocol.${ peerDomain }`);
protocol = protocol[0].join('');

if (protocol !== 'http' && protocol !== 'https') {
protocol = null;
}
} catch (err) {
// if there is an error while getting the _tcp entry, it means the config is not there
// but if there is an error looking for the `_rocketchat_tcp_protocol` entry, it means we should use https
}
}

const [srvEntry] = srvEntries;

// If there is no entry, throw error
if (!srvEntry) {
if (!srvEntry || !protocol) {
logger.dns.debug(`search: could not find valid SRV entry peerDomain=${ peerDomain } srvEntry=${ JSON.stringify(srvEntry) } protocol=${ protocol }`);
return searchHub(peerDomain);
}

let publicKey = null;

// Get the public key from the TXT record
const publicKeyTxtRecords = dnsResolveTXT(`rocketchat-public-key.${ peerDomain }`);
try {
logger.dns.debug(`search: peerDomain=${ peerDomain } txt=rocketchat-public-key.${ peerDomain }`);
const publicKeyTxtRecords = dnsResolveTXT(`rocketchat-public-key.${ peerDomain }`);

// Join the TXT record, that might be split
const publicKey = publicKeyTxtRecords[0].join('');
// Join the TXT record, that might be split
publicKey = publicKeyTxtRecords[0].join('');
} catch (err) {
// Ignore errors when looking for DNS entries
}

// If there is no entry, throw error
if (!publicKey) {
logger.dns.debug(`search: could not find TXT entry for peerDomain=${ peerDomain } - SRV entry found`);
return searchHub(peerDomain);
}

logger.dns.debug(`search: found peerDomain=${ peerDomain } srvEntry=${ srvEntry.name }:${ srvEntry.port } protocol=${ protocol }`);

return {
url: `${ protocol }://${ srvEntry.name }:${ srvEntry.port }`,
peerDomain,
Expand Down
2 changes: 2 additions & 0 deletions app/federation/server/lib/http.js
Expand Up @@ -37,6 +37,8 @@ export function federationRequestToPeer(method, peerDomain, uri, body, options =
let result;

try {
logger.http.debug(() => `federationRequestToPeer => url=${ baseUrl }${ uri }`);

result = federationRequest(method, `${ baseUrl }${ uri }`, body, options.headers || {}, peerKey);
} catch (err) {
logger.http.error(`${ ignoreErrors ? '[IGNORED] ' : '' }Error ${ err }`);
Expand Down
19 changes: 16 additions & 3 deletions app/mailer/server/api.js
Expand Up @@ -6,7 +6,7 @@ import s from 'underscore.string';
import juice from 'juice';
import stripHtml from 'string-strip-html';

import { settings } from '../../settings';
import { settings } from '../../settings/server';

let contentHeader;
let contentFooter;
Expand Down Expand Up @@ -42,11 +42,13 @@ export const replace = function replace(str, data = {}) {
return Object.entries(options).reduce((ret, [key, value]) => replacekey(ret, key, value), translate(str));
};

const nonEscapeKeys = ['room_path'];

export const replaceEscaped = (str, data = {}) => replace(str, {
Site_Name: s.escapeHTML(settings.get('Site_Name')),
Site_Url: s.escapeHTML(settings.get('Site_Url')),
...Object.entries(data).reduce((ret, [key, value]) => {
ret[key] = s.escapeHTML(value);
ret[key] = nonEscapeKeys.includes(key) ? value : s.escapeHTML(value);
return ret;
}, {}),
});
Expand Down Expand Up @@ -116,7 +118,18 @@ export const sendNoWrap = ({ to, from, replyTo, subject, html, text, headers })
Meteor.defer(() => Email.send({ to, from, replyTo, subject, html, text, headers }));
};

export const send = ({ to, from, replyTo, subject, html, text, data, headers }) => sendNoWrap({ to, from, replyTo, subject: replace(subject, data), text: text ? replace(text, data) : stripHtml(replace(html, data)), html: wrap(html, data), headers });
export const send = ({ to, from, replyTo, subject, html, text, data, headers }) =>
sendNoWrap({
to,
from,
replyTo,
subject: replace(subject, data),
text: text
? replace(text, data)
: stripHtml(replace(html, data)),
html: wrap(html, data),
headers,
});

export const checkAddressFormatAndThrow = (from, func) => {
if (checkAddressFormat(from)) {
Expand Down
2 changes: 1 addition & 1 deletion app/oembed/client/oembedUrlWidget.html
Expand Up @@ -25,7 +25,7 @@
<a href="{{url}}" rel="noopener noreferrer" target="{{target}}"><strong>{{{title}}}</strong></a>
</div>
{{/if}}
<div style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis">{{{description}}}</div>
<div style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis">{{description}}</div>
</div>
</blockquote>
{{/if}}
Expand Down
5 changes: 3 additions & 2 deletions app/oembed/client/oembedUrlWidget.js
@@ -1,6 +1,7 @@
import { Blaze } from 'meteor/blaze';
import { Template } from 'meteor/templating';
import _ from 'underscore';
import s from 'underscore.string';

const getTitle = function(self) {
if (self.meta == null) {
Expand All @@ -17,14 +18,14 @@ const getDescription = function(self) {
if (description == null) {
return;
}
return _.unescape(description.replace(/(^[“\s]*)|([”\s]*$)/g, ''));
return s.unescapeHTML(description.replace(/(^[“\s]*)|([”\s]*$)/g, ''));
};

Template.oembedUrlWidget.helpers({
description() {
const description = getDescription(this);
if (_.isString(description)) {
return Blaze._escape(description);
return description;
}
},
title() {
Expand Down
6 changes: 3 additions & 3 deletions app/ui-utils/client/lib/modal.js
Expand Up @@ -70,6 +70,9 @@ const createModal = (config = {}, fn, onCancel) => {
},

close: () => {
if (onCancel) {
onCancel.call(instance);
}
instance.destroy();
modalStack = modalStack.filter((modal) => modal !== instance);
if (modalStack.length) {
Expand All @@ -89,9 +92,6 @@ const createModal = (config = {}, fn, onCancel) => {
},

cancel: () => {
if (onCancel) {
onCancel.call(instance);
}
instance.close();
},

Expand Down
1 change: 1 addition & 0 deletions app/ui/client/lib/chatMessages.js
Expand Up @@ -374,6 +374,7 @@ export class ChatMessages {
const file = new File([messageBlob], fileName, { type: contentType, lastModified: Date.now() });
fileUpload([{ file, name: fileName }], this.input, { rid, tmid });
} catch (e) {
messageBoxState.set(this.input, msg);
return true;
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions app/version-check/server/functions/checkVersionUpdate.js
Expand Up @@ -44,7 +44,7 @@ export default () => {
sendMessagesToAdmins({
msgs: ({ adminUser }) => [{ msg: `*${ TAPi18n.__('Update_your_RocketChat', adminUser.language) }*\n${ TAPi18n.__('New_version_available_(s)', update.lastestVersion.version, adminUser.language) }\n${ update.lastestVersion.infoUrl }` }],
banners: [{
id: 'versionUpdate',
id: `versionUpdate-${ update.lastestVersion.version }`.replace(/\./g, '_'),
priority: 10,
title: 'Update_your_RocketChat',
text: 'New_version_available_(s)',
Expand All @@ -62,7 +62,7 @@ export default () => {
msg: `*${ TAPi18n.__('Rocket_Chat_Alert', adminUser.language) }:*\n\n*${ TAPi18n.__(alert.title, adminUser.language) }*\n${ TAPi18n.__(alert.text, ...alert.textArguments || [], adminUser.language) }\n${ alert.infoUrl }`,
})),
banners: alerts.map((alert) => ({
id: `alert-${ alert.id }`,
id: `alert-${ alert.id }`.replace(/\./g, '_'),
priority: 10,
title: alert.title,
text: alert.text,
Expand Down
12 changes: 6 additions & 6 deletions app/version-check/server/functions/getNewUpdates.js
Expand Up @@ -2,7 +2,6 @@ import os from 'os';

import { HTTP } from 'meteor/http';
import { check, Match } from 'meteor/check';
import { MongoInternals } from 'meteor/mongo';

import { Settings } from '../../../models';
import { Info } from '../../../utils';
Expand All @@ -11,14 +10,11 @@ import { getWorkspaceAccessToken } from '../../../cloud/server';
export default () => {
try {
const uniqueID = Settings.findOne('uniqueID');
const { _oplogHandle } = MongoInternals.defaultRemoteCollectionDriver().mongo;
const oplogEnabled = _oplogHandle && _oplogHandle.onOplogEntry;

const params = {
uniqueId: uniqueID.value,
installedAt: uniqueID.createdAt,
installedAt: uniqueID.createdAt.toJSON(),
version: Info.version,
oplogEnabled,
osType: os.type(),
osPlatform: os.platform(),
osArch: os.arch(),
Expand All @@ -40,7 +36,11 @@ export default () => {
});

check(data, Match.ObjectIncluding({
versions: [String],
versions: [Match.ObjectIncluding({
version: Match.Optional(String),
security: Match.Optional(Boolean),
infoUrl: Match.Optional(String),
})],
alerts: Match.Optional([Match.ObjectIncluding({
id: Match.Optional(String),
title: Match.Optional(String),
Expand Down
11 changes: 3 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -125,7 +125,7 @@
"@nivo/heatmap": "^0.61.0",
"@nivo/line": "^0.61.1",
"@nivo/pie": "^0.61.1",
"@rocket.chat/apps-engine": "1.15.0-beta.3411",
"@rocket.chat/apps-engine": "1.15.0",
"@rocket.chat/fuselage": "^0.9.0",
"@rocket.chat/fuselage-hooks": "^0.9.0",
"@rocket.chat/fuselage-polyfills": "^0.9.0",
Expand Down

0 comments on commit 2a8f351

Please sign in to comment.