diff --git a/app/apps/server/bridges/uploads.ts b/app/apps/server/bridges/uploads.ts index 27dcbbff3dd4..ab7d6bb2da14 100644 --- a/app/apps/server/bridges/uploads.ts +++ b/app/apps/server/bridges/uploads.ts @@ -7,7 +7,6 @@ import { FileUpload } from '../../../file-upload/server'; import { determineFileType } from '../../lib/misc/determineFileType'; import { AppServerOrchestrator } from '../orchestrator'; - const getUploadDetails = (details: IUploadDetails): Partial => { if (details.visitorToken) { const { userId, ...result } = details; @@ -56,17 +55,16 @@ export class AppUploadBridge extends UploadBridge { return new Promise(Meteor.bindEnvironment((resolve, reject) => { try { - const uploadedFile = fileStore.insertSync(getUploadDetails(details), buffer); - - if (details.visitorToken) { - Meteor.call('sendFileLivechatMessage', details.rid, details.visitorToken, uploadedFile); - } else { - Meteor.runAsUser(details.userId, () => { + Meteor.runAsUser(details.userId, () => { + const uploadedFile = fileStore.insertSync(getUploadDetails(details), buffer); + this.orch.debugLog(`The App ${ appId } has created an upload`, uploadedFile); + if (details.visitorToken) { + Meteor.call('sendFileLivechatMessage', details.rid, details.visitorToken, uploadedFile); + } else { Meteor.call('sendFileMessage', details.rid, null, uploadedFile); - }); - } - - resolve(this.orch.getConverters()?.get('uploads').convertToApp(uploadedFile)); + } + resolve(this.orch.getConverters()?.get('uploads').convertToApp(uploadedFile)); + }); } catch (err) { reject(err); }