Skip to content
Merged
6 changes: 3 additions & 3 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -11210,7 +11210,7 @@
}
get path() {
const { keySet: { subscribeKey }, uuid, channels, } = this.parameters;
return `/v2/presence/sub-key/${subscribeKey}/channel/${encodeNames(channels !== null && channels !== void 0 ? channels : [], ',')}/uuid/${uuid}`;
return `/v2/presence/sub-key/${subscribeKey}/channel/${encodeNames(channels !== null && channels !== void 0 ? channels : [], ',')}/uuid/${encodeString(uuid !== null && uuid !== void 0 ? uuid : '')}`;
}
get queryParameters() {
const { channelGroups } = this.parameters;
Expand Down Expand Up @@ -11243,7 +11243,7 @@
const { keySet: { subscribeKey }, state, channels = [], channelGroups = [], } = this.parameters;
if (!subscribeKey)
return 'Missing Subscribe Key';
if (!state)
if (state === undefined)
return 'Missing State';
if ((channels === null || channels === void 0 ? void 0 : channels.length) === 0 && (channelGroups === null || channelGroups === void 0 ? void 0 : channelGroups.length) === 0)
return 'Please provide a list of channels and/or channel-groups';
Expand Down Expand Up @@ -11309,7 +11309,7 @@
const query = { heartbeat: `${heartbeat}` };
if (channelGroups && channelGroups.length !== 0)
query['channel-group'] = channelGroups.join(',');
if (state)
if (state !== undefined)
query.state = JSON.stringify(state);
return query;
}
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/endpoints/presence/get_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class GetPresenceStateRequest extends request_1.AbstractRequest {
}
get path() {
const { keySet: { subscribeKey }, uuid, channels, } = this.parameters;
return `/v2/presence/sub-key/${subscribeKey}/channel/${(0, utils_1.encodeNames)(channels !== null && channels !== void 0 ? channels : [], ',')}/uuid/${uuid}`;
return `/v2/presence/sub-key/${subscribeKey}/channel/${(0, utils_1.encodeNames)(channels !== null && channels !== void 0 ? channels : [], ',')}/uuid/${(0, utils_1.encodeString)(uuid !== null && uuid !== void 0 ? uuid : '')}`;
}
get queryParameters() {
const { channelGroups } = this.parameters;
Expand Down
2 changes: 1 addition & 1 deletion lib/core/endpoints/presence/heartbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class HeartbeatRequest extends request_1.AbstractRequest {
const query = { heartbeat: `${heartbeat}` };
if (channelGroups && channelGroups.length !== 0)
query['channel-group'] = channelGroups.join(',');
if (state)
if (state !== undefined)
query.state = JSON.stringify(state);
return query;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core/endpoints/presence/set_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SetPresenceStateRequest extends request_1.AbstractRequest {
const { keySet: { subscribeKey }, state, channels = [], channelGroups = [], } = this.parameters;
if (!subscribeKey)
return 'Missing Subscribe Key';
if (!state)
if (state === undefined)
return 'Missing State';
if ((channels === null || channels === void 0 ? void 0 : channels.length) === 0 && (channelGroups === null || channelGroups === void 0 ? void 0 : channelGroups.length) === 0)
return 'Please provide a list of channels and/or channel-groups';
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions src/core/endpoints/presence/get_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AbstractRequest } from '../../components/request';
import RequestOperation from '../../constants/operations';
import { KeySet, Payload, Query } from '../../types/api';
import * as Presence from '../../types/api/presence';
import { encodeNames } from '../../utils';
import { encodeNames, encodeString } from '../../utils';

// --------------------------------------------------------
// ------------------------ Types -------------------------
Expand Down Expand Up @@ -103,7 +103,10 @@ export class GetPresenceStateRequest extends AbstractRequest<Presence.GetPresenc
channels,
} = this.parameters;

return `/v2/presence/sub-key/${subscribeKey}/channel/${encodeNames(channels ?? [], ',')}/uuid/${uuid}`;
return `/v2/presence/sub-key/${subscribeKey}/channel/${encodeNames(
channels ?? [],
',',
)}/uuid/${encodeString(uuid ?? '')}`;
}

protected get queryParameters(): Query {
Expand Down
2 changes: 1 addition & 1 deletion src/core/endpoints/presence/heartbeat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class HeartbeatRequest extends AbstractRequest<Presence.PresenceHeartbeat
const query: Record<string, string> = { heartbeat: `${heartbeat}` };

if (channelGroups && channelGroups.length !== 0) query['channel-group'] = channelGroups.join(',');
if (state) query.state = JSON.stringify(state);
if (state !== undefined) query.state = JSON.stringify(state);

return query;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/endpoints/presence/set_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class SetPresenceStateRequest extends AbstractRequest<Presence.SetPresenc
} = this.parameters;

if (!subscribeKey) return 'Missing Subscribe Key';
if (!state) return 'Missing State';
if (state === undefined) return 'Missing State';
if (channels?.length === 0 && channelGroups?.length === 0)
return 'Please provide a list of channels and/or channel-groups';
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/pubnub-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2549,7 +2549,7 @@ export class PubNubCore<

const request = new GetPresenceStateRequest({
...parameters,
uuid: parameters.uuid ?? this._configuration.userId,
uuid: parameters.uuid ?? this._configuration.userId!,
keySet: this._configuration.keySet,
});
const logResponse = (response: Presence.GetPresenceStateResponse | null) => {
Expand Down
Loading
Loading