From 09d6906a62d05d81876decdaf2415b381ec2f193 Mon Sep 17 00:00:00 2001 From: Martin May Date: Fri, 5 Sep 2014 13:57:28 -0600 Subject: [PATCH] Adapted library and tests for new 2KB payload size --- lib/apnagent/message.js | 6 +++--- test/message.js | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/apnagent/message.js b/lib/apnagent/message.js index 2e74e35..f2a8282 100644 --- a/lib/apnagent/message.js +++ b/lib/apnagent/message.js @@ -407,8 +407,8 @@ Message.prototype.serialize = function () { var str = JSON.stringify(payload) , len = Buffer.byteLength(str, enc); - if (len > 256 && this.aps.body) { - var over = len - 256 + if (len > 2048 && this.aps.body) { + var over = len - 2048 , bodyLen = Buffer.byteLength(this.aps.body, enc) , body = bodyLen <= over ? null @@ -423,7 +423,7 @@ Message.prototype.serialize = function () { } else { payload.aps.alert.body = body; } - } else if (len > 256) { + } else if (len > 2048) { throw new SE('Message too long.', null, ssf); } diff --git a/test/message.js b/test/message.js index 2777f3a..ecad26f 100644 --- a/test/message.js +++ b/test/message.js @@ -167,7 +167,7 @@ describe('Message', function () { var json = msg.serialize(); Buffer.byteLength(JSON.stringify(json.payload), msg.encoding) - .should.not.be.above(256); + .should.not.be.above(2048); json.payload.should.deep.equal({ custom: 'variable' @@ -192,7 +192,7 @@ describe('Message', function () { var json = msg.serialize(); Buffer.byteLength(JSON.stringify(json.payload), msg.encoding) - .should.not.be.above(256); + .should.not.be.above(2048); json.payload.should.deep.equal({ custom: 'variable' @@ -230,7 +230,7 @@ describe('Message', function () { var json = msg.serialize(); Buffer.byteLength(JSON.stringify(json.payload), msg.encoding) - .should.not.be.above(256); + .should.not.be.above(2048); json.payload.should.deep.equal({ custom: 'variable' @@ -259,7 +259,7 @@ describe('Message', function () { var json = msg.serialize(); Buffer.byteLength(JSON.stringify(json.payload), msg.encoding) - .should.not.be.above(256); + .should.not.be.above(2048); json.payload.should.deep.equal({ custom: 'variable' @@ -287,7 +287,7 @@ describe('Message', function () { var json = msg.serialize(); Buffer.byteLength(JSON.stringify(json.payload), msg.encoding) - .should.not.be.above(256); + .should.not.be.above(2048); json.payload.should.deep.equal({ custom: 'variable' @@ -319,7 +319,7 @@ describe('Message', function () { var json = msg.serialize(); Buffer.byteLength(JSON.stringify(json.payload), msg.encoding) - .should.not.be.above(256); + .should.not.be.above(2048); json.payload.should.deep.equal({ custom: 'variable'