Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into fix-dont-save-us…
Browse files Browse the repository at this point in the history
…er-when-custom-field-is-invalid
  • Loading branch information
Darkneon committed Jul 17, 2017
2 parents 1411fbb + a729aaa commit b560d3b
Show file tree
Hide file tree
Showing 28 changed files with 207 additions and 127 deletions.
2 changes: 1 addition & 1 deletion packages/rocketchat-2fa/client/accountSecurity.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>{{_ "Two-factor_authentication"}}</h1>
<div class="section-content border-component-color">
<div class="alert pending-background pending-color pending-border">
<strong>
WARNING: Once you enable this, you will not be able to login on the native mobile apps (Rocket.Chat+) using your password until they implement the 2FA.
{{_ "Two-factor_authentication_native_mobile_app_warning"}}
</strong>
</div>
{{#if isEnabled}}
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-authorization/server/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Meteor.startup(function() {
{ _id: 'run-migration', roles : ['admin'] },
{ _id: 'set-moderator', roles : ['admin', 'owner'] },
{ _id: 'set-owner', roles : ['admin', 'owner'] },
{ _id: 'send-many-messages', roles : ['admin', 'bot'] },
{ _id: 'unarchive-room', roles : ['admin'] },
{ _id: 'view-c-room', roles : ['admin', 'user', 'bot', 'anonymous'] },
{ _id: 'user-generate-access-token', roles : ['admin'] },
Expand Down
4 changes: 3 additions & 1 deletion packages/rocketchat-cas/cas_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ Meteor.loginWithCas = function(options, callback) {
}

const appUrl = Meteor.absoluteUrl().replace(/\/$/, '') + __meteor_runtime_config__.ROOT_URL_PATH_PREFIX;
const loginUrl = `${ login_url }?service=${ appUrl }/_cas/${ credentialToken }`;
// check if the provided CAS URL already has some parameters
const delim = (login_url.split('?').length > 1) ? '&' : '?';
const loginUrl = `${ login_url }${ delim }service=${ appUrl }/_cas/${ credentialToken }`;

const popup = openCenteredPopup(
loginUrl,
Expand Down
6 changes: 3 additions & 3 deletions packages/rocketchat-cors/cors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}

Expand All @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-custom-sounds/admin/soundEdit.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h3>{{_ "Custom_Sound_Add"}}</h3>
</div>
<div class="input-line">
<label for="image">{{_ "Sound_File_mp3"}}</label>
<input id="image" type="file" accept="audio/mp3"/>
<input id="image" type="file" accept="audio/mp3,audio/mpeg"/>
</div>
<nav>
<button class='button button-block cancel' type="button"><span>{{_ "Cancel"}}</span></button>
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-emoji-custom/client/lib/emojiCustom.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* globals getEmojiUrlFromName:true, updateEmojiCustom:true, deleteEmojiCustom:true, isSetNotNull */
RocketChat.emoji.packages.emojiCustom = {
emojiCategories: { rocket: TAPi18n.__('Custom') },
emojiCategories: { rocket: 'Custom' },
toneList: {},
list: [],

Expand Down
16 changes: 8 additions & 8 deletions packages/rocketchat-emoji-emojione/emojiPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* Mapping category hashes into human readable and translated names
*/
emojiCategories = {
people: TAPi18n.__('Smileys_and_People'),
nature: TAPi18n.__('Animals_and_Nature'),
food: TAPi18n.__('Food_and_Drink'),
activity: TAPi18n.__('Activity'),
travel: TAPi18n.__('Travel_and_Places'),
objects: TAPi18n.__('Objects'),
symbols: TAPi18n.__('Symbols'),
flags: TAPi18n.__('Flags')
people: 'Smileys_and_People',
nature: 'Animals_and_Nature',
food: 'Food_and_Drink',
activity: 'Activity',
travel: 'Travel_and_Places',
objects: 'Objects',
symbols: 'Symbols',
flags: 'Flags'
};

toneList = {
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-emoji/emojiPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ function categoryName(category) {
for (const emojiPackage in RocketChat.emoji.packages) {
if (RocketChat.emoji.packages.hasOwnProperty(emojiPackage)) {
if (RocketChat.emoji.packages[emojiPackage].emojiCategories.hasOwnProperty(category)) {
return RocketChat.emoji.packages[emojiPackage].emojiCategories[category];
const categoryTag = RocketChat.emoji.packages[emojiPackage].emojiCategories[category];
return TAPi18n.__(categoryTag);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-emoji/rocketchat.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
RocketChat.emoji = {
packages: {
base: {
emojiCategories: { recent: TAPi18n.__('Frequently_Used') },
emojiCategories: { recent: 'Frequently_Used' },
emojisByCategory: {
recent: []
},
Expand Down
11 changes: 9 additions & 2 deletions packages/rocketchat-file-upload/server/config/AmazonS3.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ const configure = _.debounce(function() {
const AWSSecretAccessKey = RocketChat.settings.get('FileUpload_S3_AWSSecretAccessKey');
const URLExpiryTimeSpan = RocketChat.settings.get('FileUpload_S3_URLExpiryTimeSpan');
const Region = RocketChat.settings.get('FileUpload_S3_Region');
const SignatureVersion = RocketChat.settings.get('FileUpload_S3_SignatureVersion');
const ForcePathStyle = RocketChat.settings.get('FileUpload_S3_ForcePathStyle');
// const CDN = RocketChat.settings.get('FileUpload_S3_CDN');
// const BucketURL = RocketChat.settings.get('FileUpload_S3_BucketURL');
const BucketURL = RocketChat.settings.get('FileUpload_S3_BucketURL');

if (!Bucket || !AWSAccessKeyId || !AWSSecretAccessKey) {
return;
Expand All @@ -43,7 +45,8 @@ const configure = _.debounce(function() {
connection: {
accessKeyId: AWSAccessKeyId,
secretAccessKey: AWSSecretAccessKey,
signatureVersion: 'v4',
signatureVersion: SignatureVersion,
s3ForcePathStyle: ForcePathStyle,
params: {
Bucket,
ACL: Acl
Expand All @@ -53,6 +56,10 @@ const configure = _.debounce(function() {
URLExpiryTimeSpan
};

if (BucketURL) {
config.connection.endpoint = BucketURL;
}

AmazonS3Uploads.store = FileUpload.configureUploadsStore('AmazonS3', AmazonS3Uploads.name, config);
AmazonS3Avatars.store = FileUpload.configureUploadsStore('AmazonS3', AmazonS3Avatars.name, config);
}, 500);
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-file-upload/server/lib/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
14 changes: 14 additions & 0 deletions packages/rocketchat-file-upload/server/startup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ RocketChat.settings.addGroup('FileUpload', function() {
},
i18nDescription: 'Override_URL_to_which_files_are_uploaded_This_url_also_used_for_downloads_unless_a_CDN_is_given.'
});
this.add('FileUpload_S3_SignatureVersion', 'v4', {
type: 'string',
enableQuery: {
_id: 'FileUpload_Storage_Type',
value: 'AmazonS3'
}
});
this.add('FileUpload_S3_ForcePathStyle', false, {
type: 'boolean',
enableQuery: {
_id: 'FileUpload_Storage_Type',
value: 'AmazonS3'
}
});
this.add('FileUpload_S3_URLExpiryTimeSpan', 120, {
type: 'int',
enableQuery: {
Expand Down
11 changes: 7 additions & 4 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,12 @@
"FileUpload_MediaTypeWhiteListDescription": "Comma-separated list of media types. Leave it blank for accepting all media types.",
"FileUpload_ProtectFiles": "Protect uploaded files",
"FileUpload_ProtectFilesDescription": "Only authenticated users will have access",
"FileUpload_S3_Acl": "Amazon S3 acl",
"FileUpload_S3_AWSAccessKeyId": "Amazon S3 AWSAccessKeyId",
"FileUpload_S3_AWSSecretAccessKey": "Amazon S3 AWSSecretAccessKey",
"FileUpload_S3_Bucket": "Amazon S3 bucket name",
"FileUpload_S3_Acl": "Acl",
"FileUpload_S3_AWSAccessKeyId": "Access Key",
"FileUpload_S3_AWSSecretAccessKey": "Secret Key",
"FileUpload_S3_Bucket": "Bucket name",
"FileUpload_S3_SignatureVersion": "Signature Version",
"FileUpload_S3_ForcePathStyle": "Force Path Style",
"FileUpload_S3_BucketURL": "Bucket URL",
"FileUpload_S3_CDN": "CDN domain for downloads",
"FileUpload_S3_Region": "Region",
Expand Down Expand Up @@ -1676,6 +1678,7 @@
"Two-factor_authentication_disabled": "Two-factor authentication disabled",
"Two-factor_authentication_enabled": "Two-factor authentication enabled",
"Two-factor_authentication_is_currently_disabled": "Two-factor authentication is currently disabled",
"Two-factor_authentication_native_mobile_app_warning" : "WARNING: Once you enable this, you will not be able to login on the native mobile apps (Rocket.Chat+) using your password until they implement the 2FA.",
"Thursday": "Thursday",
"Time_in_seconds": "Time in seconds",
"Title": "Title",
Expand Down
12 changes: 7 additions & 5 deletions packages/rocketchat-importer-slack/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ Importer.Slack = class extends Importer.Base {
RocketChat.models.Messages.createUserJoinWithRoomIdAndUser(room._id, this.getRocketUser(message.user), msgDataDefaults);
}
} else if (message.subtype === 'channel_leave') {
if (this.getRocketUser(message.user)) { RocketChat.models.Messages.createUserLeaveWithRoomIdAndUser(room._id, this.getRocketUser(message.user), msgDataDefaults); }
if (this.getRocketUser(message.user)) {
RocketChat.models.Messages.createUserLeaveWithRoomIdAndUser(room._id, this.getRocketUser(message.user), msgDataDefaults);
}
} else if (message.subtype === 'me_message') {
const msgObj = {
...msgDataDefaults,
Expand Down Expand Up @@ -288,15 +290,15 @@ Importer.Slack = class extends Importer.Base {
if (this.getRocketUser(message.user)) {
RocketChat.models.Messages.createRoomSettingsChangedWithTypeRoomIdMessageAndUser('room_changed_description', room._id, message.purpose, this.getRocketUser(message.user), msgDataDefaults);
}
} else if (message.subtype === 'channel_topic') {
} else if (message.subtype === 'channel_topic') {
if (this.getRocketUser(message.user)) {
RocketChat.models.Messages.createRoomSettingsChangedWithTypeRoomIdMessageAndUser('room_changed_topic', room._id, message.topic, this.getRocketUser(message.user), msgDataDefaults);
}
} else if (message.subtype === 'channel_name') {
} else if (message.subtype === 'channel_name') {
if (this.getRocketUser(message.user)) {
RocketChat.models.Messages.createRoomRenamedWithRoomIdRoomNameAndUser(room._id, message.name, this.getRocketUser(message.user), msgDataDefaults);
}
} else if (message.subtype === 'pinned_item') {
} else if (message.subtype === 'pinned_item') {
if (message.attachments) {
const msgObj = {
...msgDataDefaults,
Expand All @@ -323,7 +325,7 @@ Importer.Slack = class extends Importer.Base {
};
this.uploadFile(details, message.file.url_private_download, this.getRocketUser(message.user), room, new Date(parseInt(message.ts.split('.')[0]) * 1000));
}
} else if (!missedTypes[message.subtype] && !ignoreTypes[message.subtype]) {
} else if (!missedTypes[message.subtype] && !ignoreTypes[message.subtype]) {
missedTypes[message.subtype] = message;
}
} else {
Expand Down
123 changes: 66 additions & 57 deletions packages/rocketchat-importer/server/classes/ImporterBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
// getProgress: =>
// #return the progress report, tbd what is expected
// @version 1.0.0
import http from 'http';
import https from 'https';
import AdmZip from 'adm-zip';
import getFileType from 'file-type';

Importer.Base = class Base {
static getBSONSize(object) {
// The max BSON object size we can store in MongoDB is 16777216 bytes
Expand Down Expand Up @@ -41,11 +46,12 @@ Importer.Base = class Base {
// @param [String] mimeType the of the expected file type
//
constructor(name, description, mimeType) {
this.MaxBSONSize = 8000000;
this.http = Npm.require('http');
this.https = Npm.require('https');

this.http = http;
this.https = https;
this.AdmZip = AdmZip;
this.getFileType = getFileType;

this.MaxBSONSize = 8000000;
this.prepare = this.prepare.bind(this);
this.startImport = this.startImport.bind(this);
this.getSelection = this.getSelection.bind(this);
Expand All @@ -61,8 +67,6 @@ Importer.Base = class Base {
this.logger = new Logger(`${ this.name } Importer`, {});
this.progress = new Importer.Progress(this.name);
this.collection = Importer.RawImports;
this.AdmZip = Npm.require('adm-zip');
this.getFileType = Npm.require('file-type');
const importId = Importer.Imports.insert({ 'type': this.name, 'ts': Date.now(), 'status': this.progress.step, 'valid': true, 'user': Meteor.user()._id });
this.importRecord = Importer.Imports.findOne(importId);
this.users = {};
Expand Down Expand Up @@ -187,58 +191,63 @@ Importer.Base = class Base {
//
uploadFile(details, fileUrl, user, room, timeStamp) {
this.logger.debug(`Uploading the file ${ details.name } from ${ fileUrl }.`);
const requestModule = /https/i.test(fileUrl) ? Importer.Base.https : Importer.Base.http;

return requestModule.get(fileUrl, Meteor.bindEnvironment(function(stream) {
const fileStore = FileUpload.getStore('Uploads');
fileStore.insert(details, stream, function(err, file) {
if (err) {
throw new Error(err);
} else {
const url = file.url.replace(Meteor.absoluteUrl(), '/');

const attachment = {
title: file.name,
title_link: url
};

if (/^image\/.+/.test(file.type)) {
attachment.image_url = url;
attachment.image_type = file.type;
attachment.image_size = file.size;
attachment.image_dimensions = file.identify != null ? file.identify.size : undefined;
}

if (/^audio\/.+/.test(file.type)) {
attachment.audio_url = url;
attachment.audio_type = file.type;
attachment.audio_size = file.size;
const requestModule = /https/i.test(fileUrl) ? this.https : this.http;

const fileStore = FileUpload.getStore('Uploads');

return requestModule.get(fileUrl, Meteor.bindEnvironment(function(res) {
const rawData = [];
res.on('data', chunk => rawData.push(chunk));
res.on('end', Meteor.bindEnvironment(() => {
fileStore.insert(details, Buffer.concat(rawData), function(err, file) {
if (err) {
throw new Error(err);
} else {
const url = file.url.replace(Meteor.absoluteUrl(), '/');

const attachment = {
title: file.name,
title_link: url
};

if (/^image\/.+/.test(file.type)) {
attachment.image_url = url;
attachment.image_type = file.type;
attachment.image_size = file.size;
attachment.image_dimensions = file.identify != null ? file.identify.size : undefined;
}

if (/^audio\/.+/.test(file.type)) {
attachment.audio_url = url;
attachment.audio_type = file.type;
attachment.audio_size = file.size;
}

if (/^video\/.+/.test(file.type)) {
attachment.video_url = url;
attachment.video_type = file.type;
attachment.video_size = file.size;
}

const msg = {
rid: details.rid,
ts: timeStamp,
msg: '',
file: {
_id: file._id
},
groupable: false,
attachments: [attachment]
};

if ((details.message_id != null) && (typeof details.message_id === 'string')) {
msg['_id'] = details.message_id;
}

return RocketChat.sendMessage(user, msg, room, true);
}

if (/^video\/.+/.test(file.type)) {
attachment.video_url = url;
attachment.video_type = file.type;
attachment.video_size = file.size;
}

const msg = {
rid: details.rid,
ts: timeStamp,
msg: '',
file: {
_id: file._id
},
groupable: false,
attachments: [attachment]
};

if ((details.message_id != null) && (typeof details.message_id === 'string')) {
msg['_id'] = details.message_id;
}

return RocketChat.sendMessage(user, msg, room, true);
}
});
});
}));
}));
}
};
Loading

0 comments on commit b560d3b

Please sign in to comment.