123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.ParseCloudCodePublisher = void 0;
- var _ParsePubSub = require("./ParsePubSub");
- var _node = _interopRequireDefault(require("parse/node"));
- var _logger = _interopRequireDefault(require("../logger"));
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
- class ParseCloudCodePublisher {
- // config object of the publisher, right now it only contains the redisURL,
- // but we may extend it later.
- constructor(config = {}) {
- this.parsePublisher = _ParsePubSub.ParsePubSub.createPublisher(config);
- }
- async connect() {
- if (typeof this.parsePublisher.connect === 'function') {
- if (this.parsePublisher.isOpen) {
- return;
- }
- return Promise.resolve(this.parsePublisher.connect());
- }
- }
- onCloudCodeAfterSave(request) {
- this._onCloudCodeMessage(_node.default.applicationId + 'afterSave', request);
- }
- onCloudCodeAfterDelete(request) {
- this._onCloudCodeMessage(_node.default.applicationId + 'afterDelete', request);
- }
- onClearCachedRoles(user) {
- this.parsePublisher.publish(_node.default.applicationId + 'clearCache', JSON.stringify({
- userId: user.id
- }));
- }
- // Request is the request object from cloud code functions. request.object is a ParseObject.
- _onCloudCodeMessage(type, request) {
- _logger.default.verbose('Raw request from cloud code current : %j | original : %j', request.object, request.original);
- // We need the full JSON which includes className
- const message = {
- currentParseObject: request.object._toFullJSON()
- };
- if (request.original) {
- message.originalParseObject = request.original._toFullJSON();
- }
- if (request.classLevelPermissions) {
- message.classLevelPermissions = request.classLevelPermissions;
- }
- this.parsePublisher.publish(type, JSON.stringify(message));
- }
- }
- exports.ParseCloudCodePublisher = ParseCloudCodePublisher;
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfUGFyc2VQdWJTdWIiLCJyZXF1aXJlIiwiX25vZGUiLCJfaW50ZXJvcFJlcXVpcmVEZWZhdWx0IiwiX2xvZ2dlciIsImUiLCJfX2VzTW9kdWxlIiwiZGVmYXVsdCIsIl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