Closed huksley closed 1 year ago
I can see the payloads send in Chrome vs Firefox are different
have same problem
This may be a duplicate of https://github.com/KartikTalwar/gmail.js/issues/721
Line format for XHR seems to have changed slightly.
I decoded payload of msg I think it looks different from #721, not sure?
interface RequestBodyMail {
0: string; // messageId,
1: PayloadAddress; // from
2: PayloadAddress[]; // to
3: PayloadAddress[]; // cc
4: PayloadAddress[]; // bcc
6: number; // timestamp
7: string; // subject
8?: {
1?: {
0: number;
1: string; // body piece
}[];
}; // body structure
10: string[]; // smart labels
}
@huksley : If you can create a PR for the event-stuff, I'll be happy to review that and create another release.
I must admit that when it comes to the events themselves, I don't feel that confident in the parsing code as the email-parser (which I pretty much wrote from scratch myself).
@huksley are you trying to solve the problem?
Fixed, but need to have both code paths tested - I can't because my Firefox also started working with new APIs
Not seeing this feedback, I've created a patch which I think fixes this issue. That is now published as v1.1.2
on npmjs.
If you still think there's more work which needs to be done, please do let me know :smile:
@josteink perfect, it work!
Some users reports that older algorithm is back and older version of my extension works fine...
@josteink I see you've made your own changes, btw these might not work:
const sent_email_content_html = api.tools.parse_sent_message_html_payload(sent_email);
const sent_attachments = api.tools.parse_sent_message_attachments(sent_email["11"]);
Because HTML payload format and attachments in a different format now.
Some users reports that older algorithm is back and older version of my extension works fine...
Google please make up your mind 😮
I think it is a rollout algorithm or something..
@josteink I see you've made your own changes, btw these might now work:
const sent_email_content_html = api.tools.parse_sent_message_html_payload(sent_email); const sent_attachments = api.tools.parse_sent_message_attachments(sent_email["11"]);
Because HTML payload format and attachments in a different format now.
Do you mean may NOT work?
If so, PRs for getting them fixed are welcome 😉
Released v1.1.3 with @huksley's fixes too.
@josteink is it work for both format?
Only for new formats.
I would think we need to support both versions for now.
Then we should probably introduce some parser class/interface to do the parsing to clean up the code somewhat.
Something like this?
interface IGmailParser {
canParse(obj): boolean;
parse(obj): array;
}
The code we have now is starting to have a somewhat desperate need for at least a minimal amount of architecture.
As for both versions… are you talking about the events only? Or also the data APIs?
I added the is_email_new()
condition, and it triggers old and new parser as needed. But since older code also checks now for new email format, it probably will not work with older APIs...
Then we should probably introduce some parser class/interface to do the parsing to clean up the code somewhat.
I would think there should be a parsers (or handlers) for different functionality of Gmail, versioned. And users can provide flags which enable (or disable specific handlers) - this will be perfect for MW3 and future versions.
interface GmailHandler {
enable(gmail: GmailJS): void
}
// Parses properly when you press Send in compose window (new format of send payloads)
class GmailSendPayloadHandler20220913 extends GmailHandler {
}
enabled = ["GmailNewHandler"]
handlers = [new GmailNewHandler(), new GmailSendPayloadHandler20220913()].filter(h => enabled.includes(h.constructor.name)
handlers.forEach(handler => handler.enable(this))
Hello! It seems that parse_sent_message_payload
is fixed as well now, and parse_sent_message_payload_new
has incorrect subject
field index (should be 7, but there is 8).
I believe that parse_sent_message_payload_new
could be removed in favor of recently updated parse_sent_message_payload
.
UPD: just discovered that incorrect index was fixed in #726. 🙂 But I still think that removing duplicated code is good, as long as parse_send_message_payload
was fixed in 9d4ff11327df06363df3576c12368d4e762b7017.
It is still something to be confirmed, but I can see that both
send_message
andsend_scheduled_message
does not work anymore.These hooks are now never triggered:
Browser differences
I can see there is different parameters passed in URL - Chrome v105
Firefox v104
I am trying to investigate if it is payload or something...