Skip to content

Commit

Permalink
Merge pull request #9711 from RocketChat/remove-gm
Browse files Browse the repository at this point in the history
[BREAK] Remove Graphics/Image Magick support
  • Loading branch information
rodrigok committed Feb 14, 2018
2 parents d85a34b + a655a98 commit a0cb3ab
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 118 deletions.
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

0 comments on commit a0cb3ab

Please sign in to comment.