Fix installationId on LiveQuery connect (#6180)
Throws an error and prevents LiveQuery from reconnecting. Fixes Monitoring installationId. Allow installationId to be sent to and from client.
This commit is contained in:
@@ -337,7 +337,6 @@ describe('ParseLiveQueryServer', function() {
|
|||||||
query: query,
|
query: query,
|
||||||
requestId: requestId,
|
requestId: requestId,
|
||||||
sessionToken: 'sessionToken',
|
sessionToken: 'sessionToken',
|
||||||
installationId: 'installationId',
|
|
||||||
};
|
};
|
||||||
parseLiveQueryServer._handleSubscribe(parseWebSocket, request);
|
parseLiveQueryServer._handleSubscribe(parseWebSocket, request);
|
||||||
|
|
||||||
@@ -360,7 +359,6 @@ describe('ParseLiveQueryServer', function() {
|
|||||||
expect(args[0]).toBe(requestId);
|
expect(args[0]).toBe(requestId);
|
||||||
expect(args[1].fields).toBe(query.fields);
|
expect(args[1].fields).toBe(query.fields);
|
||||||
expect(args[1].sessionToken).toBe(request.sessionToken);
|
expect(args[1].sessionToken).toBe(request.sessionToken);
|
||||||
expect(args[1].installationId).toBe(request.installationId);
|
|
||||||
// Make sure we send subscribe response to the client
|
// Make sure we send subscribe response to the client
|
||||||
expect(client.pushSubscribe).toHaveBeenCalledWith(requestId);
|
expect(client.pushSubscribe).toHaveBeenCalledWith(requestId);
|
||||||
});
|
});
|
||||||
@@ -518,6 +516,7 @@ describe('ParseLiveQueryServer', function() {
|
|||||||
const connectRequest = {
|
const connectRequest = {
|
||||||
op: 'connect',
|
op: 'connect',
|
||||||
applicationId: '1',
|
applicationId: '1',
|
||||||
|
installationId: '1234',
|
||||||
};
|
};
|
||||||
// Trigger message event
|
// Trigger message event
|
||||||
parseWebSocket.emit('message', connectRequest);
|
parseWebSocket.emit('message', connectRequest);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class Client {
|
|||||||
parseWebSocket: any;
|
parseWebSocket: any;
|
||||||
hasMasterKey: boolean;
|
hasMasterKey: boolean;
|
||||||
sessionToken: string;
|
sessionToken: string;
|
||||||
|
installationId: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
roles: Array<string>;
|
roles: Array<string>;
|
||||||
subscriptionInfos: Object;
|
subscriptionInfos: Object;
|
||||||
@@ -32,12 +33,14 @@ class Client {
|
|||||||
id: number,
|
id: number,
|
||||||
parseWebSocket: any,
|
parseWebSocket: any,
|
||||||
hasMasterKey: boolean = false,
|
hasMasterKey: boolean = false,
|
||||||
sessionToken: string
|
sessionToken: string,
|
||||||
|
installationId: string
|
||||||
) {
|
) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.parseWebSocket = parseWebSocket;
|
this.parseWebSocket = parseWebSocket;
|
||||||
this.hasMasterKey = hasMasterKey;
|
this.hasMasterKey = hasMasterKey;
|
||||||
this.sessionToken = sessionToken;
|
this.sessionToken = sessionToken;
|
||||||
|
this.installationId = installationId;
|
||||||
this.roles = [];
|
this.roles = [];
|
||||||
this.subscriptionInfos = new Map();
|
this.subscriptionInfos = new Map();
|
||||||
this.pushConnect = this._pushEvent('connected');
|
this.pushConnect = this._pushEvent('connected');
|
||||||
@@ -93,6 +96,7 @@ class Client {
|
|||||||
const response: Message = {
|
const response: Message = {
|
||||||
op: type,
|
op: type,
|
||||||
clientId: this.id,
|
clientId: this.id,
|
||||||
|
installationId: this.installationId,
|
||||||
};
|
};
|
||||||
if (typeof subscriptionId !== 'undefined') {
|
if (typeof subscriptionId !== 'undefined') {
|
||||||
response['requestId'] = subscriptionId;
|
response['requestId'] = subscriptionId;
|
||||||
|
|||||||
@@ -584,7 +584,8 @@ class ParseLiveQueryServer {
|
|||||||
clientId,
|
clientId,
|
||||||
parseWebsocket,
|
parseWebsocket,
|
||||||
hasMasterKey,
|
hasMasterKey,
|
||||||
request.sessionToken
|
request.sessionToken,
|
||||||
|
request.installationId
|
||||||
);
|
);
|
||||||
parseWebsocket.clientId = clientId;
|
parseWebsocket.clientId = clientId;
|
||||||
this.clients.set(parseWebsocket.clientId, client);
|
this.clients.set(parseWebsocket.clientId, client);
|
||||||
@@ -679,9 +680,6 @@ class ParseLiveQueryServer {
|
|||||||
if (request.sessionToken) {
|
if (request.sessionToken) {
|
||||||
subscriptionInfo.sessionToken = request.sessionToken;
|
subscriptionInfo.sessionToken = request.sessionToken;
|
||||||
}
|
}
|
||||||
if (request.installationId) {
|
|
||||||
subscriptionInfo.installationId = request.installationId;
|
|
||||||
}
|
|
||||||
client.addSubscriptionInfo(request.requestId, subscriptionInfo);
|
client.addSubscriptionInfo(request.requestId, subscriptionInfo);
|
||||||
|
|
||||||
// Add clientId to subscription
|
// Add clientId to subscription
|
||||||
@@ -703,7 +701,7 @@ class ParseLiveQueryServer {
|
|||||||
subscriptions: this.subscriptions.size,
|
subscriptions: this.subscriptions.size,
|
||||||
sessionToken: request.sessionToken,
|
sessionToken: request.sessionToken,
|
||||||
useMasterKey: client.hasMasterKey,
|
useMasterKey: client.hasMasterKey,
|
||||||
installationId: request.installationId,
|
installationId: client.installationId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -785,7 +783,7 @@ class ParseLiveQueryServer {
|
|||||||
subscriptions: this.subscriptions.size,
|
subscriptions: this.subscriptions.size,
|
||||||
sessionToken: subscriptionInfo.sessionToken,
|
sessionToken: subscriptionInfo.sessionToken,
|
||||||
useMasterKey: client.hasMasterKey,
|
useMasterKey: client.hasMasterKey,
|
||||||
installationId: subscriptionInfo.installationId,
|
installationId: client.installationId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!notifyClient) {
|
if (!notifyClient) {
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ const connect = {
|
|||||||
sessionToken: {
|
sessionToken: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
|
installationId: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
required: ['op', 'applicationId'],
|
required: ['op', 'applicationId'],
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user