From 6af8a4ceda3a8ad8ef288d44f242465541054e05 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Mon, 8 Jan 2024 17:59:45 +0200 Subject: [PATCH] fixed gmail api devel --- lib/api-client/gmail-client.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/api-client/gmail-client.js b/lib/api-client/gmail-client.js index cf9214d1..0028dd0b 100644 --- a/lib/api-client/gmail-client.js +++ b/lib/api-client/gmail-client.js @@ -9,6 +9,8 @@ const util = require('util'); const addressparser = require('nodemailer/lib/addressparser'); const libmime = require('libmime'); +const fs = require('fs'); + const GMAIL_API_BASE = 'https://gmail.googleapis.com'; const LIST_BATCH_SIZE = 10; // how many listing requests to run at the same time @@ -535,13 +537,13 @@ let main = async () => { console.log(JSON.stringify(messages, false, 2)); for (let msg of messages) { if (msg.attachments && msg.attachments.length) { - let s = await gmailClient.getMessage(msg.id, { textType: '*' }); + await gmailClient.getMessage(msg.id, { textType: '*' }); let raw = await gmailClient.getRawMessage(msg.id); - await require('fs').promises.writeFile(`/Users/andris/Desktop/${msg.id}.eml`, raw); + await fs.promises.writeFile(`/Users/andris/Desktop/${msg.id}.eml`, raw); for (let a of msg.attachments) { let attachment = await gmailClient.getAttachmentContent(a.id); - await require('fs').promises.writeFile(`/Users/andris/Desktop/${a.filename}`, attachment); + await fs.promises.writeFile(`/Users/andris/Desktop/${a.filename}`, attachment); process.exit(); } }