Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAK] Remove Graphics/Image Magick support #9711

Merged
merged 1 commit into from
Feb 14, 2018
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
122 changes: 70 additions & 52 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
"emailreplyparser": "^0.0.5",
"file-type": "^7.4.0",
"filesize": "3.5.11",
"gm": "1.23.1",
"gridfs-stream": "1.1.1",
"he": "1.1.1",
"highlight.js": "^9.12.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-file-upload/server/lib/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Object.assign(FileUpload, {
},

uploadsOnValidate(file) {
if (RocketChatFile.enabled === false || !/^image\/((x-windows-)?bmp|p?jpeg|png)$/.test(file.type)) {
if (!/^image\/((x-windows-)?bmp|p?jpeg|png)$/.test(file.type)) {
return;
}

Expand Down
65 changes: 1 addition & 64 deletions packages/rocketchat-file/file.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,13 @@ import stream from 'stream';
import fs from 'fs';
import path from 'path';
import mkdirp from 'mkdirp';
import gm from 'gm';
import {exec} from 'child_process';

// Fix problem with usernames being converted to object id
Grid.prototype.tryParseObjectId = function() {
return false;
};
//TODO: REMOVE RocketChatFile from globals
RocketChatFile = {
gm,
enabled: undefined,
enable() {
RocketChatFile.enabled = true;
return RocketChat.settings.updateOptionsById('Accounts_AvatarResize', {
alert: undefined
});
},
disable() {
RocketChatFile.enabled = false;
return RocketChat.settings.updateOptionsById('Accounts_AvatarResize', {
alert: 'The_image_resize_will_not_work_because_we_can_not_detect_ImageMagick_or_GraphicsMagick_installed_in_your_server'
});
}
};

const detectGM = function() {
return exec('gm version', Meteor.bindEnvironment(function(error, stdout) {
if ((error == null) && stdout.indexOf('GraphicsMagick') > -1) {
RocketChatFile.enable();
RocketChat.Info.GraphicsMagick = {
enabled: true,
version: stdout
};
} else {
RocketChat.Info.GraphicsMagick = {
enabled: false
};
}
return exec('convert -version', Meteor.bindEnvironment(function(error, stdout) {
if ((error == null) && stdout.indexOf('ImageMagick') > -1) {
if (RocketChatFile.enabled !== true) {
// Enable GM to work with ImageMagick if no GraphicsMagick
RocketChatFile.gm = RocketChatFile.gm.subClass({
imageMagick: true
});
RocketChatFile.enable();
}
return RocketChat.Info.ImageMagick = {
enabled: true,
version: stdout
};
} else {
if (RocketChatFile.enabled !== true) {
RocketChatFile.disable();
}
return RocketChat.Info.ImageMagick = {
enabled: false
};
}
}));
}));
};

detectGM();

Meteor.methods({
'detectGM'() {
detectGM();
}
});
RocketChatFile = {};

RocketChatFile.bufferToStream = function(buffer) {
const bufferStream = new stream.PassThrough();
Expand Down