Skip to content

Commit ba0258f

Browse files
authored
fix: fixed XAPPLEPUSHSERVICE command (needs to return topic) (#719)
1 parent f32dc14 commit ba0258f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

imap-core/lib/commands/xapplepushservice.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ module.exports = {
159159
_sess: this.id
160160
};
161161

162-
this._server.onXAPPLEPUSHSERVICE(accountID, deviceToken, subTopic, mailboxes, this.session, error => {
162+
// <https://github.com/freswa/dovecot-xaps-daemon/issues/39#issuecomment-2263472541>
163+
this._server.onXAPPLEPUSHSERVICE(accountID, deviceToken, subTopic, mailboxes, this.session, (error, topic) => {
163164
if (error) {
164165
logdata._error = error.message;
165166
logdata._code = error.code;
@@ -172,9 +173,16 @@ module.exports = {
172173
});
173174
}
174175

176+
// this is a developer bug, they forgot to return a topic in callback
177+
if (typeof topic !== 'string' || !topic)
178+
return callback(null, {
179+
response: 'NO',
180+
code: 'TEMPFAIL'
181+
});
182+
175183
// <https://opensource.apple.com/source/dovecot/dovecot-293/dovecot/src/imap/cmd-x-apple-push-service.c.auto.html>
176184
// <https://github.com/st3fan/dovecot-xaps-plugin/blob/3d1c71e0c78cc35ca6ead21f49a8e0e35e948a7c/xaps-imap-plugin.c#L158-L166>
177-
this.send(`* XAPPLEPUSHSERVICE aps-version "${version}" aps-topic "${subTopic}"`);
185+
this.send(`* XAPPLEPUSHSERVICE aps-version "${version}" aps-topic "${topic}"`);
178186
callback(null, {
179187
response: 'OK',
180188
message: 'XAPPLEPUSHSERVICE Registration successful.'

0 commit comments

Comments
 (0)