mirror of
https://github.com/chatmail/core.git
synced 2026-10-01 18:50:39 +03:00
feat: stop requiring XDELTAPUSH capability for push notifications
register device token if XDELTAPUSH IMAP capability is available (current relay setup provides it) or if "maxsmtprecipients" IMAP metadata key is available (relays since May 2026 provide it), allowing chatmail relay setups to drop XDELTAPUSH capability marker with the next release while retaining push notification support.
This commit is contained in:
@@ -25,12 +25,8 @@ pub(crate) struct Capabilities {
|
||||
/// <https://tools.ietf.org/html/rfc4978>
|
||||
pub can_compress: bool,
|
||||
|
||||
/// True if the server supports XDELTAPUSH capability.
|
||||
/// This capability means setting /private/devicetoken IMAP METADATA
|
||||
/// on the INBOX results in new mail notifications
|
||||
/// via notifications.delta.chat service.
|
||||
/// This is supported by <https://github.com/deltachat/chatmail>
|
||||
pub can_push: bool,
|
||||
/// True if the server advertises the legacy `XDELTAPUSH` capability.
|
||||
pub has_xdeltapush: bool,
|
||||
|
||||
/// True if the server has an XCHATMAIL capability
|
||||
/// indicating that it is a <https://github.com/deltachat/chatmail> server.
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ pub(crate) async fn identify_server(
|
||||
can_check_quota: caps.has_str("QUOTA"),
|
||||
can_metadata: caps.has_str("METADATA"),
|
||||
can_compress: caps.has_str("COMPRESS=DEFLATE"),
|
||||
can_push: caps.has_str("XDELTAPUSH"),
|
||||
has_xdeltapush: caps.has_str("XDELTAPUSH"),
|
||||
is_chatmail: caps.has_str("XCHATMAIL"),
|
||||
server_id,
|
||||
};
|
||||
|
||||
@@ -116,15 +116,3 @@ fn test_uid_grouper() {
|
||||
vec![("INBOX".to_string(), vec![1, 2, 3], "2:3".to_string())]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_setmetadata_device_token() {
|
||||
assert_eq!(
|
||||
format_setmetadata("INBOX", "foobarbaz"),
|
||||
"SETMETADATA \"INBOX\" (/private/devicetoken {9+}\r\nfoobarbaz)"
|
||||
);
|
||||
assert_eq!(
|
||||
format_setmetadata("INBOX", "foo\r\nbar\r\nbaz\r\n"),
|
||||
"SETMETADATA \"INBOX\" (/private/devicetoken {15+}\r\nfoo\r\nbar\r\nbaz\r\n)"
|
||||
);
|
||||
}
|
||||
|
||||
+5
-4
@@ -49,6 +49,10 @@ pub(crate) struct Session {
|
||||
/// Should be false if no folder is currently selected.
|
||||
pub new_mail: bool,
|
||||
|
||||
/// True if storing the device token on the relay
|
||||
/// was already attempted on this connection.
|
||||
pub(crate) push_token_registered: bool,
|
||||
|
||||
pub resync_request_sender: async_channel::Sender<()>,
|
||||
}
|
||||
|
||||
@@ -81,6 +85,7 @@ impl Session {
|
||||
selected_mailbox: None,
|
||||
selected_folder_needs_expunge: false,
|
||||
new_mail: false,
|
||||
push_token_registered: false,
|
||||
resync_request_sender,
|
||||
}
|
||||
}
|
||||
@@ -106,10 +111,6 @@ impl Session {
|
||||
self.capabilities.can_metadata
|
||||
}
|
||||
|
||||
pub fn can_push(&self) -> bool {
|
||||
self.capabilities.can_push
|
||||
}
|
||||
|
||||
// Returns true if IMAP server has `XCHATMAIL` capability.
|
||||
pub(crate) fn is_chatmail(&self) -> bool {
|
||||
self.capabilities.is_chatmail
|
||||
|
||||
Reference in New Issue
Block a user