Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/server/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export const RocketChatAssets = new class {
});
}

const file = new Buffer(binaryContent, 'binary');
const file = Buffer.from(binaryContent, 'binary');
if (assets[asset].constraints.width || assets[asset].constraints.height) {
const dimensions = sizeOf(file);
if (assets[asset].constraints.width && assets[asset].constraints.width !== dimensions.width) {
Expand Down
2 changes: 1 addition & 1 deletion app/custom-sounds/server/methods/uploadCustomSound.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Meteor.methods({
throw new Meteor.Error('not_authorized');
}

const file = new Buffer(binaryContent, 'binary');
const file = Buffer.from(binaryContent, 'binary');

const rs = RocketChatFile.bufferToStream(file);
RocketChatFileCustomSoundsInstance.deleteFile(`${ soundData._id }.${ soundData.extension }`);
Expand Down
2 changes: 1 addition & 1 deletion app/emoji-custom/server/methods/uploadEmojiCustom.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Meteor.methods({
emojiData.name = limax(emojiData.name, { replacement: '_' });
// delete aliases for notification purposes. here, it is a string rather than an array
delete emojiData.aliases;
const file = new Buffer(binaryContent, 'binary');
const file = Buffer.from(binaryContent, 'binary');

const rs = RocketChatFile.bufferToStream(file);
RocketChatFileEmojiCustomInstance.deleteFile(encodeURIComponent(`${ emojiData.name }.${ emojiData.extension }`));
Expand Down
2 changes: 1 addition & 1 deletion app/importer-hipchat/server/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class HipChatImporter extends Base {
super.prepare(dataURI, sentContentType, fileName, skipTypeCheck);
const { image } = RocketChatFile.dataURIParse(dataURI);
// const contentType = ref.contentType;
const zip = new this.AdmZip(new Buffer(image, 'base64'));
const zip = new this.AdmZip(Buffer.from(image, 'base64'));
const zipEntries = zip.getEntries();
let tempRooms = [];
let tempUsers = [];
Expand Down
2 changes: 1 addition & 1 deletion app/importer-slack-users/server/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class SlackUsersImporter extends Base {

super.updateProgress(ProgressStep.PREPARING_USERS);
const uriResult = RocketChatFile.dataURIParse(dataURI);
const buf = new Buffer(uriResult.image, 'base64');
const buf = Buffer.from(uriResult.image, 'base64');
const parsed = this.csvParser(buf.toString());

parsed.forEach((user, index) => {
Expand Down
4 changes: 2 additions & 2 deletions app/importer/server/classes/ImporterBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class Base {
*/
prepareUsingLocalFile(fullFilePath) {
const file = fs.readFileSync(fullFilePath);
const buffer = Buffer.isBuffer(file) ? file : new Buffer(file);
const buffer = Buffer.isBuffer(file) ? file : Buffer.from(file);

const { contentType } = this.importRecord;
const fileName = this.importRecord.file;
Expand All @@ -163,7 +163,7 @@ export class Base {
prepare(dataURI, sentContentType, fileName, skipTypeCheck) {
this.collection.remove({});
if (!skipTypeCheck) {
const fileType = this.getFileType(new Buffer(dataURI.split(',')[1], 'base64'));
const fileType = this.getFileType(Buffer.from(dataURI.split(',')[1], 'base64'));
this.logger.debug('Uploaded file information is:', fileType);
this.logger.debug('Expected file type is:', this.info.mimeType);

Expand Down
2 changes: 1 addition & 1 deletion app/importer/server/methods/uploadImportFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Meteor.methods({
importer.instance.startFileUpload(newFileName, contentType);

// Save the file on the File Store
const file = new Buffer(binaryContent, 'base64');
const file = Buffer.from(binaryContent, 'base64');
const readStream = RocketChatFile.bufferToStream(file);
const writeStream = RocketChatImportFileInstance.createWriteStream(newFileName, contentType);

Expand Down
4 changes: 2 additions & 2 deletions app/irc/server/servers/RFC2813/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RFC2813 {
this.serverPrefix = null;

// Hold the buffer while receiving
this.receiveBuffer = new Buffer('');
this.receiveBuffer = Buffer.from('');
}

/**
Expand Down Expand Up @@ -136,7 +136,7 @@ class RFC2813 {
}

// Reset the buffer
this.receiveBuffer = new Buffer('');
this.receiveBuffer = Buffer.from('');

lines.forEach((line) => {
if (line.length && !line.startsWith('\a')) {
Expand Down
4 changes: 2 additions & 2 deletions app/ldap/server/ldap.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,14 @@ export default class LDAP {
if (attribute) {
filter = new this.ldapjs.filters.EqualityFilter({
attribute,
value: new Buffer(id, 'hex'),
value: Buffer.from(id, 'hex'),
});
} else {
const filters = [];
Unique_Identifier_Field.forEach((item) => {
filters.push(new this.ldapjs.filters.EqualityFilter({
attribute: item,
value: new Buffer(id, 'hex'),
value: Buffer.from(id, 'hex'),
}));
});

Expand Down
2 changes: 1 addition & 1 deletion app/lib/server/functions/setUserAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const setUserAvatar = function(user, dataURI, contentType, service) {
contentType = fileData.contentType;
}

const buffer = new Buffer(image, encoding);
const buffer = Buffer.from(image, encoding);
const fileStore = FileUpload.getStore('Avatars');
fileStore.deleteByName(user.username);

Expand Down
2 changes: 1 addition & 1 deletion app/meteor-accounts-saml/server/lib/ServiceProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class SAMLServiceProvider {
}

public validateResponse(samlResponse: string, callback: IResponseValidateCallback): void {
const xml = new Buffer(samlResponse, 'base64').toString('utf8');
const xml = Buffer.from(samlResponse, 'base64').toString('utf8');

const parser = new ResponseParser(this.serviceProviderOptions);
return parser.validate(xml, callback);
Expand Down
2 changes: 1 addition & 1 deletion app/meteor-accounts-saml/server/lib/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class SAMLUtils {
}

public static inflateXml(base64Data: string, successCallback: (xml: string) => void, errorCallback: (err: string | object | null) => void): void {
const buffer = new Buffer(base64Data, 'base64');
const buffer = Buffer.from(base64Data, 'base64');
zlib.inflateRaw(buffer, (err, decoded) => {
if (err) {
this.log(`Error while inflating. ${ err }`);
Expand Down
2 changes: 1 addition & 1 deletion app/webdav/server/methods/uploadFileToWebdav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Meteor.methods({
}

const uploadFolder = 'Rocket.Chat Uploads/';
const buffer = new Buffer(fileData);
const buffer = Buffer.from(fileData);

try {
const cred = getWebdavCredentials(account);
Expand Down
2 changes: 1 addition & 1 deletion server/routes/avatar/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const serveAvatar = (avatar, format, res) => {

if (['png', 'jpg', 'jpeg'].includes(format)) {
res.setHeader('Content-Type', `image/${ format }`);
sharp(new Buffer(avatar))
sharp(Buffer.from(avatar))
.toFormat(format)
.pipe(res);
return;
Expand Down
2 changes: 1 addition & 1 deletion server/startup/migrations/v002.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Migrations.add({
const dataURI = avatars[service].blob;
const { image, contentType } = RocketChatFile.dataURIParse(dataURI);

const rs = RocketChatFile.bufferToStream(new Buffer(image, 'base64'));
const rs = RocketChatFile.bufferToStream(Buffer.from(image, 'base64'));
const fileStore = FileUpload.getStore('Avatars');
fileStore.deleteByName(user.username);

Expand Down