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

ZMS-195 #773

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
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
31 changes: 31 additions & 0 deletions lib/api/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,28 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti
idate: Joi.date().description('Date string of receive time'),
intro: Joi.string().required().description('First 128 bytes of the message'),
attachments: booleanSchema.required().description('Does the message have attachments'),
attachmentsList: Joi.array()
.items(
Joi.object({
id: Joi.string().required().description('Attachment ID'),
hash: Joi.string().description('SHA-256 hash of the contents of the attachment'),
filename: Joi.string().required().description('Filename of the attachment'),
contentType: Joi.string().required().description('MIME type'),
disposition: Joi.string().required().description('Attachment disposition'),
transferEncoding: Joi.string()
.required()
.description(
'Which transfer encoding was used (actual content when fetching attachments is not encoded)'
),
related: booleanSchema
.required()
.description(
'Was this attachment found from a multipart/related node. This usually means that this is an embedded image'
),
sizeKb: Joi.number().required().description('Approximate size of the attachment in kilobytes')
})
)
.description('Attachments for the message'),
size: Joi.number().required().description('Message size in bytes'),
seen: booleanSchema.required().description('Is this message already seen or not'),
deleted: booleanSchema
Expand Down Expand Up @@ -525,10 +547,12 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti
msgid: true,
mailbox: true,
[result.value.metaData ? 'meta' : 'meta.from']: true,
'mimeTree.attachmentMap': true,
hdate: true,
idate: true,
subject: true,
ha: true,
attachments: true,
size: true,
intro: true,
unseen: true,
Expand Down Expand Up @@ -4036,6 +4060,13 @@ function formatMessageListing(messageData, includeHeaders) {
idate: messageData.idate ? messageData.idate.toISOString() : null,
intro: messageData.intro,
attachments: !!messageData.ha,
attachmentsList: (messageData.attachments || []).map(attachmentData => {
let hash = messageData.mimeTree && messageData.mimeTree.attachmentMap && messageData.mimeTree.attachmentMap[attachmentData.id];
if (!hash) {
return attachmentData;
}
return Object.assign({ hash: hash.toString('hex') }, attachmentData);
}),
size: messageData.size,
seen: !messageData.unseen,
deleted: !messageData.undeleted,
Expand Down