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

[FIX] user/agent upload not working via Apps Engine after 3.16.0 #23393

Merged
merged 2 commits into from
Oct 8, 2021
Merged
Changes from 1 commit
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
21 changes: 11 additions & 10 deletions app/apps/server/bridges/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IUploadDetails } from '@rocket.chat/apps-engine/definition/uploads/IUpl
import { FileUpload } from '../../../file-upload/server';
import { determineFileType } from '../../lib/misc/determineFileType';
import { AppServerOrchestrator } from '../orchestrator';
import { SystemLogger } from '../../../../server/lib/logger/system';


const getUploadDetails = (details: IUploadDetails): Partial<IUploadDetails> => {
Expand Down Expand Up @@ -56,17 +57,17 @@ 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, () => {
SystemLogger.debug({ msg: 'App bridge is trying to upload the file.', details });
murtaza98 marked this conversation as resolved.
Show resolved Hide resolved
Meteor.runAsUser(details.userId, () => {
const uploadedFile = fileStore.insertSync(getUploadDetails(details), buffer);
SystemLogger.debug({ msg: 'App bridge has successfully uploaded the file', uploadedFile });
murtaza98 marked this conversation as resolved.
Show resolved Hide resolved
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);
}
Expand Down