@xuda.io/ai_module 1.1.4529 → 1.1.4531

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.mjs +8 -7
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4409,7 +4409,6 @@ const chat_note = async function (req, job_id, headers) {
4409
4409
  };
4410
4410
 
4411
4411
  const chat_email = async function (req, job_id, headers) {
4412
- debugger;
4413
4412
  const { uid, email_id, perform_ai_execution = true, from_mailbox } = req;
4414
4413
  const account_profile_info = await account_module.get_active_account_profile_info(uid);
4415
4414
  let { prompt: body, conversation_doc, attachments = [], ai_agents } = req;
@@ -4451,8 +4450,10 @@ const chat_email = async function (req, job_id, headers) {
4451
4450
  if (!sent_email_result.success) {
4452
4451
  throw new Error('error sending email');
4453
4452
  }
4454
- //// attachments
4455
- ///
4453
+ let email_attachments = [];
4454
+ for (const attachment of attachments) {
4455
+ email_attachments.push(await save_drive_file_to_disk(attachment));
4456
+ }
4456
4457
  }
4457
4458
 
4458
4459
  if (perform_ai_execution) {
@@ -7015,15 +7016,15 @@ const save_drive_file_to_disk = async function (drive_file) {
7015
7016
 
7016
7017
  const tempDir = os.tmpdir();
7017
7018
 
7018
- const tempInputPath = path.join(tempDir, drive_file.filename);
7019
+ const tempOutputPath = path.join(tempDir, drive_file.filename + '_' + Date.now());
7019
7020
 
7020
7021
  // 5. Write the downloaded image to disk
7021
- fs.writeFileSync(tempInputPath, imageBuffer);
7022
+ fs.writeFileSync(tempOutputPath, imageBuffer);
7022
7023
  /////////////////////////////////
7023
7024
 
7024
7025
  return {
7025
- filename: 'invoice.pdf',
7026
- path: '/tmp/attachments/invoice.pdf',
7026
+ filename: drive_file.filename,
7027
+ path: tempOutputPath,
7027
7028
  contentType: 'application/pdf',
7028
7029
  };
7029
7030
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4529",
3
+ "version": "1.1.4531",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",