@@ -392,6 +392,28 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti
392
392
idate : Joi . date ( ) . description ( 'Date string of receive time' ) ,
393
393
intro : Joi . string ( ) . required ( ) . description ( 'First 128 bytes of the message' ) ,
394
394
attachments : booleanSchema . required ( ) . description ( 'Does the message have attachments' ) ,
395
+ attachmentsList : Joi . array ( )
396
+ . items (
397
+ Joi . object ( {
398
+ id : Joi . string ( ) . required ( ) . description ( 'Attachment ID' ) ,
399
+ hash : Joi . string ( ) . description ( 'SHA-256 hash of the contents of the attachment' ) ,
400
+ filename : Joi . string ( ) . required ( ) . description ( 'Filename of the attachment' ) ,
401
+ contentType : Joi . string ( ) . required ( ) . description ( 'MIME type' ) ,
402
+ disposition : Joi . string ( ) . required ( ) . description ( 'Attachment disposition' ) ,
403
+ transferEncoding : Joi . string ( )
404
+ . required ( )
405
+ . description (
406
+ 'Which transfer encoding was used (actual content when fetching attachments is not encoded)'
407
+ ) ,
408
+ related : booleanSchema
409
+ . required ( )
410
+ . description (
411
+ 'Was this attachment found from a multipart/related node. This usually means that this is an embedded image'
412
+ ) ,
413
+ sizeKb : Joi . number ( ) . required ( ) . description ( 'Approximate size of the attachment in kilobytes' )
414
+ } )
415
+ )
416
+ . description ( 'Attachments for the message' ) ,
395
417
size : Joi . number ( ) . required ( ) . description ( 'Message size in bytes' ) ,
396
418
seen : booleanSchema . required ( ) . description ( 'Is this message already seen or not' ) ,
397
419
deleted : booleanSchema
@@ -525,10 +547,12 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti
525
547
msgid : true ,
526
548
mailbox : true ,
527
549
[ result . value . metaData ? 'meta' : 'meta.from' ] : true ,
550
+ 'mimeTree.attachmentMap' : true ,
528
551
hdate : true ,
529
552
idate : true ,
530
553
subject : true ,
531
554
ha : true ,
555
+ attachments : true ,
532
556
size : true ,
533
557
intro : true ,
534
558
unseen : true ,
@@ -4037,6 +4061,13 @@ function formatMessageListing(messageData, includeHeaders) {
4037
4061
idate : messageData . idate ? messageData . idate . toISOString ( ) : null ,
4038
4062
intro : messageData . intro ,
4039
4063
attachments : ! ! messageData . ha ,
4064
+ attachmentsList : ( messageData . attachments || [ ] ) . map ( attachmentData => {
4065
+ let hash = messageData . mimeTree && messageData . mimeTree . attachmentMap && messageData . mimeTree . attachmentMap [ attachmentData . id ] ;
4066
+ if ( ! hash ) {
4067
+ return attachmentData ;
4068
+ }
4069
+ return Object . assign ( { hash : hash . toString ( 'hex' ) } , attachmentData ) ;
4070
+ } ) ,
4040
4071
size : messageData . size ,
4041
4072
seen : ! messageData . unseen ,
4042
4073
deleted : ! messageData . undeleted ,
0 commit comments