Skip to content

Commit

Permalink
Merge pull request #187 from pubnub/develop
Browse files Browse the repository at this point in the history
Release v4.27.1
  • Loading branch information
raipubnub committed Nov 20, 2019
2 parents 59fc700 + 3c3535f commit e0901c2
Show file tree
Hide file tree
Showing 18 changed files with 225 additions and 153 deletions.
18 changes: 17 additions & 1 deletion .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
---
changelog:
-
changes:
-
text: "Make changes in fetch_messages endpoint to move message actions (if any) for message from 'data' to 'actions' property (old 'data' will be in place for few updates to not break existing clients)."
type: bug
-
text: "fix PAMv3 tests mocked signature"
type: improvement
-
text: "fix lint warnings for tests and code"
type: improvement
-
text: "fix gulp build so that failures in test and lint will trigger failure in travis"
type: improvement
date: 2019-11-20
version: v4.27.1
-
changes:
-
Expand Down Expand Up @@ -773,4 +789,4 @@ supported-platforms:
- "Ubuntu 14.04 and above"
- "Windows 7, 8, 10"
version: "Pubnub Javascript for Node"
version: "4.27.0"
version: "4.27.1"
18 changes: 16 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
## [v4.27.0](https://github.com/pubnub/javascript/tree/v4.27.0)
September-27-2019
## [v4.27.1](https://github.com/pubnub/javascript/tree/v4.27.1)
November-20-2019


