-
Notifications
You must be signed in to change notification settings - Fork 776
#947 base event payload #976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,15 +24,16 @@ public class GHEventPayload { | |
| // Webhook payload object common properties: action, sender, repository, organization, installation | ||
| private String action; | ||
| private GHUser sender; | ||
| GHRepository repository; | ||
| private GHRepository repository; | ||
| private GHOrganization organization; | ||
| GHAppInstallation installation; | ||
| private GHAppInstallation installation; | ||
|
|
||
| GHEventPayload() { | ||
| } | ||
|
|
||
| /** | ||
| * Most webhook payloads contain an action property that contains the specific activity that triggered the event. | ||
| * Gets the action for the triggered event. Most but not all webhook payloads contain an action property that | ||
| * contains the specific activity that triggered the event. | ||
| * | ||
| * @return event action | ||
| */ | ||
|
|
@@ -112,11 +113,14 @@ void wrapUp(GitHub root) { | |
| sender.wrapUp(root); | ||
| } | ||
| if (repository != null) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aggregated from overriden |
||
| repository.root = root; | ||
| repository.wrap(root); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: |
||
| } | ||
| if (organization != null) { | ||
| organization.wrapUp(root); | ||
| } | ||
| if (installation != null) { | ||
| installation.wrapUp(root); | ||
| } | ||
| } | ||
|
|
||
| // List of events that still need to be added: | ||
|
|
@@ -192,8 +196,8 @@ void wrapUp(GitHub root) { | |
| if (checkRun == null) | ||
| throw new IllegalStateException( | ||
| "Expected check_run payload, but got something else. Maybe we've got another type of event?"); | ||
| GHRepository repository = getRepository(); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inherited |
||
| checkRun.wrap(repository); | ||
| } else { | ||
| checkRun.wrap(root); | ||
|
|
@@ -226,8 +230,8 @@ void wrapUp(GitHub root) { | |
| if (checkSuite == null) | ||
| throw new IllegalStateException( | ||
| "Expected check_suite payload, but got something else. Maybe we've got another type of event?"); | ||
| GHRepository repository = getRepository(); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| checkSuite.wrap(repository); | ||
| } else { | ||
| checkSuite.wrap(root); | ||
|
|
@@ -258,11 +262,10 @@ public List<GHRepository> getRepositories() { | |
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| if (installation == null) | ||
| if (getInstallation() == null) { | ||
| throw new IllegalStateException( | ||
| "Expected check_suite payload, but got something else. Maybe we've got another type of event?"); | ||
| else | ||
| installation.wrapUp(root); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inherited |
||
| } | ||
|
|
||
| if (repositories != null && !repositories.isEmpty()) { | ||
| try { | ||
|
|
@@ -320,11 +323,10 @@ public List<GHRepository> getRepositoriesRemoved() { | |
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| if (installation == null) | ||
| if (getInstallation() == null) { | ||
| throw new IllegalStateException( | ||
| "Expected check_suite payload, but got something else. Maybe we've got another type of event?"); | ||
| else | ||
| installation.wrapUp(root); | ||
| } | ||
|
|
||
| List<GHRepository> repositories; | ||
| if ("added".equals(getAction())) | ||
|
|
@@ -393,8 +395,8 @@ void wrapUp(GitHub root) { | |
| if (pullRequest == null) | ||
| throw new IllegalStateException( | ||
| "Expected pull_request payload, but got something else. Maybe we've got another type of event?"); | ||
| GHRepository repository = getRepository(); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| pullRequest.wrapUp(repository); | ||
| } else { | ||
| pullRequest.wrapUp(root); | ||
|
|
@@ -441,8 +443,8 @@ void wrapUp(GitHub root) { | |
|
|
||
| review.wrapUp(pullRequest); | ||
|
|
||
| GHRepository repository = getRepository(); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| pullRequest.wrapUp(repository); | ||
| } else { | ||
| pullRequest.wrapUp(root); | ||
|
|
@@ -489,8 +491,8 @@ void wrapUp(GitHub root) { | |
|
|
||
| comment.wrapUp(pullRequest); | ||
|
|
||
| GHRepository repository = getRepository(); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| pullRequest.wrapUp(repository); | ||
| } else { | ||
| pullRequest.wrapUp(root); | ||
|
|
@@ -531,8 +533,8 @@ public void setIssue(GHIssue issue) { | |
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| GHRepository repository = getRepository(); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| issue.wrap(repository); | ||
| } else { | ||
| issue.wrap(root); | ||
|
|
@@ -593,8 +595,8 @@ public void setIssue(GHIssue issue) { | |
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| GHRepository repository = getRepository(); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| issue.wrap(repository); | ||
| } else { | ||
| issue.wrap(root); | ||
|
|
@@ -636,8 +638,8 @@ public void setComment(GHCommitComment comment) { | |
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| GHRepository repository = getRepository(); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| comment.wrap(repository); | ||
| } | ||
| } | ||
|
|
@@ -695,14 +697,6 @@ public String getMasterBranch() { | |
| public String getDescription() { | ||
| return description; | ||
| } | ||
|
|
||
| @Override | ||
| void wrapUp(GitHub root) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fully inherited - hence removed |
||
| super.wrapUp(root); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -735,14 +729,6 @@ public String getRef() { | |
| public String getRefType() { | ||
| return refType; | ||
| } | ||
|
|
||
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -777,8 +763,8 @@ public void setDeployment(GHDeployment deployment) { | |
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| GHRepository repository = getRepository(); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| deployment.wrap(repository); | ||
| } | ||
| } | ||
|
|
@@ -837,8 +823,8 @@ public void setDeployment(GHDeployment deployment) { | |
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| GHRepository repository = getRepository(); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| deployment.wrap(repository); | ||
| deploymentStatus.wrap(repository); | ||
| } | ||
|
|
@@ -878,9 +864,6 @@ public void setForkee(GHRepository forkee) { | |
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| forkee.wrap(root); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -891,12 +874,6 @@ void wrapUp(GitHub root) { | |
| * event</a> | ||
| */ | ||
| public static class Ping extends GHEventPayload { | ||
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| if (repository != null) | ||
| repository.wrap(root); | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
@@ -908,13 +885,6 @@ void wrapUp(GitHub root) { | |
| */ | ||
| public static class Public extends GHEventPayload { | ||
|
|
||
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| if (repository != null) | ||
| repository.wrap(root); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1038,13 +1008,6 @@ public String getCompare() { | |
| return compare; | ||
| } | ||
|
|
||
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| if (repository != null) | ||
| repository.wrap(root); | ||
| } | ||
|
|
||
| /** | ||
| * The type Pusher. | ||
| */ | ||
|
|
@@ -1218,14 +1181,6 @@ public GHRelease getRelease() { | |
| public void setRelease(GHRelease release) { | ||
| this.release = release; | ||
| } | ||
|
|
||
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1236,11 +1191,7 @@ void wrapUp(GitHub root) { | |
| * @see <a href="https://docs.github.com/en/rest/reference/repos">Repositories</a> | ||
| */ | ||
| public static class Repository extends GHEventPayload { | ||
| @Override | ||
| void wrapUp(GitHub root) { | ||
| super.wrapUp(root); | ||
| repository.wrap(root); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1319,8 +1270,8 @@ void wrapUp(GitHub root) { | |
| throw new IllegalStateException( | ||
| "Expected status payload, but got something else. Maybe we've got another type of event?"); | ||
| } | ||
| GHRepository repository = getRepository(); | ||
| if (repository != null) { | ||
| repository.wrap(root); | ||
| commit.wrapUp(repository); | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as declared in #947 moved from subclasses. Field may be null depending on the event type