Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Severe bug: On un-reading email, the event has the different mssageId instead the one actually it is. #17

Closed
vinodhreddygs opened this issue May 25, 2020 · 13 comments

Comments

@vinodhreddygs
Copy link

Hi @andris9 ,

Whenever I unread an email, the event which I get through webhooks has a different messageId.
Due to that, I can't able to get the content of the email on which actually update event is triggered.
Please let me know what is the reason for this. This is causing severe issues in my application.

Thanks in advance.

@andris9
Copy link
Collaborator

andris9 commented May 25, 2020

Are you using Gmail or Gsuite? You have to perform all changes against messages in the “All messages” folder, not in actual folders. It’s the same message but has different id’s depending from the folder you are using.

@vinodhreddygs
Copy link
Author

@andris9 I'am using Gmail.
How do I specify to get email from specific folder (i.e. All message) ?

This is the GET API to get the email information based on the messageID
/v1/account/{account}/message/{message} Where should I specify to retrieve message from specific folder?

@avdnick
Copy link

avdnick commented May 25, 2020

@vinodhreddygs Hi,
I think @andris9 means to use /v1/account/example/messages?path=INBOX and replace 'INBOX' with '[Gmail]/All Messages' to list the messages. And from there you get the messages you want to perfom a change.

@vinodhreddygs
Copy link
Author

@avdnick Oh. thanks for your reply. I do that.
And also I have one more question i.e, Whenever webhooks triggers, I can see all the data storing in the Redis. How can I clear the data on Redis?

@vinodhreddygs
Copy link
Author

messages?path=INBOX

Hi @andris9 @avdnick ,
/v1/account/example/messages?path=INBOX : this API is to get all the messages list from a particular folder as u mentioned like INBOX.
But there is one more API provided to get the specific email information based on the messageID i.e. /v1/account/{account}/message/{message} when I try to add qs syntax to this API i.e /v1/account/{account}/message/{message}?path=INBOX , its gives bad request error.
Then what is the use of /v1/account/{account}/message/{message} if we can't get a message by giving the messageID that we get on any event trigger?

@andris9
Copy link
Collaborator

andris9 commented May 26, 2020

If you are using Gmail and want to use webhooks then you need to perform all your processing via the "All Mail" folder, not INBOX.

You can see from the labels property for the list of folders this email belongs to. Labels property includes as list of special-use labels and folder name strings for normal folders. Eg {"labels": ["\\Inbox", "test"]} means that message can be found both in INBOX and in a folder named "test".

Gmail does not use the common one-folder/one-email model but one-email/multiple-folders and for each folder it has different id. The same message in different folders has the same emailId property but this is not the same as id.

@andris9
Copy link
Collaborator

andris9 commented May 26, 2020

If you do want to use INBOX instead of All Mail then you can match changes received via webhooks using the emailId property as this is always the same no matter what folder is used. emailId is not universal, it is only supported by a handful of servers (including Gmail), so you can not expect this property always to exist. It does not have a fixed format either. Gmail uses numbers but Yahoo uses strings. IMAP API casts this value always into a string.

@vinodhreddygs
Copy link
Author

If you are using Gmail and want to use webhooks then you need to perform all your processing via the "All Mail" folder, not INBOX.

You can see from the labels property for the list of folders this email belongs to. Labels property includes as list of special-use labels and folder name strings for normal folders. Eg {"labels": ["\\Inbox", "test"]} means that message can be found both in INBOX and in a folder named "test".

Gmail does not use the common one-folder/one-email model but one-email/multiple-folders and for each folder it has different id. The same message in different folders has the same emailId property but this is not the same as id.

@andris9 do you mean that I need to get the all the messages in the folder "All Mail' and then i need to filter the email which I want based on messageID?
Can't I get mail by messageID from "All Mail" folder using /v1/account/{account}/message/{message} or I should do any modification to this API?

@andris9
Copy link
Collaborator

andris9 commented May 26, 2020

You can use /v1/account/{account}/message/{message} (where {message} is data.id value from the webhook JSON) to fetch message data. But if you have previously fetched the same message from INBOX, then {message} is different (one is for the message form INBOX and the other is for the message in All Mail). In the end it's the same email, so for example marking message as seen using All Mail id marks the same message as seen in INBOX.

@vinodhreddygs
Copy link
Author

@andris9 All the message APIs that provided in the Swagger API docs will fetch/get messages or Attachments against the "All Mail" folder?
Please refer below screenshot:
image

@andris9
Copy link
Collaborator

andris9 commented May 26, 2020

{message} has folder path encoded into it, this is how IMAP API knows from which folder to look the message for. INBOX and All Mail are different folders and the same message has different UID value in these folder, so the same message can have multiple valid {message} values - one for each folder the message can be found in. The only thing that is consistent is emailId value but you can't use this for API calls.

@andris9
Copy link
Collaborator

andris9 commented May 26, 2020

So to answer your initial question, having different message id values is OK as message id value depends on the folder this message data was fetched from. Use emailId to match messages from IMAP API against your local copy.

@andris9 andris9 closed this as completed May 26, 2020
@vinodhreddygs
Copy link
Author

@andris9 on Flags update(i.e. On unread the mail), webhooks are not triggering, due to that I can't able to handle the events on flags update in my application.
Please let me know, is there any reason for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants