parent
96cf382deb
commit
5fdd47dd62
5 changed files with 63 additions and 1 deletions
|
|
@ -758,5 +758,13 @@
|
|||
"prompt_add_tags_full_text": {
|
||||
"message": "Analyze the following email text and generate a comma-separated list of tags that summarize its content. Use themes, key topics, and relevant descriptors as tags. Ensure the tags are concise and relevant to the email's content.\nEmail text: {%mail_text_body%}\nConsider the following details for context:\n- Sender: {%author%}\n- Recipients: {%recipients%}\n- CC list: {%cc_list%}\n- Email subject: {%mail_subject%}\nPlease base your tags on the email's text and context, ignoring unnecessary information or trivial details.",
|
||||
"description": ""
|
||||
},
|
||||
"placeholder_mail_tags": {
|
||||
"message": "Mail tags",
|
||||
"description": ""
|
||||
},
|
||||
"placeholder_full_tags_list": {
|
||||
"message": "Existing tags",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
// Some original methods are derived from https://github.com/ali-raheem/Aify/blob/cfadf52f576b7be3720b5b73af7c8d3129c054da/plugin/html/actions.js
|
||||
|
||||
import { getPrompts } from './mzta-prompts.js';
|
||||
import { getLanguageDisplayName, getMenuContextCompose, getMenuContextDisplay, i18nConditionalGet, getMailSubject } from './mzta-utils.js'
|
||||
import { getLanguageDisplayName, getMenuContextCompose, getMenuContextDisplay, i18nConditionalGet, getMailSubject, getTagsList, transformTagsLabels } from './mzta-utils.js'
|
||||
import { taLogger } from './mzta-logger.js';
|
||||
import { placeholdersUtils } from './mzta-placeholders.js';
|
||||
import { mzta_specialCommand_AddTags } from './special_commands/mzta-add-tags.js';
|
||||
|
|
@ -115,6 +115,7 @@ export class mzta_Menus {
|
|||
}
|
||||
|
||||
let fullPrompt = '';
|
||||
let full_tags_list = await getTagsList();
|
||||
if(!placeholdersUtils.hasPlaceholder(curr_prompt.text)){
|
||||
// no placeholders, do as usual
|
||||
fullPrompt = curr_prompt.text + (String(curr_prompt.need_signature) == "1" ? " " + await this.getDefaultSignature():"") + " " + chatgpt_lang + " \"" + (selection_text=='' ? body_text : selection_text) + "\" ";
|
||||
|
|
@ -152,6 +153,13 @@ export class mzta_Menus {
|
|||
case 'junk_score':
|
||||
finalSubs['junk_score'] = curr_message.junkScore;
|
||||
break;
|
||||
case 'mail_tags':
|
||||
let mail_tags_array = await transformTagsLabels(curr_message.tags, full_tags_list[1]);
|
||||
finalSubs['mail_tags'] = mail_tags_array.join(", ");
|
||||
break;
|
||||
case 'full_tags_list':
|
||||
finalSubs['full_tags_list'] = full_tags_list[0];
|
||||
break;
|
||||
default: // TODO Manage custom placeholders https://github.com/micz/ThunderAI/issues/156
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,6 +96,20 @@ const defaultPlaceholders = [
|
|||
type: 0,
|
||||
is_default: "1",
|
||||
},
|
||||
{
|
||||
id: 'mail_tags',
|
||||
name: "__MSG_placeholder_mail_tags__",
|
||||
default_value: "",
|
||||
type: 0,
|
||||
is_default: "1",
|
||||
},
|
||||
{
|
||||
id: 'full_tags_list',
|
||||
name: "__MSG_placeholder_full_tags_list__",
|
||||
default_value: "",
|
||||
type: 0,
|
||||
is_default: "1",
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -176,6 +176,37 @@ export function generateCallID(length = 10) {
|
|||
return result;
|
||||
}
|
||||
|
||||
export async function getTagsList(){
|
||||
let messageTags = {};
|
||||
if(isThunderbird128OrGreater()) {
|
||||
messageTags = await browser.messages.tags.list();
|
||||
} else {
|
||||
messageTags = await browser.messages.listTags();
|
||||
}
|
||||
const output = messageTags.map(tag => tag.tag).join(', ');
|
||||
|
||||
const output2 = messageTags.reduce((acc, messageTag) => {
|
||||
acc[messageTag.key] = {
|
||||
tag: messageTag.tag,
|
||||
color: messageTag.color,
|
||||
key: messageTag.key,
|
||||
ordinal: messageTag.ordinal,
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return [output, output2]; // Return the list of tags and the list of tags objects as an array
|
||||
}
|
||||
|
||||
export async function transformTagsLabels(labels, tags_list) {
|
||||
console.log(">>>>>>>>> transformTagsLabels labels: " + labels);
|
||||
console.log(">>>>>>>>> transformTagsLabels tags_list: " + tags_list);
|
||||
let output = [];
|
||||
for(let label of labels) {
|
||||
output.push(tags_list[label].tag);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
// The following methods are a modified version derived from https://github.com/ali-raheem/Aify/blob/13ff87583bc520fb80f555ab90a90c5c9df797a7/plugin/content_scripts/compose.js
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
"activeTab",
|
||||
"accountsRead",
|
||||
"downloads",
|
||||
"messagesTagsList",
|
||||
"https://*.chatgpt.com/*"
|
||||
],
|
||||
"background": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue