feat: message and attachment download

Signed-off-by: Sebastian <krupinski01@gmail.com>
This commit is contained in:
2026-05-23 23:09:40 -04:00
parent cdff4d0d3f
commit b66ebbd078
4 changed files with 114 additions and 19 deletions

View File

@@ -633,6 +633,33 @@ export const useMailStore = defineStore('mailStore', () => {
}
}
async function downloadMessage(entity: EntityObject, index?: number) {
const target = entity.identifier
let part = null
if (index !== undefined) {
part = entity.properties.attachments?.[Number(index)] ?? null
}
try {
await entitiesStore.download(target, part)
} catch (error) {
const messageText = error instanceof Error
? error.message
: index === undefined
? 'Failed to download message'
: 'Failed to download attachment'
console.error(
index === undefined
? '[Mail][Operations] Failed to download message:'
: '[Mail][Operations] Failed to download attachment:',
error,
)
notify(messageText, 'error')
throw error
}
}
function notify(message: string, color: 'success' | 'error' | 'info' | 'warning' = 'success') {
showSnackbar({ message, color })
}
@@ -672,6 +699,7 @@ export const useMailStore = defineStore('mailStore', () => {
deleteMessages,
deleteFolder,
moveMessages,
downloadMessage,
moveFolder,
renameFolder,
notify,