diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 4eb596ab..6927118e 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1123,6 +1123,10 @@ "message": "If checked, the AI will automatically add tags to newly received emails.", "description": "" }, + "prefs_OptionText_add_tags_auto_Info2": { + "message": "Choose which account to activate this feature for at the bottom of this page.", + "description": "" + }, "prefs_OptionText_add_tags_auto_force_existing": { "message": "Force existing tags when autotagging", "description": "" @@ -1350,5 +1354,17 @@ "ask_chatgptweb_permission_ok": { "message": "Permission granted. You can click here to close this tab and return to the main window.", "description": "" + }, + "AccountSelector_AutoTags": { + "message": "Choose the accounts where auto-tagging is enabled", + "description": "" + }, + "AccountSelector_AutoTags_infoline": { + "message": "Each change is saved immediately.", + "description": "" + }, + "AccountSelector_Spamfilter": { + "message": "Choose the accounts where the spam filter is enabled", + "description": "" } } \ No newline at end of file diff --git a/js/mzta-utils.js b/js/mzta-utils.js index e4514a18..b16099a0 100644 --- a/js/mzta-utils.js +++ b/js/mzta-utils.js @@ -43,6 +43,17 @@ function fixMsgHeader(msgHeader) { return msgHeader; } +export async function getAccountsList() { + let accounts = await browser.accounts.list(); + let accounts_array = []; + for (let account of accounts) { + let account_id = account.id; + let account_name = account.name; + accounts_array.push({id: account_id, name: account_name}); + } + return accounts_array; +} + export async function getCurrentIdentity(msgHeader, getFull = false) { let identities_array = []; let fallback_identity = ''; diff --git a/mzta-background.js b/mzta-background.js index deb9c72f..86b43752 100644 --- a/mzta-background.js +++ b/mzta-background.js @@ -845,6 +845,9 @@ const newEmailListener = (folder, messagesList) => { async function processEmails(messages, addTagsAuto, spamFilter) { taWorkingStatus.startWorking(); + + let prefs_aats = await browser.storage.sync.get({ add_tags_maxnum: prefs_default.add_tags_maxnum, connection_type: prefs_default.connection_type, add_tags_force_lang: prefs_default.add_tags_force_lang, default_chatgpt_lang: prefs_default.default_chatgpt_lang, add_tags_auto_force_existing: prefs_default.add_tags_auto_force_existing, add_tags_enabled_accounts: prefs_default.add_tags_enabled_accounts, spamfilter_enabled_accounts: prefs_default.spamfilter_enabled_accounts }); + for await (let message of messages) { let curr_fullMessage = null; let msg_text = null; @@ -857,12 +860,18 @@ async function processEmails(messages, addTagsAuto, spamFilter) { } if (addTagsAuto) { + if(prefs_aats.add_tags_enabled_accounts.length > 0){ + let accountId = message.folder.accountId; + if(!prefs_aats.add_tags_enabled_accounts.includes(accountId)){ + taLog.log("Account " + accountId + " not enabled for add_tags, skipping..."); + continue; + } + } let specialFullPrompt_add_tags = ''; let curr_prompt_add_tags = menus.allPrompts.find(p => p.id === 'prompt_add_tags'); let tags_full_list = await getTagsList(); let chatgpt_lang = await taPromptUtils.getDefaultLang(curr_prompt_add_tags); specialFullPrompt_add_tags = await taPromptUtils.preparePrompt(curr_prompt_add_tags, message, chatgpt_lang, '', body_text, curr_fullMessage.headers.subject, msg_text, '', tags_full_list); - let prefs_aat = await browser.storage.sync.get({ add_tags_maxnum: prefs_default.add_tags_maxnum, connection_type: prefs_default.connection_type, add_tags_force_lang: prefs_default.add_tags_force_lang, default_chatgpt_lang: prefs_default.default_chatgpt_lang, add_tags_auto_force_existing: prefs_default.add_tags_auto_force_existing }); specialFullPrompt_add_tags = taPromptUtils.finalizePrompt_add_tags(specialFullPrompt_add_tags, prefs_aat.add_tags_maxnum, prefs_aat.add_tags_force_lang, prefs_aat.default_chatgpt_lang); taLog.log("Special prompt: " + specialFullPrompt_add_tags); let cmd_addTags = new mzta_specialCommand(specialFullPrompt_add_tags, prefs_aat.connection_type, prefs_init.do_debug); @@ -879,6 +888,13 @@ async function processEmails(messages, addTagsAuto, spamFilter) { } if (spamFilter) { + if(prefs_aats.spamfilter_enabled_accounts.length > 0){ + let accountId = message.folder.accountId; + if(!prefs_aats.spamfilter_enabled_accounts.includes(accountId)){ + taLog.log("Account " + accountId + " not enabled for spamfilter, skipping..."); + continue; + } + } let curr_prompt_spamfilter = await getSpamFilterPrompt(); let chatgpt_lang = await taPromptUtils.getDefaultLang(curr_prompt_spamfilter); let specialFullPrompt_spamfilter = await taPromptUtils.preparePrompt(curr_prompt_spamfilter, message, chatgpt_lang, '', body_text, curr_fullMessage.headers.subject, msg_text, '', ''); diff --git a/options/mzta-options-default.js b/options/mzta-options-default.js index c4674218..501b0254 100644 --- a/options/mzta-options-default.js +++ b/options/mzta-options-default.js @@ -51,6 +51,7 @@ export const prefs_default = { add_tags_auto_force_existing: false, add_tags_auto_only_inbox: true, add_tags_context_menu: true, + add_tags_enabled_accounts: [], get_calendar_event: true, get_task: true, calendar_enforce_timezone: false, @@ -58,4 +59,5 @@ export const prefs_default = { spamfilter: false, spamfilter_threshold: 70, spamfilter_context_menu: true, + spamfilter_enabled_accounts: [], } \ No newline at end of file diff --git a/pages/addtags/mzta-add-tags.css b/pages/addtags/mzta-add-tags.css index 2899916f..fc254dc4 100644 --- a/pages/addtags/mzta-add-tags.css +++ b/pages/addtags/mzta-add-tags.css @@ -12,7 +12,7 @@ font-style: italic; } -#addtags_excl_list_container{ +#addtags_excl_list_container, #account_selector_container{ width: 90%; margin: 40px auto; } @@ -21,6 +21,22 @@ width: 30em; } +#account_selector_container{ + display: none; +} + +#account_selector_checkboxes{ + padding: 10px; + border: 1px solid gray; + width: 24em; + margin-bottom: 10px; + margin-top: 10px; +} + +.add_tags_auto{ + background-color: #e9ffdf; +} + .btn_div{ width: 100%; display: flex; @@ -129,4 +145,8 @@ table#miczPrefs tr:last-child td { .autocomplete-list li.active { background-color: #4c4e58; } + + .add_tags_auto{ + background-color: #415c35; + } } \ No newline at end of file diff --git a/pages/addtags/mzta-add-tags.html b/pages/addtags/mzta-add-tags.html index 9067132c..18f20d48 100644 --- a/pages/addtags/mzta-add-tags.html +++ b/pages/addtags/mzta-add-tags.html @@ -49,8 +49,9 @@ - - __MSG_prefs_OptionText_add_tags_auto__ + + __MSG_prefs_OptionText_add_tags_auto__ +
__MSG_prefs_OptionText_add_tags_auto_Info2__
- + __MSG_prefs_OptionText_add_tags_auto_force_existing__ - + __MSG_prefs_OptionText_add_tags_auto_only_inbox__