[Full Changelog](https://github.com/pubnub/javascript/compare/v4.27.0...v4.27.1)



- ⭐ Make changes in fetch_messages endpoint to move message actions (if any) for message from 'data' to 'actions' property (old 'data' will be in place for few updates to not break existing clients).
- ⭐ fix PAMv3 tests mocked signature
- ⭐ fix lint warnings for tests and code
- ⭐ fix gulp build so that failures in test and lint will trigger failure in travis


## [v4.27.0](https://github.com/pubnub/javascript/tree/v4.27.0)
October-08-2019


[Full Changelog](https://github.com/pubnub/javascript/compare/v4.26.1...v4.27.0)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ please use the [master_3x](https://github.com/pubnub/javascript/tree/master_3x)



* https://cdn.pubnub.com/sdk/javascript/pubnub.4.27.0.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.27.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.27.1.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.27.1.js
4 changes: 2 additions & 2 deletions dist/titanium/pubnub.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! 4.27.0 / Consumer */
/*! 4.27.1 / Consumer */
exports["PubNub"] =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
Expand Down Expand Up @@ -471,7 +471,7 @@ var _default = function () {
}, {
key: "getVersion",
value: function getVersion() {
return '4.27.0';
return '4.27.1';
}
}, {
key: "_decideUUID",
Expand Down
2 changes: 1 addition & 1 deletion dist/titanium/pubnub.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! 4.27.0 / Consumer */
/*! 4.27.1 / Consumer */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
Expand Down Expand Up @@ -480,7 +480,7 @@ var _default = function () {
}, {
key: "getVersion",
value: function getVersion() {
return '4.27.0';
return '4.27.1';
}
}, {
key: "_decideUUID",
Expand Down
2 changes: 1 addition & 1 deletion dist/web/pubnub.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const unzip = require('gulp-unzip');
// increase mocha timeout from default of 2000 to allow long running async tests to complete
const mochaTimeout = 5000;

gulp.on('error', process.exit.bind(process, 1));
gulp.task('clean', () => {
return gulp
.src(['lib', 'dist', 'coverage', 'upload'], { read: false, allowEmpty: true })
Expand Down Expand Up @@ -188,4 +189,4 @@ gulp.task('webpack', (done) => {

gulp.task('compile', (done) => {
runSequence('clean', 'babel', 'webpack', 'uglify_web', 'uglify_titanium', 'create_version', 'create_version_gzip', done);
});
});
2 changes: 1 addition & 1 deletion lib/core/components/config.js

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

2 changes: 1 addition & 1 deletion lib/core/components/config.js.map

Large diffs are not rendered by default.

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": "4.27.0",
"version": "4.27.1",
"author": "PubNub <support@pubnub.com>",
"description": "Publish & Subscribe Real-time Messaging with PubNub",
"bin": {},
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 @@ -296,7 +296,7 @@ export default class {
}

getVersion(): string {
return '4.27.0';
return '4.27.1';
}

_decideUUID(providedUUID: string): string {
Expand Down
2 changes: 1 addition & 1 deletion src/core/endpoints/actions/get_message_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function handleResponse(
getMessageActionsResponse: Object
): GetMessageActionsResponse {
/** @type GetMessageActionsResponse */
let response = { data: getMessageActionsResponse.data };
let response = { data: getMessageActionsResponse.data, start: null, end: null };

if (response.data.length) {
response.end = response.data[response.data.length - 1].actionTimetoken;
Expand Down
4 changes: 3 additions & 1 deletion src/core/endpoints/fetch_messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ export function handleResponse(
(serverResponse.channels[channelName] || []).forEach((messageEnvelope) => {
let announce: MessageAnnouncement = {};
announce.channel = channelName;
announce.subscription = null;
announce.timetoken = messageEnvelope.timetoken;
announce.message = __processMessage(modules, messageEnvelope.message);

if (messageEnvelope.actions) {
announce.actions = messageEnvelope.actions;

// This should be kept for few updates for existing clients consistency.
announce.data = messageEnvelope.actions;
}
if (messageEnvelope.meta) {
Expand Down
88 changes: 60 additions & 28 deletions test/integration/endpoints/fetch_messages.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global describe, beforeEach, afterEach, it, before, after */
/* global describe, beforeEach, afterEach, it, after */
/* eslint no-console: 0 */

import assert from 'assert';
Expand All @@ -18,7 +18,7 @@ function publishMessagesToChannel(client: PubNub, count: Number, channel: String
}

client.publish(payload, (status, response) => {
publishCompleted++;
publishCompleted += 1;

if (!status.error) {
messages.push({ message: payload.message, timetoken: response.timetoken });
Expand All @@ -27,13 +27,12 @@ function publishMessagesToChannel(client: PubNub, count: Number, channel: String
console.error('Publish did fail:', status);
}

if (publishCompleted < count) {
publish(publishCompleted);
} else if (publishCompleted === count) {
completion(messages);
}
if (publishCompleted < count) {
publish(publishCompleted);
} else if (publishCompleted === count) {
completion(messages);
}
);
});
};

publish(publishCompleted);
Expand All @@ -49,12 +48,12 @@ function addActionsInChannel(client: PubNub, count: Number, messageTimetokens: A
let actionsAdded = 0;
let actions = [];

for (let messageIdx = 0; messageIdx < messageTimetokens.length; messageIdx++) {
for (let messageIdx = 0; messageIdx < messageTimetokens.length; messageIdx += 1) {
const messageTimetoken = messageTimetokens[messageIdx];

for (let messageActionIdx = 0; messageActionIdx < count; messageActionIdx++) {
for (let messageActionIdx = 0; messageActionIdx < count; messageActionIdx += 1) {
/** @type MessageAction */
const action = { type: types[(messageActionIdx + 1)%3], value: values[(messageActionIdx + 1)%10] };
const action = { type: types[(messageActionIdx + 1) % 3], value: values[(messageActionIdx + 1) % 10] };

actionsToAdd.push({ messageTimetoken, action });
}
Expand All @@ -66,7 +65,7 @@ function addActionsInChannel(client: PubNub, count: Number, messageTimetokens: A
client.addMessageAction(
{ channel, messageTimetoken, action },
(status, response) => {
actionsAdded++;
actionsAdded += 1;

if (!status.error) {
actions.push(response.data);
Expand Down Expand Up @@ -107,8 +106,8 @@ describe('fetch messages endpoints', () => {
beforeEach(() => {
nock.cleanAll();
pubnub = new PubNub({
subscribeKey: subscribeKey,
publishKey: publishKey,
subscribeKey,
publishKey,
uuid: 'myUUID',
});
});
Expand Down Expand Up @@ -140,15 +139,13 @@ describe('fetch messages endpoints', () => {
message: {
text: 'hey1',
},
subscription: null,
timetoken: '11',
},
{
channel: 'ch1',
message: {
text: 'hey2',
},
subscription: null,
timetoken: '12',
},
],
Expand All @@ -158,15 +155,13 @@ describe('fetch messages endpoints', () => {
message: {
text: 'hey3',
},
subscription: null,
timetoken: '21',
},
{
channel: 'ch2',
message: {
text: 'hey2',
},
subscription: null,
timetoken: '22',
},
],
Expand Down Expand Up @@ -206,15 +201,13 @@ describe('fetch messages endpoints', () => {
message: {
text: 'hey',
},
subscription: null,
timetoken: '11',
},
{
channel: 'ch1',
message: {
text: 'hey',
},
subscription: null,
timetoken: '12',
},
],
Expand All @@ -224,15 +217,13 @@ describe('fetch messages endpoints', () => {
message: {
text2: 'hey2',
},
subscription: null,
timetoken: '21',
},
{
channel: 'ch2',
message: {
text2: 'hey2',
},
subscription: null,
timetoken: '22',
},
],
Expand Down Expand Up @@ -265,7 +256,7 @@ describe('fetch messages endpoints', () => {
try {
pubnub.fetchMessages(
{ channels: ['channelA', 'channelB'], includeMessageActions: true },
(status, response) => {}
() => {}
);
} catch (error) {
assert.equal(error.message, 'History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.');
Expand All @@ -275,13 +266,13 @@ describe('fetch messages endpoints', () => {
assert(errorCatched);
});

it('supports actions', (done) => {
it('supports actions (stored as \'data\' field)', (done) => {
const channel = PubNub.generateUUID();
const expectedMessagesCount = 2;
const expectedActionsCount = 4;

publishMessagesToChannel(pubnub, expectedMessagesCount, channel, (messages) => {
const messageTimetokens = messages.map((message) => message.timetoken );
const messageTimetokens = messages.map((message) => message.timetoken);

addActionsInChannel(pubnub, expectedActionsCount, messageTimetokens, channel, (actions) => {
setTimeout(() => {
Expand All @@ -294,7 +285,49 @@ describe('fetch messages endpoints', () => {
Object.keys(actionsByType).forEach((actionType) => {
Object.keys(actionsByType[actionType]).forEach((actionValue) => {
let actionFound = false;
historyActionsCount++;
historyActionsCount += 1;

actions.forEach((action) => {
if (action.value === actionValue) {
actionFound = true;
}
});

assert.equal(actionFound, true);
});
});

assert.equal(historyActionsCount, expectedActionsCount);
assert.equal(fetchedMessages[0].timetoken, messageTimetokens[0]);
assert.equal(fetchedMessages[fetchedMessages.length - 1].timetoken, messageTimetokens[messageTimetokens.length - 1]);

done();
});
}, 2000);
});
});
}).timeout(60000);

it('supports actions (stored as \'actions\' field)', (done) => {
const channel = PubNub.generateUUID();
const expectedMessagesCount = 2;
const expectedActionsCount = 4;

publishMessagesToChannel(pubnub, expectedMessagesCount, channel, (messages) => {
const messageTimetokens = messages.map((message) => message.timetoken);

addActionsInChannel(pubnub, expectedActionsCount, messageTimetokens, channel, (actions) => {
setTimeout(() => {
pubnub.fetchMessages({ channels: [channel], includeMessageActions: true }, (status, response) => {
assert.equal(status.error, false);
const fetchedMessages = response.channels[channel];
const actionsByType = fetchedMessages[0].actions;
let historyActionsCount = 0;

Object.keys(actionsByType).forEach((actionType) => {
Object.keys(actionsByType[actionType]).forEach((actionValue) => {
let actionFound = false;
historyActionsCount += 1;

actions.forEach((action) => {
if (action.value === actionValue) {
Expand All @@ -308,8 +341,7 @@ describe('fetch messages endpoints', () => {

assert.equal(historyActionsCount, expectedActionsCount);
assert.equal(fetchedMessages[0].timetoken, messageTimetokens[0]);
assert.equal(fetchedMessages[fetchedMessages.length - 1].timetoken,
messageTimetokens[messageTimetokens.length - 1]);
assert.equal(fetchedMessages[fetchedMessages.length - 1].timetoken, messageTimetokens[messageTimetokens.length - 1]);

done();
});
Expand Down

0 comments on commit e0901c2

Please sign in to comment.