Skip to content

Commit

Permalink
fix: fixed XAPPLEPUSHSERVICE command (needs to return topic) (#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism authored Aug 1, 2024
1 parent f32dc14 commit ba0258f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions imap-core/lib/commands/xapplepushservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ module.exports = {
_sess: this.id
};

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

// this is a developer bug, they forgot to return a topic in callback
if (typeof topic !== 'string' || !topic)
return callback(null, {
response: 'NO',
code: 'TEMPFAIL'
});

// <https://opensource.apple.com/source/dovecot/dovecot-293/dovecot/src/imap/cmd-x-apple-push-service.c.auto.html>
// <https://github.com/st3fan/dovecot-xaps-plugin/blob/3d1c71e0c78cc35ca6ead21f49a8e0e35e948a7c/xaps-imap-plugin.c#L158-L166>
this.send(`* XAPPLEPUSHSERVICE aps-version "${version}" aps-topic "${subTopic}"`);
this.send(`* XAPPLEPUSHSERVICE aps-version "${version}" aps-topic "${topic}"`);
callback(null, {
response: 'OK',
message: 'XAPPLEPUSHSERVICE Registration successful.'
Expand Down

0 comments on commit ba0258f

Please sign in to comment.