Concat appId to PubSub channel (#3043)
This commit is contained in:
committed by
Florent Vilmart
parent
ee9099d6ad
commit
6264f99ad5
@@ -32,7 +32,7 @@ describe('ParseCloudCodePublisher', function() {
|
||||
var request = {};
|
||||
publisher.onCloudCodeAfterSave(request);
|
||||
|
||||
expect(publisher._onCloudCodeMessage).toHaveBeenCalledWith('afterSave', request);
|
||||
expect(publisher._onCloudCodeMessage).toHaveBeenCalledWith(Parse.applicationId + 'afterSave', request);
|
||||
});
|
||||
|
||||
it('can handle cloud code afterDelete request', function() {
|
||||
@@ -41,7 +41,7 @@ describe('ParseCloudCodePublisher', function() {
|
||||
var request = {};
|
||||
publisher.onCloudCodeAfterDelete(request);
|
||||
|
||||
expect(publisher._onCloudCodeMessage).toHaveBeenCalledWith('afterDelete', request);
|
||||
expect(publisher._onCloudCodeMessage).toHaveBeenCalledWith(Parse.applicationId + 'afterDelete', request);
|
||||
});
|
||||
|
||||
it('can handle cloud code request', function() {
|
||||
|
||||
@@ -11,11 +11,11 @@ class ParseCloudCodePublisher {
|
||||
}
|
||||
|
||||
onCloudCodeAfterSave(request: any): void {
|
||||
this._onCloudCodeMessage('afterSave', request);
|
||||
this._onCloudCodeMessage(Parse.applicationId + 'afterSave', request);
|
||||
}
|
||||
|
||||
onCloudCodeAfterDelete(request: any): void {
|
||||
this._onCloudCodeMessage('afterDelete', request);
|
||||
this._onCloudCodeMessage(Parse.applicationId + 'afterDelete', request);
|
||||
}
|
||||
|
||||
// Request is the request object from cloud code functions. request.object is a ParseObject.
|
||||
|
||||
@@ -55,8 +55,8 @@ class ParseLiveQueryServer {
|
||||
|
||||
// Initialize subscriber
|
||||
this.subscriber = ParsePubSub.createSubscriber(config);
|
||||
this.subscriber.subscribe('afterSave');
|
||||
this.subscriber.subscribe('afterDelete');
|
||||
this.subscriber.subscribe(Parse.applicationId + 'afterSave');
|
||||
this.subscriber.subscribe(Parse.applicationId + 'afterDelete');
|
||||
// Register message handler for subscriber. When publisher get messages, it will publish message
|
||||
// to the subscribers and the handler will be called.
|
||||
this.subscriber.on('message', (channel, messageStr) => {
|
||||
@@ -69,9 +69,9 @@ class ParseLiveQueryServer {
|
||||
return;
|
||||
}
|
||||
this._inflateParseObject(message);
|
||||
if (channel === 'afterSave') {
|
||||
if (channel === Parse.applicationId + 'afterSave') {
|
||||
this._onAfterSave(message);
|
||||
} else if (channel === 'afterDelete') {
|
||||
} else if (channel === Parse.applicationId + 'afterDelete') {
|
||||
this._onAfterDelete(message);
|
||||
} else {
|
||||
logger.error('Get message %s from unknown channel %j', message, channel);
|
||||
@@ -104,7 +104,7 @@ class ParseLiveQueryServer {
|
||||
// Message is the JSON object from publisher after inflated. Message.currentParseObject is the ParseObject after changes.
|
||||
// Message.originalParseObject is the original ParseObject.
|
||||
_onAfterDelete(message: any): void {
|
||||
logger.verbose('afterDelete is triggered');
|
||||
logger.verbose(Parse.applicationId + 'afterDelete is triggered');
|
||||
|
||||
let deletedParseObject = message.currentParseObject.toJSON();
|
||||
let className = deletedParseObject.className;
|
||||
@@ -145,7 +145,7 @@ class ParseLiveQueryServer {
|
||||
// Message is the JSON object from publisher after inflated. Message.currentParseObject is the ParseObject after changes.
|
||||
// Message.originalParseObject is the original ParseObject.
|
||||
_onAfterSave(message: any): void {
|
||||
logger.verbose('afterSave is triggered');
|
||||
logger.verbose(Parse.applicationId + 'afterSave is triggered');
|
||||
|
||||
let originalParseObject = null;
|
||||
if (message.originalParseObject) {
|
||||
|
||||
Reference in New Issue
Block a user