| 86 | } |
| 87 | |
| 88 | saveHook(hook) { |
| 89 | var query; |
| 90 | if (hook.functionName && hook.url) { |
| 91 | query = { functionName: hook.functionName }; |
| 92 | } else if (hook.triggerName && hook.className && hook.url) { |
| 93 | query = { className: hook.className, triggerName: hook.triggerName }; |
| 94 | } else { |
| 95 | throw new Parse.Error(143, 'invalid hook declaration'); |
| 96 | } |
| 97 | return this.database |
| 98 | .update(DefaultHooksCollectionName, query, hook, { upsert: true }) |
| 99 | .then(() => { |
| 100 | return Promise.resolve(hook); |
| 101 | }); |
| 102 | } |
| 103 | |
| 104 | addHookToTriggers(hook) { |
| 105 | var wrappedFunction = wrapToHTTPRequest(hook, this._webhookKey); |