Skip to content

Commit

Permalink
Remove newBatchResponse parameter
Browse files Browse the repository at this point in the history
Per spec commit c48464a (it’s no longer needed in protocol v3).
  • Loading branch information
lawrence-forooghian committed Dec 12, 2023
1 parent b181c3d commit 014c158
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions src/common/lib/client/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,31 +210,23 @@ export class Rest {
if (this.client.options.headers) Utils.mixin(headers, this.client.options.headers);

const requestBody = Utils.encodeBody(requestBodyDTO, this.client._MsgPack, format);
Resource.post(
this.client,
'/messages',
requestBody,
headers,
{ newBatchResponse: 'true' },
null,
(err, body, headers, unpacked) => {
if (err) {
callback(err);
return;
}
Resource.post(this.client, '/messages', requestBody, headers, {}, null, (err, body, headers, unpacked) => {
if (err) {
callback(err);
return;
}

const batchResults = (
unpacked ? body : Utils.decodeBody(body, this.client._MsgPack, format)
) as BatchPublishResult[];
const batchResults = (
unpacked ? body : Utils.decodeBody(body, this.client._MsgPack, format)
) as BatchPublishResult[];

// I don't love the below type assertions for `callback` but not sure how to avoid them
if (singleSpecMode) {
(callback as StandardCallback<BatchPublishResult>)(null, batchResults[0]);
} else {
(callback as StandardCallback<BatchPublishResult[]>)(null, batchResults);
}
// I don't love the below type assertions for `callback` but not sure how to avoid them
if (singleSpecMode) {
(callback as StandardCallback<BatchPublishResult>)(null, batchResults[0]);
} else {
(callback as StandardCallback<BatchPublishResult[]>)(null, batchResults);
}
);
});
}

batchPresence(channels: string[]): Promise<BatchPresenceResult>;
Expand All @@ -257,7 +249,7 @@ export class Rest {
this.client,
'/presence',
headers,
{ newBatchResponse: 'true', channels: channelsParam },
{ channels: channelsParam },
null,
(err, body, headers, unpacked) => {
if (err) {
Expand Down Expand Up @@ -304,7 +296,7 @@ export class Rest {
`/keys/${keyName}/revokeTokens`,
requestBody,
headers,
{ newBatchResponse: 'true' },
{},
null,
(err, body, headers, unpacked) => {
if (err) {
Expand Down

0 comments on commit 014c158

Please sign in to comment.