@@ -19,17 +19,20 @@ const permissions = tcMiddleware.permissions;
19
19
* @returns {Array<Promise> } The array of two promises, first one if the attachment object promise,
20
20
* The second promise is for the file pre-signed url (if attachment type is file)
21
21
*/
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
23
24
if ( attachment . type === ATTACHMENT_TYPES . LINK ) {
24
- // If the attachment is a link return it as-is without getting the pre-signed url
25
25
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' ) {
29
31
return [ attachment , 'dummy://url' ] ;
30
32
}
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 ] ;
33
36
} ;
34
37
35
38
module . exports = [
0 commit comments