Skip to content

Commit

Permalink
fixed gmail api devel
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Jan 8, 2024
1 parent d771bad commit 6af8a4c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/api-client/gmail-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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();
}
}
Expand Down

0 comments on commit 6af8a4c

Please sign in to comment.