Skip to content

Adapted library and tests for new 2KB payload size #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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