The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/app/federation/server/endpoints/uploads.js

25 lines
671 B

import { API } from '../../../api/server';
import { Uploads } from '../../../models/server';
import { FileUpload } from '../../../file-upload/server';
import { isFederationEnabled } from '../lib/isFederationEnabled';
API.v1.addRoute('federation.uploads', { authRequired: false }, {
get() {
if (!isFederationEnabled()) {
return API.v1.failure('Federation not enabled');
}
const { upload_id } = this.requestParams();
const upload = Uploads.findOneById(upload_id);
if (!upload) {
return API.v1.failure('There is no such file in this server');
}
const buffer = FileUpload.getBufferSync(upload);
return API.v1.success({ upload, buffer });
},
});