diff --git a/_locales/en/messages.json b/_locales/en/messages.json index b02f8c67..1117df79 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1143,6 +1143,10 @@ "message": "Default language as defined in ThunderAI options.", "description": "" }, + "placeholder_mail_attachments_info": { + "message": "Information about the attachments in the email", + "description": "" + }, "empty": { "message": "This placeholder doesn't add any text, but it prevents the email body from being automatically appended at the end of the prompt.", "description": "" diff --git a/js/mzta-placeholders.js b/js/mzta-placeholders.js index 7d056680..9422f584 100644 --- a/js/mzta-placeholders.js +++ b/js/mzta-placeholders.js @@ -221,6 +221,14 @@ const defaultPlaceholders = [ is_default: "1", enabled: 1, }, + { + id: 'mail_attachments_info', + name: "__MSG_placeholder_mail_attachments_info__", + default_value: "", + type: 1, + is_default: "1", + enabled: 1, + } ]; @@ -460,6 +468,16 @@ export const placeholdersUtils = { let prefs_def_lang = await browser.storage.sync.get({default_chatgpt_lang: ''}); finalSubs['thunderai_def_lang'] = placeholdersUtils.failSafePlaceholders(prefs_def_lang.default_chatgpt_lang); break; + case 'mail_attachments_info': + let attachments_info_string = ""; + let attachments_info = await browser.messages.listAttachments(curr_message.id); + if(attachments_info && attachments_info.length > 0){ + attachments_info_string = attachments_info.map(att => "\"" + att.name + "\" [" + att.contentType + "] (" + Math.round(att.size / 1024) + " KB)").join("\n"); + } + attachments_info_string = attachments_info_string.trimEnd(); + finalSubs['mail_attachments_info'] = placeholdersUtils.failSafePlaceholders(attachments_info_string); + // console.log(">>>>>>>>>> mail_attachments_info: " + finalSubs['mail_attachments_info']); + break; case 'empty': finalSubs['empty'] = ''; break;