Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/apnagent/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down
12 changes: 6 additions & 6 deletions test/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down