Skip to content

Commit

Permalink
fix: issue of parsing response for here_now (#427)
Browse files Browse the repository at this point in the history
* fix: issue of parsing response for here_now

* test: additional assert for hereNow response parsing test

* PubNub SDK v8.4.1 release.

---------

Co-authored-by: Mohit Tejani <[email protected]>
Co-authored-by: PubNub Release Bot <[email protected]>
  • Loading branch information
3 people authored Jan 2, 2025
1 parent 6a9fa7d commit 1a2ddeb
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 14 deletions.
11 changes: 8 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
changelog:
- date: 2025-01-02
version: v8.4.1
changes:
- type: bug
text: "Fixed issue of hereNow response parsing for `totalOccupancy` field."
- date: 2024-12-17
version: v8.4.0
changes:
Expand Down Expand Up @@ -1094,7 +1099,7 @@ supported-platforms:
- 'Ubuntu 14.04 and up'
- 'Windows 7 and up'
version: 'Pubnub Javascript for Node'
version: '8.4.0'
version: '8.4.1'
sdks:
- full-name: PubNub Javascript SDK
short-name: Javascript
Expand All @@ -1110,7 +1115,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.4.0.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.4.1.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -1781,7 +1786,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v8.4.0/pubnub.8.4.0.js
location: https://github.com/pubnub/javascript/releases/download/v8.4.1/pubnub.8.4.1.js
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v8.4.1
January 02 2025

#### Fixed
- Fixed issue of hereNow response parsing for `totalOccupancy` field.

## v8.4.0
December 17 2024

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Watch [Getting Started with PubNub JS SDK](https://app.dashcam.io/replay/64ee0d2
npm install pubnub
```
* or download one of our builds from our CDN:
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.4.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.4.0.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.4.1.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.4.1.min.js
2. Configure your keys:
Expand Down
4 changes: 2 additions & 2 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -3961,7 +3961,7 @@
return base.PubNubFile;
},
get version() {
return '8.4.0';
return '8.4.1';
},
getVersion() {
return this.version;
Expand Down Expand Up @@ -8810,7 +8810,7 @@
throw PubNubAPIError.create(response);
// Extract general presence information.
const totalChannels = 'occupancy' in serviceResponse ? 1 : serviceResponse.payload.total_channels;
const totalOccupancy = 'occupancy' in serviceResponse ? serviceResponse.occupancy : serviceResponse.payload.total_channels;
const totalOccupancy = 'occupancy' in serviceResponse ? serviceResponse.occupancy : serviceResponse.payload.total_occupancy;
const channelsPresence = {};
let channels = {};
// Remap single channel presence to multiple channels presence response.
Expand Down
2 changes: 1 addition & 1 deletion dist/web/pubnub.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/core/components/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const makeConfiguration = (base, setupCryptoModule) => {
return base.PubNubFile;
},
get version() {
return '8.4.0';
return '8.4.1';
},
getVersion() {
return this.version;
Expand Down
2 changes: 1 addition & 1 deletion lib/core/endpoints/presence/here_now.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class HereNowRequest extends request_1.AbstractRequest {
throw pubnub_api_error_1.PubNubAPIError.create(response);
// Extract general presence information.
const totalChannels = 'occupancy' in serviceResponse ? 1 : serviceResponse.payload.total_channels;
const totalOccupancy = 'occupancy' in serviceResponse ? serviceResponse.occupancy : serviceResponse.payload.total_channels;
const totalOccupancy = 'occupancy' in serviceResponse ? serviceResponse.occupancy : serviceResponse.payload.total_occupancy;
const channelsPresence = {};
let channels = {};
// Remap single channel presence to multiple channels presence response.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pubnub",
"version": "8.4.0",
"version": "8.4.1",
"author": "PubNub <[email protected]>",
"description": "Publish & Subscribe Real-time Messaging with PubNub",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const makeConfiguration = (
return base.PubNubFile;
},
get version(): string {
return '8.4.0';
return '8.4.1';
},
getVersion(): string {
return this.version;
Expand Down
2 changes: 1 addition & 1 deletion src/core/endpoints/presence/here_now.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class HereNowRequest extends AbstractRequest<Presence.HereNowResponse> {
// Extract general presence information.
const totalChannels = 'occupancy' in serviceResponse ? 1 : serviceResponse.payload.total_channels;
const totalOccupancy =
'occupancy' in serviceResponse ? serviceResponse.occupancy : serviceResponse.payload.total_channels;
'occupancy' in serviceResponse ? serviceResponse.occupancy : serviceResponse.payload.total_occupancy;
const channelsPresence: Presence.HereNowResponse['channels'] = {};
let channels: Required<MultipleChannelServiceResponse['payload']>['channels'] = {};

Expand Down
4 changes: 3 additions & 1 deletion test/integration/endpoints/presence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ describe('presence endpoints', () => {
})
.reply(
200,
' {"status": 200, "message": "OK", "payload": {"channels": {"ch1": {"uuids": ["a581c974-e2f9-4088-9cc8-9632708e012d"], "occupancy": 1}}, "total_channels": 1, "total_occupancy": 1}, "service": "Presence"}',
' {"status": 200, "message": "OK", "payload": {"channels": {"ch1": {"uuids": ["a581c974-e2f9-4088-9cc8-9632708e012d"], "occupancy": 1}}, "total_channels": 3, "total_occupancy": 7}, "service": "Presence"}',
{ 'content-type': 'text/javascript' },
);

Expand All @@ -621,6 +621,8 @@ describe('presence endpoints', () => {
]
}
});
assert.equal(response.totalChannels, 3);
assert.equal(response.totalOccupancy, 7);
assert.equal(scope.isDone(), true);
done();
} catch (error) {
Expand Down

0 comments on commit 1a2ddeb

Please sign in to comment.