You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using RFC 5465 we can subscribe to notifications about new messages using command NOTIFY SET (selected (Messagenew {PREFETCH_FLAGS} messageexpunge)) like this:
? SELECT INBOX
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 38 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1697564012] UIDs valid
* OK [UIDNEXT 155] Predicted next UID
* OK [HIGHESTMODSEQ 294] Highest
? OK [READ-WRITE] Select completed (0.001 + 0.000 secs).
? NOTIFY SET (selected (Messagenew (UID INTERNALDATE RFC822.SIZE BODY.PEEK[HEADER.FIELDS (MESSAGE-ID X-MICROSOFT-ORIGINAL-MESSAGE-ID FROM IN-REPLY-TO REFERENCES CHAT-VERSION AUTOCRYPT-SETUP-MESSAGE)]) messageexpunge))
? OK NOTIFY completed (0.001 + 0.000 secs).
Later when a message arrives we will get a prefetch instantly without making a request for it
There is even no need to be in IDLE for that, but IDLE is still needed to get * OK Still here keepalives, so no need to change anything around the IDLE code paths.
To implement NOTIFY support, we need to:
Look for NOTIFY capability.
If NOTIFY is supported, enable it once after logging in for the folder we watch (either INBOX or DeltaChat). In the example I used "selected", but we better watch for the explicit folder name to avoid missing messages if we switch folders or close the current folder. Ideally we don't need to switch folders when using NOTIFY, but I would suggest not getting rid of scan_folders() right away and make NOTIFY working with minimal changes first.
Set up a data structure (a vector) inside the IMAP session to collect prefetches.
After enabling notify, prefetch once manually to make sure we don't miss any message from the time before enabling NOTIFY.
Process FETCH messages that we receive. Normally they will get into Session.unsolicited_responses() channel and we should process them when we read from it, but they may also accidentally be mistaken as a FETCH command response so we should also recognize such notify-prefetches whenever we read a FETCH command response.
Add a flag Config::DisableNotify similar to Config::DisableIdle and run some tests with it enabled to ensure we don't break compatibility with the servers not supporting NOTIFY.
The text was updated successfully, but these errors were encountered:
Using RFC 5465 we can subscribe to notifications about new messages using command
NOTIFY SET (selected (Messagenew {PREFETCH_FLAGS} messageexpunge))
like this:Later when a message arrives we will get a prefetch instantly without making a request for it
There is even no need to be in IDLE for that, but IDLE is still needed to get
* OK Still here
keepalives, so no need to change anything around the IDLE code paths.To implement
NOTIFY
support, we need to:NOTIFY
capability.NOTIFY
is supported, enable it once after logging in for the folder we watch (either INBOX or DeltaChat). In the example I used "selected", but we better watch for the explicit folder name to avoid missing messages if we switch folders or close the current folder. Ideally we don't need to switch folders when usingNOTIFY
, but I would suggest not getting rid ofscan_folders()
right away and makeNOTIFY
working with minimal changes first.FETCH
messages that we receive. Normally they will get intoSession.unsolicited_responses()
channel and we should process them when we read from it, but they may also accidentally be mistaken as aFETCH
command response so we should also recognize such notify-prefetches whenever we read aFETCH
command response.Config::DisableNotify
similar toConfig::DisableIdle
and run some tests with it enabled to ensure we don't break compatibility with the servers not supportingNOTIFY
.The text was updated successfully, but these errors were encountered: