@@ -19,17 +19,20 @@ const permissions = tcMiddleware.permissions;
1919 * @returns {Array<Promise> } The array of two promises, first one if the attachment object promise,
2020 * The second promise is for the file pre-signed url (if attachment type is file)
2121 */
22- const getPreSignedUrl = ( req , attachment ) => {
22+ const getPreSignedUrl = async ( req , attachment ) => {
23+ // If the attachment is a link return it as-is without getting the pre-signed url
2324 if ( attachment . type === ATTACHMENT_TYPES . LINK ) {
24- // If the attachment is a link return it as-is without getting the pre-signed url
2525 return [ attachment , '' ] ;
26- } // The attachment is a file
27- // In development/test mode, if file upload is disabled, we return the dummy attachment object
28- if ( _ . includes ( [ 'development' , 'test' ] , process . env . NODE_ENV ) && config . get ( 'enableFileUpload' ) === 'false' ) {
26+ }
27+
28+ // The attachment is a file
29+ // In development mode, if file upload is disabled, we return the dummy attachment object
30+ if ( _ . includes ( [ 'development' ] , process . env . NODE_ENV ) && config . get ( 'enableFileUpload' ) === 'false' ) {
2931 return [ attachment , 'dummy://url' ] ;
3032 }
31- // Not in development mode or file upload is not disabled
32- return [ attachment , util . getFileDownloadUrl ( req , attachment . path ) ] ;
33+ // Not in development mode or file upload is not disabled
34+ const url = await util . getFileDownloadUrl ( req , attachment . path ) ;
35+ return [ attachment , url ] ;
3336} ;
3437
3538module . exports = [
0 commit comments