Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix installationId on LiveQuery connect #6180

Merged
merged 1 commit into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions spec/ParseLiveQueryServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ describe('ParseLiveQueryServer', function() {
query: query,
requestId: requestId,
sessionToken: 'sessionToken',
installationId: 'installationId',
};
parseLiveQueryServer._handleSubscribe(parseWebSocket, request);

Expand All @@ -360,7 +359,6 @@ describe('ParseLiveQueryServer', function() {
expect(args[0]).toBe(requestId);
expect(args[1].fields).toBe(query.fields);
expect(args[1].sessionToken).toBe(request.sessionToken);
expect(args[1].installationId).toBe(request.installationId);
// Make sure we send subscribe response to the client
expect(client.pushSubscribe).toHaveBeenCalledWith(requestId);
});
Expand Down Expand Up @@ -518,6 +516,7 @@ describe('ParseLiveQueryServer', function() {
const connectRequest = {
op: 'connect',
applicationId: '1',
installationId: '1234',
};
// Trigger message event
parseWebSocket.emit('message', connectRequest);
Expand Down
6 changes: 5 additions & 1 deletion src/LiveQuery/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Client {
parseWebSocket: any;
hasMasterKey: boolean;
sessionToken: string;
installationId: string;
userId: string;
roles: Array<string>;
subscriptionInfos: Object;
Expand All @@ -32,12 +33,14 @@ class Client {
id: number,
parseWebSocket: any,
hasMasterKey: boolean = false,
sessionToken: string
sessionToken: string,
installationId: string
) {
this.id = id;
this.parseWebSocket = parseWebSocket;
this.hasMasterKey = hasMasterKey;
this.sessionToken = sessionToken;
this.installationId = installationId;
this.roles = [];
this.subscriptionInfos = new Map();
this.pushConnect = this._pushEvent('connected');
Expand Down Expand Up @@ -93,6 +96,7 @@ class Client {
const response: Message = {
op: type,
clientId: this.id,
installationId: this.installationId,
};
if (typeof subscriptionId !== 'undefined') {
response['requestId'] = subscriptionId;
Expand Down
10 changes: 4 additions & 6 deletions src/LiveQuery/ParseLiveQueryServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ class ParseLiveQueryServer {
clientId,
parseWebsocket,
hasMasterKey,
request.sessionToken
request.sessionToken,
request.installationId
);
parseWebsocket.clientId = clientId;
this.clients.set(parseWebsocket.clientId, client);
Expand Down Expand Up @@ -679,9 +680,6 @@ class ParseLiveQueryServer {
if (request.sessionToken) {
subscriptionInfo.sessionToken = request.sessionToken;
}
if (request.installationId) {
subscriptionInfo.installationId = request.installationId;
}
client.addSubscriptionInfo(request.requestId, subscriptionInfo);

// Add clientId to subscription
Expand All @@ -703,7 +701,7 @@ class ParseLiveQueryServer {
subscriptions: this.subscriptions.size,
sessionToken: request.sessionToken,
useMasterKey: client.hasMasterKey,
installationId: request.installationId,
installationId: client.installationId,
});
}

Expand Down Expand Up @@ -785,7 +783,7 @@ class ParseLiveQueryServer {
subscriptions: this.subscriptions.size,
sessionToken: subscriptionInfo.sessionToken,
useMasterKey: client.hasMasterKey,
installationId: subscriptionInfo.installationId,
installationId: client.installationId,
});

if (!notifyClient) {
Expand Down
3 changes: 3 additions & 0 deletions src/LiveQuery/RequestSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const connect = {
sessionToken: {
type: 'string',
},
installationId: {
type: 'string',
},
},
required: ['op', 'applicationId'],
additionalProperties: false,
Expand Down