Skip to content

Commit

Permalink
#580 PR Merge 시 webhook 이 발송되도록 수정.
Browse files Browse the repository at this point in the history
기존 발송되지 않는 코드 제거
  • Loading branch information
hongwonjun committed Oct 31, 2019
1 parent c4d9415 commit 11fe844
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/models/NotificationEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ public String getResourceId() {
}

private static void webhookRequest(EventType eventTypes, PullRequest pullRequest, Boolean gitPushOnly) {
List<Webhook> webhookList = Webhook.findByProject(pullRequest.toProjectId);
List<Webhook> webhookList = Webhook.findByProject(pullRequest.toProject.id);
for (Webhook webhook : webhookList) {
if (gitPushOnly == webhook.gitPushOnly) {
// Send push event via webhook payload URLs.
Expand Down Expand Up @@ -680,6 +680,11 @@ public static NotificationEvent afterPullRequestUpdated(User sender, PullRequest
notiEvent.oldValue = oldState.state();
notiEvent.newValue = newState.state();
NotificationEvent.add(notiEvent);

if (newState == State.MERGED) {
webhookRequest(PULL_REQUEST_MERGED, pullRequest, false);
}

return notiEvent;
}

Expand Down Expand Up @@ -718,8 +723,6 @@ private static String newPullRequestCommitChangedMessage(PullRequest pullRequest
* @see {@link actors.PullRequestActor#processPullRequestMerging(models.PullRequestEventMessage, models.PullRequest)}
*/
public static NotificationEvent afterMerge(User sender, PullRequest pullRequest, State state) {
webhookRequest(PULL_REQUEST_MERGED, pullRequest, false);

NotificationEvent notiEvent = createFrom(sender, pullRequest);
notiEvent.title = formatReplyTitle(pullRequest);
notiEvent.receivers = state == State.MERGED ? getReceiversWithRelatedAuthors(sender, pullRequest) : getReceivers(sender, pullRequest);
Expand Down Expand Up @@ -758,7 +761,6 @@ public static NotificationEvent afterNewPullRequest(PullRequest pullRequest) {
}

public static NotificationEvent afterPullRequestUpdated(PullRequest pullRequest, State oldState, State newState) {
webhookRequest(PULL_REQUEST_STATE_CHANGED, pullRequest, false);
return afterPullRequestUpdated(UserApp.currentUser(), pullRequest, oldState, newState);
}

Expand Down

0 comments on commit 11fe844

Please sign in to comment.