sending the received data to thunderai-sparks. see #182
This commit is contained in:
parent
fc250b9529
commit
cf72ab1f0d
1 changed files with 25 additions and 4 deletions
|
|
@ -22,7 +22,7 @@ import { getPrompts } from './mzta-prompts.js';
|
||||||
import { getLanguageDisplayName, getMenuContextCompose, getMenuContextDisplay, i18nConditionalGet, getMailSubject, getTagsList, transformTagsLabels } from './mzta-utils.js'
|
import { getLanguageDisplayName, getMenuContextCompose, getMenuContextDisplay, i18nConditionalGet, getMailSubject, getTagsList, transformTagsLabels } from './mzta-utils.js'
|
||||||
import { taLogger } from './mzta-logger.js';
|
import { taLogger } from './mzta-logger.js';
|
||||||
import { placeholdersUtils } from './mzta-placeholders.js';
|
import { placeholdersUtils } from './mzta-placeholders.js';
|
||||||
import { mzta_specialCommand_AddTags } from './special_commands/mzta-add-tags.js';
|
import { mzta_specialCommand } from './mzta-special-commands.js';
|
||||||
|
|
||||||
export class mzta_Menus {
|
export class mzta_Menus {
|
||||||
|
|
||||||
|
|
@ -230,7 +230,7 @@ export class mzta_Menus {
|
||||||
// TODO: use the current API, abort if using chatgpt web
|
// TODO: use the current API, abort if using chatgpt web
|
||||||
// COMMENTED TO DO TESTS
|
// COMMENTED TO DO TESTS
|
||||||
// tags_current_email = "recipients, TEST, home, work, CAR, light";
|
// tags_current_email = "recipients, TEST, home, work, CAR, light";
|
||||||
let cmd_addTags = new mzta_specialCommand_AddTags(fullPrompt,prefs_at.connection_type,true);
|
let cmd_addTags = new mzta_specialCommand(fullPrompt,prefs_at.connection_type,true);
|
||||||
await cmd_addTags.initWorker();
|
await cmd_addTags.initWorker();
|
||||||
try{
|
try{
|
||||||
tags_current_email = await cmd_addTags.sendPrompt();
|
tags_current_email = await cmd_addTags.sendPrompt();
|
||||||
|
|
@ -246,13 +246,34 @@ export class mzta_Menus {
|
||||||
return {ok:'1'};
|
return {ok:'1'};
|
||||||
break; // Add tags to the email - END
|
break; // Add tags to the email - END
|
||||||
}
|
}
|
||||||
case 'get_calendar_event': { // Get a calendar event info
|
case 'prompt_get_calendar_event': { // Get a calendar event info
|
||||||
|
let calendar_event_data = '';
|
||||||
let prefs_at = await browser.storage.sync.get({connection_type: ''});
|
let prefs_at = await browser.storage.sync.get({connection_type: ''});
|
||||||
if((prefs_at.connection_type === '')||(prefs_at.connection_type === null)||(prefs_at.connection_type === undefined)||(prefs_at.connection_type === 'chatgpt_web')){
|
if((prefs_at.connection_type === '')||(prefs_at.connection_type === null)||(prefs_at.connection_type === undefined)||(prefs_at.connection_type === 'chatgpt_web')){
|
||||||
console.error("[ThunderAI | GetCalendarEvent] Invalid connection type: " + prefs_at.connection_type);
|
console.error("[ThunderAI | GetCalendarEvent] Invalid connection type: " + prefs_at.connection_type);
|
||||||
return {ok:'0'};
|
return {ok:'0'};
|
||||||
}
|
}
|
||||||
//TODO
|
/* We expect to receive from the AI a JSON object like this:
|
||||||
|
* {
|
||||||
|
* "startDate": "20250104T183000Z",
|
||||||
|
* "endDate": "20250104T193000Z",
|
||||||
|
* "summary": "ThunderAI Sparks",
|
||||||
|
* "forceAllDay": false
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
this.logger.log("fullPrompt: " + fullPrompt);
|
||||||
|
let cmd_GetCalendarEvent = new mzta_specialCommand(fullPrompt,prefs_at.connection_type,true);
|
||||||
|
await cmd_GetCalendarEvent.initWorker();
|
||||||
|
try{
|
||||||
|
calendar_event_data = await cmd_GetCalendarEvent.sendPrompt();
|
||||||
|
console.log(">>>>>>>>>>> calendar_event_data: " + calendar_event_data);
|
||||||
|
}catch(err){
|
||||||
|
console.error("[ThunderAI] Error getting calendar event data: ", JSON.stringify(err));
|
||||||
|
browser.tabs.sendMessage(tabs[0].id, { command: "sendAlert", curr_tab_type: tabs[0].type, message: "Error getting calendar event data: " + JSON.stringify(err) });
|
||||||
|
return {ok:'0'};
|
||||||
|
}
|
||||||
|
this.logger.log("calendar_event_data: " + calendar_event_data);
|
||||||
|
browser.runtime.sendMessage('thunderai-sparks@micz.it',{action: "openCalendarEventDialog", calendar_event_data: calendar_event_data})
|
||||||
return {ok:'1'};
|
return {ok:'1'};
|
||||||
break; // Get a calendar event info - END
|
break; // Get a calendar event info - END
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue