KartikTalwar / gmail.js

Gmail JavaScript API
MIT License
3.74k stars 455 forks source link

the value of subject in the data passed into processSend is not correct #725

Closed cancan101 closed 1 year ago

cancan101 commented 1 year ago

I had to use:

const bodyData = JSON.parse(body);
const emailSubject = bodyData[1]?.[0]?.[0]?.[1]?.[1]?.[13]?.[0]?.[7];

It looks like the current path being returned is: [1][0][0][1][1][2][0][4][0][8] which is from: https://github.com/huksley/gmail-js/blob/79a18883343a55002f9010bca4dbca02d3349297/src/gmail.js#L1790

It looks like the subject line is contained in the parent object to what is passed to parse_sent_message_payload_new.

josteink commented 1 year ago

But what version are you using now?

cancan101 commented 1 year ago

1.1.3

josteink commented 1 year ago

I hate to be the guy who shrugs this off as "works on my machine", but I currently can't see any runtime-errors in my extension.

Can you still reproduce this?

josteink commented 1 year ago

Ok, so I don't depend on this property myself, but I can see how this could be annoying for those who does, and YES I can reproduce it.

Can you make a PR for this, and I will try to get it merged? :smile:

cancan101 commented 1 year ago

There isn't any runtime errors here. You get garbage if you try to read the subject:

  gmail.observe.after(
    'send_message',
    async function (url, body, data, response, xhr): Promise<void> {
      const subject = data.subject;
      console.log('send_message...', subject);
    }
  );