Skip to content

Commit

Permalink
Unify mime-type package configuration (#14217)
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan authored and ggazzo committed Apr 22, 2019
1 parent b8c0e6f commit 77fe8ac
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 18 deletions.
7 changes: 2 additions & 5 deletions app/assets/server/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
import { settings } from '../../settings';
import { Settings } from '../../models';
import { getURL } from '../../utils';
import { getURL } from '../../utils/lib/isURL';
import { mime } from '../../utils/lib/mimeTypes';
import { hasPermission } from '../../authorization';
import { RocketChatFile } from '../../file';
import { WebAppHashing } from 'meteor/webapp-hashing';
import { WebAppInternals } from 'meteor/webapp';
import _ from 'underscore';
import sizeOf from 'image-size';
import mime from 'mime-type/with-db';
import crypto from 'crypto';
import sharp from 'sharp';

mime.define('image/vnd.microsoft.icon', { extensions: ['ico'] }, mime.dupAppend);
mime.define('image/x-icon', { extensions: ['ico'] }, mime.dupAppend);

const RocketChatAssetsInstance = new RocketChatFile.GridFS({
name: 'assets',
});
Expand Down
2 changes: 1 addition & 1 deletion app/file-upload/server/lib/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Meteor } from 'meteor/meteor';
import fs from 'fs';
import stream from 'stream';
import streamBuffers from 'stream-buffers';
import mime from 'mime-type/with-db';
import Future from 'fibers/future';
import sharp from 'sharp';
import { Cookies } from 'meteor/ostrio:cookies';
Expand All @@ -16,6 +15,7 @@ import Avatars from '../../../models/server/models/Avatars';
import Users from '../../../models/server/models/Users';
import Rooms from '../../../models/server/models/Rooms';
import Settings from '../../../models/server/models/Settings';
import { mime } from '../../../utils/lib/mimeTypes';
import { roomTypes } from '../../../utils/server/lib/roomTypes';
import { hasPermission } from '../../../authorization/server/functions/hasPermission';
import { canAccessRoom } from '../../../authorization/server/functions/canAccessRoom';
Expand Down
2 changes: 1 addition & 1 deletion app/ui-account/client/avatar/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { settings } from '../../../settings';
import { callbacks } from '../../../callbacks';
import { SideNav } from '../../../ui-utils';
import { t } from '../../../utils';
import { mime } from '../../../utils/lib/mimeTypes';
import { fileUploadHandler } from '../../../file-upload';
import s from 'underscore.string';
import toastr from 'toastr';
import mime from 'mime-type/with-db';

Template.avatarPrompt.onCreated(function() {
const self = this;
Expand Down
2 changes: 1 addition & 1 deletion app/ui-message/client/startup/messageBoxActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import mime from 'mime-type/with-db';
import { VRecDialog } from '../../../ui-vrecord/client';
import { messageBox, modal } from '../../../ui-utils';
import { fileUpload } from '../../../ui';
import { settings } from '../../../settings';
import { t } from '../../../utils';
import { mime } from '../../../utils/lib/mimeTypes';

messageBox.actions.add('Create_new', 'Video_message', {
id: 'video-message',
Expand Down
2 changes: 1 addition & 1 deletion app/ui/client/lib/fileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const showUploadPreview = (file, callback) => {
const getAudioUploadPreview = (file, preview) => `\
<div class='upload-preview'>
<audio style="width: 100%;" controls="controls">
<source src="${ preview }" type="audio/wav">
<source src="${ preview }" type="${ file.file.type }">
Your browser does not support the audio element.
</audio>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/ui/client/views/app/room.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import _ from 'underscore';
import moment from 'moment';
import mime from 'mime-type/with-db';
import Clipboard from 'clipboard';

import { Meteor } from 'meteor/meteor';
Expand Down Expand Up @@ -36,6 +35,7 @@ import { lazyloadtick } from '../../../../lazy-load';
import { ChatMessages } from '../../lib/chatMessages';
import { fileUpload } from '../../lib/fileUpload';
import { isURL } from '../../../../utils/lib/isURL';
import { mime } from '../../../../utils/lib/mimeTypes';

export const chatMessages = {};

Expand Down
1 change: 1 addition & 0 deletions app/utils/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ export { placeholders } from '../lib/placeholders';
export { templateVarHandler } from '../lib/templateVarHandler';
export { APIClient } from './lib/RestApiClient';
export { canDeleteMessage } from './lib/canDeleteMessage';
export { mime } from '../lib/mimeTypes';
8 changes: 8 additions & 0 deletions app/utils/lib/mimeTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import mime from 'mime-type/with-db';

mime.types.wav = 'audio/wav';
mime.define('image/vnd.microsoft.icon', { extensions: ['ico'] }, mime.dupAppend);
mime.define('image/x-icon', { extensions: ['ico'] }, mime.dupAppend);
mime.types.ico = 'image/x-icon';

export { mime };
1 change: 1 addition & 0 deletions app/utils/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export { getValidRoomName } from '../lib/getValidRoomName';
export { placeholders } from '../lib/placeholders';
export { composeMessageObjectWithUser } from './lib/composeMessageObjectWithUser';
export { templateVarHandler } from '../lib/templateVarHandler';
export { mime } from '../lib/mimeTypes';
21 changes: 14 additions & 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
"mem": "4.1.0",
"merge-graphql-schemas": "^1.5.2",
"meteor-node-stubs": "^0.4.1",
"mime-db": "^1.37.0",
"mime-db": "^1.40.0",
"mime-type": "^3.0.7",
"mkdirp": "^0.5.1",
"moment": "^2.22.2",
Expand Down

0 comments on commit 77fe8ac

Please sign in to comment.