Skip to content

Commit

Permalink
fix: App context event handling for channel and membership (#362)
Browse files Browse the repository at this point in the history
* fix: test with overlapping channels subscription using new listener interface

* dist/lib

* event emitter: fix and test for objects event type handling

* dist/lib update

* Apply suggestions from code review

Co-authored-by: Serhii Mamontov <parfeon@me.com>

* renamed property name publishTimetoken to timetoken in publishMetadata

* lib/dist

* PubNub SDK v7.6.1 release.

---------

Co-authored-by: Serhii Mamontov <parfeon@me.com>
Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 26, 2024
1 parent a73bc58 commit a551a84
Show file tree
Hide file tree
Showing 18 changed files with 195 additions and 59 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: 2024-02-26
version: v7.6.1
changes:
- type: bug
text: "Fixes issue of App context event handling for channel and membership."
- date: 2024-02-21
version: v7.6.0
changes:
Expand Down Expand Up @@ -943,7 +948,7 @@ supported-platforms:
- 'Ubuntu 14.04 and up'
- 'Windows 7 and up'
version: 'Pubnub Javascript for Node'
version: '7.6.0'
version: '7.6.1'
sdks:
- full-name: PubNub Javascript SDK
short-name: Javascript
Expand All @@ -959,7 +964,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v7.6.0.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v7.6.1.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -1630,7 +1635,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v7.6.0/pubnub.7.6.0.js
location: https://github.com/pubnub/javascript/releases/download/v7.6.1/pubnub.7.6.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 @@
## v7.6.1
February 26 2024

#### Fixed
- Fixes issue of App context event handling for channel and membership.

## v7.6.0
February 21 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.7.6.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.6.0.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.6.1.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.6.1.min.js
2. Configure your keys:
Expand Down
25 changes: 13 additions & 12 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@
return this;
};
default_1.prototype.getVersion = function () {
return '7.6.0';
return '7.6.1';
};
default_1.prototype._setRetryConfiguration = function (configuration) {
if (configuration.minimumdelay < 2) {
Expand Down Expand Up @@ -6533,7 +6533,7 @@
var messages = [];
serverResponse.m.forEach(function (rawMessage) {
var publishMetaData = {
publishTimetoken: rawMessage.p.t,
timetoken: rawMessage.p.t,
region: rawMessage.p.r,
};
var parsedMessage = {
Expand Down Expand Up @@ -6659,6 +6659,7 @@
issuingClientId: envelope.i,
subscribeKey: envelope.k,
originationTimetoken: envelope.o,
userMetadata: envelope.u,
publishMetaData: {
timetoken: envelope.p.t,
region: envelope.p.r,
Expand Down Expand Up @@ -7640,10 +7641,10 @@
}
};
EventEngine.prototype.getSubscribedChannels = function () {
return this.channels.slice(0);
return Array.from(new Set(this.channels));
};
EventEngine.prototype.getSubscribedChannelGroups = function () {
return this.groups.slice(0);
return Array.from(new Set(this.groups));
};
EventEngine.prototype.dispose = function () {
this.disconnect();
Expand Down Expand Up @@ -8107,7 +8108,7 @@
}
announce.action = e.payload.action;
announce.state = e.payload.data;
announce.timetoken = publishMetaData.publishTimetoken;
announce.timetoken = publishMetaData.timetoken;
announce.occupancy = e.payload.occupancy;
announce.uuid = e.payload.uuid;
announce.timestamp = e.payload.timestamp;
Expand All @@ -8133,7 +8134,7 @@
announce.subscription = null;
announce.channel = channel;
announce.subscription = subscriptionMatch;
announce.timetoken = publishMetaData.publishTimetoken;
announce.timetoken = publishMetaData.timetoken;
announce.publisher = e.issuingClientId;
if (e.userMetadata) {
announce.userMetadata = e.userMetadata;
Expand All @@ -8148,7 +8149,7 @@
announce.subscription = null;
announce.channel = channel;
announce.subscription = subscriptionMatch;
announce.timetoken = publishMetaData.publishTimetoken;
announce.timetoken = publishMetaData.timetoken;
announce.publisher = e.issuingClientId;
if (e.userMetadata) {
announce.userMetadata = e.userMetadata;
Expand All @@ -8166,13 +8167,13 @@
this.listenerManager.announceUser(userEvent);
this._announce('user', userEvent, announce.channel, announce.subscription);
}
else if (message.payload.type === 'channel') {
else if (e.payload.type === 'channel') {
var eventData = this._renameChannelField(announce);
var spaceEvent = __assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: this._renameEvent(eventData.message.event), type: 'space' }) });
this.listenerManager.announceSpace(spaceEvent);
this._announce('space', spaceEvent, announce.channel, announce.subscription);
}
else if (message.payload.type === 'membership') {
else if (e.payload.type === 'membership') {
var eventData = this._renameChannelField(announce);
var _a = eventData.message.data, user = _a.uuid, space = _a.channel, membershipData = __rest(_a, ["uuid", "channel"]);
membershipData.user = user;
Expand All @@ -8186,7 +8187,7 @@
var announce = {};
announce.channel = channel;
announce.subscription = subscriptionMatch;
announce.timetoken = publishMetaData.publishTimetoken;
announce.timetoken = publishMetaData.timetoken;
announce.publisher = e.issuingClientId;
announce.data = {
messageTimetoken: e.payload.data.messageTimetoken,
Expand All @@ -8203,7 +8204,7 @@
var announce = {};
announce.channel = channel;
announce.subscription = subscriptionMatch;
announce.timetoken = publishMetaData.publishTimetoken;
announce.timetoken = publishMetaData.timetoken;
announce.publisher = e.issuingClientId;
var msgPayload = e.payload;
if (this.modules.cryptoModule) {
Expand Down Expand Up @@ -8243,7 +8244,7 @@
announce.subscription = null;
announce.channel = channel;
announce.subscription = subscriptionMatch;
announce.timetoken = publishMetaData.publishTimetoken;
announce.timetoken = publishMetaData.timetoken;
announce.publisher = e.issuingClientId;
if (e.userMetadata) {
announce.userMetadata = e.userMetadata;
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/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ var default_1 = /** @class */ (function () {
return this;
};
default_1.prototype.getVersion = function () {
return '7.6.0';
return '7.6.1';
};
default_1.prototype._setRetryConfiguration = function (configuration) {
if (configuration.minimumdelay < 2) {
Expand Down
16 changes: 8 additions & 8 deletions lib/core/components/eventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var EventEmitter = /** @class */ (function () {
}
announce.action = e.payload.action;
announce.state = e.payload.data;
announce.timetoken = publishMetaData.publishTimetoken;
announce.timetoken = publishMetaData.timetoken;
announce.occupancy = e.payload.occupancy;
announce.uuid = e.payload.uuid;
announce.timestamp = e.payload.timestamp;
Expand All @@ -77,7 +77,7 @@ var EventEmitter = /** @class */ (function () {
announce.subscription = null;
announce.channel = channel;
announce.subscription = subscriptionMatch;
announce.timetoken = publishMetaData.publishTimetoken;
announce.timetoken = publishMetaData.timetoken;
announce.publisher = e.issuingClientId;
if (e.userMetadata) {
announce.userMetadata = e.userMetadata;
Expand All @@ -92,7 +92,7 @@ var EventEmitter = /** @class */ (function () {
announce.subscription = null;
announce.channel = channel;
announce.subscription = subscriptionMatch;
announce.timetoken = publishMetaData.publishTimetoken;
announce.timetoken = publishMetaData.timetoken;
announce.publisher = e.issuingClientId;
if (e.userMetadata) {
announce.userMetadata = e.userMetadata;
Expand All @@ -110,13 +110,13 @@ var EventEmitter = /** @class */ (function () {
this.listenerManager.announceUser(userEvent);
this._announce('user', userEvent, announce.channel, announce.subscription);
}
else if (message.payload.type === 'channel') {
else if (e.payload.type === 'channel') {
var eventData = this._renameChannelField(announce);
var spaceEvent = __assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: this._renameEvent(eventData.message.event), type: 'space' }) });
this.listenerManager.announceSpace(spaceEvent);
this._announce('space', spaceEvent, announce.channel, announce.subscription);
}
else if (message.payload.type === 'membership') {
else if (e.payload.type === 'membership') {
var eventData = this._renameChannelField(announce);
var _a = eventData.message.data, user = _a.uuid, space = _a.channel, membershipData = __rest(_a, ["uuid", "channel"]);
membershipData.user = user;
Expand All @@ -130,7 +130,7 @@ var EventEmitter = /** @class */ (function () {
var announce = {};
announce.channel = channel;
announce.subscription = subscriptionMatch;
announce.timetoken = publishMetaData.publishTimetoken;
announce.timetoken = publishMetaData.timetoken;
announce.publisher = e.issuingClientId;
announce.data = {
messageTimetoken: e.payload.data.messageTimetoken,
Expand All @@ -147,7 +147,7 @@ var EventEmitter = /** @class */ (function () {
var announce = {};
announce.channel = channel;
announce.subscription = subscriptionMatch;
announce.timetoken = publishMetaData.publishTimetoken;
announce.timetoken = publishMetaData.timetoken;
announce.publisher = e.issuingClientId;
var msgPayload = e.payload;
if (this.modules.cryptoModule) {
Expand Down Expand Up @@ -187,7 +187,7 @@ var EventEmitter = /** @class */ (function () {
announce.subscription = null;
announce.channel = channel;
announce.subscription = subscriptionMatch;
announce.timetoken = publishMetaData.publishTimetoken;
announce.timetoken = publishMetaData.timetoken;
announce.publisher = e.issuingClientId;
if (e.userMetadata) {
announce.userMetadata = e.userMetadata;
Expand Down
2 changes: 1 addition & 1 deletion lib/core/endpoints/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function handleResponse(modules, serverResponse) {
var messages = [];
serverResponse.m.forEach(function (rawMessage) {
var publishMetaData = {
publishTimetoken: rawMessage.p.t,
timetoken: rawMessage.p.t,
region: rawMessage.p.r,
};
var parsedMessage = {
Expand Down
1 change: 1 addition & 0 deletions lib/core/endpoints/subscriptionUtils/receiveMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var endpoint = {
issuingClientId: envelope.i,
subscribeKey: envelope.k,
originationTimetoken: envelope.o,
userMetadata: envelope.u,
publishMetaData: {
timetoken: envelope.p.t,
region: envelope.p.r,
Expand Down
4 changes: 2 additions & 2 deletions lib/event-engine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ var EventEngine = /** @class */ (function () {
}
};
EventEngine.prototype.getSubscribedChannels = function () {
return this.channels.slice(0);
return Array.from(new Set(this.channels));
};
EventEngine.prototype.getSubscribedChannelGroups = function () {
return this.groups.slice(0);
return Array.from(new Set(this.groups));
};
EventEngine.prototype.dispose = function () {
this.disconnect();
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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": "7.6.0",
"version": "7.6.1",
"author": "PubNub <support@pubnub.com>",
"description": "Publish & Subscribe Real-time Messaging with PubNub",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export default class {
}

getVersion() {
return '7.6.0';
return '7.6.1';
}

_setRetryConfiguration(configuration) {
Expand Down
Loading

0 comments on commit a551a84

Please sign in to comment.