diff --git a/imap-core/lib/commands/xapplepushservice.js b/imap-core/lib/commands/xapplepushservice.js index 1c37f4e4..e71b9aa2 100644 --- a/imap-core/lib/commands/xapplepushservice.js +++ b/imap-core/lib/commands/xapplepushservice.js @@ -159,7 +159,8 @@ module.exports = { _sess: this.id }; - this._server.onXAPPLEPUSHSERVICE(accountID, deviceToken, subTopic, mailboxes, this.session, error => { + // + this._server.onXAPPLEPUSHSERVICE(accountID, deviceToken, subTopic, mailboxes, this.session, (error, topic) => { if (error) { logdata._error = error.message; logdata._code = error.code; @@ -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' + }); + // // - 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.'