{"action":"created","comment":{"url":"https://api.github.com/repos/parse-community/parse-server/pulls/comments/209052401","pull_request_review_id":144992724,"id":209052401,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTA1MjQwMQ==","diff_hunk":"@@ -393,44 +408,39 @@ export function maybeRunQueryTrigger(triggerType, className, restWhere, restOpti\n // Resolves to an object, empty or containing an object key. A beforeSave\n // trigger will set the object key to the rest format object to save.\n // originalParseObject is optional, we only need that for before/afterSave functions\n-export function maybeRunTrigger(triggerType, auth, parseObject, originalParseObject, config) {\n+export function maybeRunTrigger(triggerType, auth, parseObject, originalParseObject, config, context) {\n   if (!parseObject) {\n     return Promise.resolve({});\n   }\n   return new Promise(function (resolve, reject) {\n     var trigger = getTrigger(parseObject.className, triggerType, config.applicationId);\n     if (!trigger) return resolve();\n-    var request = getRequestObject(triggerType, auth, parseObject, originalParseObject, config);\n-    var response = getResponseObject(request, (object) => {\n+    var request = getRequestObject(triggerType, auth, parseObject, originalParseObject, config, context);\n+    var { success, error } = getResponseObject(request, (object) => {\n       logTriggerSuccessBeforeHook(\n         triggerType, parseObject.className, parseObject.toJSON(), object, auth);\n+      if (triggerType === Types.beforeSave || triggerType === Types.afterSave) {\n+        Object.assign(context, request.context);\n+      }\n       resolve(object);\n     }, (error) => {\n       logTriggerErrorBeforeHook(\n         triggerType, parseObject.className, parseObject.toJSON(), auth, error);\n       reject(error);\n     });\n-    // Force the current Parse app before the trigger\n-    Parse.applicationId = config.applicationId;\n-    Parse.javascriptKey = config.javascriptKey || '';\n-    Parse.masterKey = config.masterKey;\n \n     // AfterSave and afterDelete triggers can return a promise, which if they\n     // do, needs to be resolved before this promise is resolved,\n     // so trigger execution is synced with RestWrite.execute() call.\n     // If triggers do not return a promise, they can run async code parallel\n     // to the RestWrite.execute() call.\n-    var triggerPromise = trigger(request, response);\n-    if(triggerType === Types.afterSave || triggerType === Types.afterDelete)\n-    {\n-      logTriggerAfterHook(triggerType, parseObject.className, parseObject.toJSON(), auth);\n-      if(triggerPromise && typeof triggerPromise.then === \"function\") {\n-        return triggerPromise.then(resolve, resolve);\n+    return Promise.resolve().then(() => {\n+      const promise = trigger(request);\n+      if(triggerType === Types.afterSave || triggerType === Types.afterDelete) {\n+        logTriggerAfterHook(triggerType, parseObject.className, parseObject.toJSON(), auth);\n       }\n-      else {\n-        return resolve();\n-      }\n-    }\n+      return promise;\n+    }).then(success, error);","path":"src/triggers.js","position":265,"original_position":265,"commit_id":"dbedbcd0c5f948cd4b613b778cd8138e0ab6b8af","original_commit_id":"dbedbcd0c5f948cd4b613b778cd8138e0ab6b8af","user":{"login":"flovilmart","id":364568,"node_id":"MDQ6VXNlcjM2NDU2OA==","avatar_url":"https://avatars3.githubusercontent.com/u/364568?v=4","gravatar_id":"","url":"https://api.github.com/users/flovilmart","html_url":"https://github.com/flovilmart","followers_url":"https://api.github.com/users/flovilmart/followers","following_url":"https://api.github.com/users/flovilmart/following{/other_user}","gists_url":"https://api.github.com/users/flovilmart/gists{/gist_id}","starred_url":"https://api.github.com/users/flovilmart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flovilmart/subscriptions","organizations_url":"https://api.github.com/users/flovilmart/orgs","repos_url":"https://api.github.com/users/flovilmart/repos","events_url":"https://api.github.com/users/flovilmart/events{/privacy}","received_events_url":"https://api.github.com/users/flovilmart/received_events","type":"User","site_admin":false},"body":"IN that case it believe we want to forward the error to the next step, not at this one.","created_at":"2018-08-09T19:33:01Z","updated_at":"2018-08-09T19:41:01Z","html_url":"https://github.com/parse-community/parse-server/pull/4943#discussion_r209052401","pull_request_url":"https://api.github.com/repos/parse-community/parse-server/pulls/4943","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/parse-community/parse-server/pulls/comments/209052401"},"html":{"href":"https://github.com/parse-community/parse-server/pull/4943#discussion_r209052401"},"pull_request":{"href":"https://api.github.com/repos/parse-community/parse-server/pulls/4943"}},"in_reply_to_id":209051566},"pull_request":{"url":"https://api.github.com/repos/parse-community/parse-server/pulls/4943","id":207397143,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3Mzk3MTQz","html_url":"https://github.com/parse-community/parse-server/pull/4943","diff_url":"https://github.com/parse-community/parse-server/pull/4943.diff","patch_url":"https://github.com/parse-community/parse-server/pull/4943.patch","issue_url":"https://api.github.com/repos/parse-community/parse-server/issues/4943","number":4943,"state":"open","locked":false,"title":"version 3.0.0 API Docs","user":{"login":"flovilmart","id":364568,"node_id":"MDQ6VXNlcjM2NDU2OA==","avatar_url":"https://avatars3.githubusercontent.com/u/364568?v=4","gravatar_id":"","url":"https://api.github.com/users/flovilmart","html_url":"https://github.com/flovilmart","followers_url":"https://api.github.com/users/flovilmart/followers","following_url":"https://api.github.com/users/flovilmart/following{/other_user}","gists_url":"https://api.github.com/users/flovilmart/gists{/gist_id}","starred_url":"https://api.github.com/users/flovilmart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flovilmart/subscriptions","organizations_url":"https://api.github.com/users/flovilmart/orgs","repos_url":"https://api.github.com/users/flovilmart/repos","events_url":"https://api.github.com/users/flovilmart/events{/privacy}","received_events_url":"https://api.github.com/users/flovilmart/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-08-09T18:01:29Z","updated_at":"2018-08-09T19:41:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dc931687855ba0ecb9041bdb327fb97744c85b63","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/parse-community/parse-server/pulls/4943/commits","review_comments_url":"https://api.github.com/repos/parse-community/parse-server/pulls/4943/comments","review_comment_url":"https://api.github.com/repos/parse-community/parse-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/parse-community/parse-server/issues/4943/comments","statuses_url":"https://api.github.com/repos/parse-community/parse-server/statuses/dbedbcd0c5f948cd4b613b778cd8138e0ab6b8af","head":{"label":"parse-community:api-docs","ref":"api-docs","sha":"dbedbcd0c5f948cd4b613b778cd8138e0ab6b8af","user":{"login":"parse-community","id":26932219,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2OTMyMjE5","avatar_url":"https://avatars3.githubusercontent.com/u/26932219?v=4","gravatar_id":"","url":"https://api.github.com/users/parse-community","html_url":"https://github.com/parse-community","followers_url":"https://api.github.com/users/parse-community/followers","following_url":"https://api.github.com/users/parse-community/following{/other_user}","gists_url":"https://api.github.com/users/parse-community/gists{/gist_id}","starred_url":"https://api.github.com/users/parse-community/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parse-community/subscriptions","organizations_url":"https://api.github.com/users/parse-community/orgs","repos_url":"https://api.github.com/users/parse-community/repos","events_url":"https://api.github.com/users/parse-community/events{/privacy}","received_events_url":"https://api.github.com/users/parse-community/received_events","type":"Organization","site_admin":false},"repo":{"id":50603846,"node_id":"MDEwOlJlcG9zaXRvcnk1MDYwMzg0Ng==","name":"parse-server","full_name":"parse-community/parse-server","owner":{"login":"parse-community","id":26932219,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2OTMyMjE5","avatar_url":"https://avatars3.githubusercontent.com/u/26932219?v=4","gravatar_id":"","url":"https://api.github.com/users/parse-community","html_url":"https://github.com/parse-community","followers_url":"https://api.github.com/users/parse-community/followers","following_url":"https://api.github.com/users/parse-community/following{/other_user}","gists_url":"https://api.github.com/users/parse-community/gists{/gist_id}","starred_url":"https://api.github.com/users/parse-community/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parse-community/subscriptions","organizations_url":"https://api.github.com/users/parse-community/orgs","repos_url":"https://api.github.com/users/parse-community/repos","events_url":"https://api.github.com/users/parse-community/events{/privacy}","received_events_url":"https://api.github.com/users/parse-community/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/parse-community/parse-server","description":"Parse-compatible API server module for Node/Express","fork":false,"url":"https://api.github.com/repos/parse-community/parse-server","forks_url":"https://api.github.com/repos/parse-community/parse-server/forks","keys_url":"https://api.github.com/repos/parse-community/parse-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/parse-community/parse-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/parse-community/parse-server/teams","hooks_url":"https://api.github.com/repos/parse-community/parse-server/hooks","issue_events_url":"https://api.github.com/repos/parse-community/parse-server/issues/events{/number}","events_url":"https://api.github.com/repos/parse-community/parse-server/events","assignees_url":"https://api.github.com/repos/parse-community/parse-server/assignees{/user}","branches_url":"https://api.github.com/repos/parse-community/parse-server/branches{/branch}","tags_url":"https://api.github.com/repos/parse-community/parse-server/tags","blobs_url":"https://api.github.com/repos/parse-community/parse-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/parse-community/parse-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/parse-community/parse-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/parse-community/parse-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/parse-community/parse-server/statuses/{sha}","languages_url":"https://api.github.com/repos/parse-community/parse-server/languages","stargazers_url":"https://api.github.com/repos/parse-community/parse-server/stargazers","contributors_url":"https://api.github.com/repos/parse-community/parse-server/contributors","subscribers_url":"https://api.github.com/repos/parse-community/parse-server/subscribers","subscription_url":"https://api.github.com/repos/parse-community/parse-server/subscription","commits_url":"https://api.github.com/repos/parse-community/parse-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/parse-community/parse-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/parse-community/parse-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/parse-community/parse-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/parse-community/parse-server/contents/{+path}","compare_url":"https://api.github.com/repos/parse-community/parse-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/parse-community/parse-server/merges","archive_url":"https://api.github.com/repos/parse-community/parse-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/parse-community/parse-server/downloads","issues_url":"https://api.github.com/repos/parse-community/parse-server/issues{/number}","pulls_url":"https://api.github.com/repos/parse-community/parse-server/pulls{/number}","milestones_url":"https://api.github.com/repos/parse-community/parse-server/milestones{/number}","notifications_url":"https://api.github.com/repos/parse-community/parse-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/parse-community/parse-server/labels{/name}","releases_url":"https://api.github.com/repos/parse-community/parse-server/releases{/id}","deployments_url":"https://api.github.com/repos/parse-community/parse-server/deployments","created_at":"2016-01-28T18:29:14Z","updated_at":"2018-08-09T17:02:13Z","pushed_at":"2018-08-09T18:33:06Z","git_url":"git://github.com/parse-community/parse-server.git","ssh_url":"git@github.com:parse-community/parse-server.git","clone_url":"https://github.com/parse-community/parse-server.git","svn_url":"https://github.com/parse-community/parse-server","homepage":"http://parseplatform.org","size":6484,"stargazers_count":15390,"watchers_count":15390,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4025,"mirror_url":null,"archived":false,"open_issues_count":259,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4025,"open_issues":259,"watchers":15390,"default_branch":"master"}},"base":{"label":"parse-community:master","ref":"master","sha":"2ae603574c71f0653e3eb4011456bc82c19c5d84","user":{"login":"parse-community","id":26932219,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2OTMyMjE5","avatar_url":"https://avatars3.githubusercontent.com/u/26932219?v=4","gravatar_id":"","url":"https://api.github.com/users/parse-community","html_url":"https://github.com/parse-community","followers_url":"https://api.github.com/users/parse-community/followers","following_url":"https://api.github.com/users/parse-community/following{/other_user}","gists_url":"https://api.github.com/users/parse-community/gists{/gist_id}","starred_url":"https://api.github.com/users/parse-community/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parse-community/subscriptions","organizations_url":"https://api.github.com/users/parse-community/orgs","repos_url":"https://api.github.com/users/parse-community/repos","events_url":"https://api.github.com/users/parse-community/events{/privacy}","received_events_url":"https://api.github.com/users/parse-community/received_events","type":"Organization","site_admin":false},"repo":{"id":50603846,"node_id":"MDEwOlJlcG9zaXRvcnk1MDYwMzg0Ng==","name":"parse-server","full_name":"parse-community/parse-server","owner":{"login":"parse-community","id":26932219,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2OTMyMjE5","avatar_url":"https://avatars3.githubusercontent.com/u/26932219?v=4","gravatar_id":"","url":"https://api.github.com/users/parse-community","html_url":"https://github.com/parse-community","followers_url":"https://api.github.com/users/parse-community/followers","following_url":"https://api.github.com/users/parse-community/following{/other_user}","gists_url":"https://api.github.com/users/parse-community/gists{/gist_id}","starred_url":"https://api.github.com/users/parse-community/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parse-community/subscriptions","organizations_url":"https://api.github.com/users/parse-community/orgs","repos_url":"https://api.github.com/users/parse-community/repos","events_url":"https://api.github.com/users/parse-community/events{/privacy}","received_events_url":"https://api.github.com/users/parse-community/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/parse-community/parse-server","description":"Parse-compatible API server module for Node/Express","fork":false,"url":"https://api.github.com/repos/parse-community/parse-server","forks_url":"https://api.github.com/repos/parse-community/parse-server/forks","keys_url":"https://api.github.com/repos/parse-community/parse-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/parse-community/parse-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/parse-community/parse-server/teams","hooks_url":"https://api.github.com/repos/parse-community/parse-server/hooks","issue_events_url":"https://api.github.com/repos/parse-community/parse-server/issues/events{/number}","events_url":"https://api.github.com/repos/parse-community/parse-server/events","assignees_url":"https://api.github.com/repos/parse-community/parse-server/assignees{/user}","branches_url":"https://api.github.com/repos/parse-community/parse-server/branches{/branch}","tags_url":"https://api.github.com/repos/parse-community/parse-server/tags","blobs_url":"https://api.github.com/repos/parse-community/parse-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/parse-community/parse-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/parse-community/parse-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/parse-community/parse-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/parse-community/parse-server/statuses/{sha}","languages_url":"https://api.github.com/repos/parse-community/parse-server/languages","stargazers_url":"https://api.github.com/repos/parse-community/parse-server/stargazers","contributors_url":"https://api.github.com/repos/parse-community/parse-server/contributors","subscribers_url":"https://api.github.com/repos/parse-community/parse-server/subscribers","subscription_url":"https://api.github.com/repos/parse-community/parse-server/subscription","commits_url":"https://api.github.com/repos/parse-community/parse-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/parse-community/parse-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/parse-community/parse-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/parse-community/parse-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/parse-community/parse-server/contents/{+path}","compare_url":"https://api.github.com/repos/parse-community/parse-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/parse-community/parse-server/merges","archive_url":"https://api.github.com/repos/parse-community/parse-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/parse-community/parse-server/downloads","issues_url":"https://api.github.com/repos/parse-community/parse-server/issues{/number}","pulls_url":"https://api.github.com/repos/parse-community/parse-server/pulls{/number}","milestones_url":"https://api.github.com/repos/parse-community/parse-server/milestones{/number}","notifications_url":"https://api.github.com/repos/parse-community/parse-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/parse-community/parse-server/labels{/name}","releases_url":"https://api.github.com/repos/parse-community/parse-server/releases{/id}","deployments_url":"https://api.github.com/repos/parse-community/parse-server/deployments","created_at":"2016-01-28T18:29:14Z","updated_at":"2018-08-09T17:02:13Z","pushed_at":"2018-08-09T18:33:06Z","git_url":"git://github.com/parse-community/parse-server.git","ssh_url":"git@github.com:parse-community/parse-server.git","clone_url":"https://github.com/parse-community/parse-server.git","svn_url":"https://github.com/parse-community/parse-server","homepage":"http://parseplatform.org","size":6484,"stargazers_count":15390,"watchers_count":15390,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4025,"mirror_url":null,"archived":false,"open_issues_count":259,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4025,"open_issues":259,"watchers":15390,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/parse-community/parse-server/pulls/4943"},"html":{"href":"https://github.com/parse-community/parse-server/pull/4943"},"issue":{"href":"https://api.github.com/repos/parse-community/parse-server/issues/4943"},"comments":{"href":"https://api.github.com/repos/parse-community/parse-server/issues/4943/comments"},"review_comments":{"href":"https://api.github.com/repos/parse-community/parse-server/pulls/4943/comments"},"review_comment":{"href":"https://api.github.com/repos/parse-community/parse-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/parse-community/parse-server/pulls/4943/commits"},"statuses":{"href":"https://api.github.com/repos/parse-community/parse-server/statuses/dbedbcd0c5f948cd4b613b778cd8138e0ab6b8af"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"flovilmart"}}