Skip to content
This repository has been archived by the owner on Dec 5, 2020. It is now read-only.

Commit

Permalink
Merge 7b00ac3 into f5c87a8
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Jul 12, 2017
2 parents f5c87a8 + 7b00ac3 commit f34aad8
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@

import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.List;

import javax.ejb.Asynchronous;
import javax.ejb.Stateless;
import javax.json.JsonObject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.slf4j.Logger;
Expand Down Expand Up @@ -122,6 +126,32 @@ public Response postNotifications(String notifications) {
return Response.serverError().build();
}

/**
* Webhook for Github issue_comment event.
* @param issueComment Event Json payload.
* @see https://developer.github.com/v3/activity/events/types/#webhook-event-name-13
* @return Http response.
*/
@POST
@Path("/github/issuecomment")
@Consumes(MediaType.APPLICATION_JSON)
public Response webhook(JsonObject issueComment) {
Notification notification = new Notification();
notification.setIssueNumber(
issueComment.getJsonObject("issue").getInt("number")
);
notification.setRepoFullName(
issueComment.getJsonObject("repository").getString("full_name")
);
List<Notification> notifications = new ArrayList<>();
notifications.add(notification);
boolean startedHandling = this.handleNotifications(notifications);
if(startedHandling) {
return Response.ok().build();
}
return Response.serverError().build();
}

/**
* Handles notifications, starts one action thread for each of them.
* @param notifications List of notifications.
Expand Down

0 comments on commit f34aad8

Please sign in to comment.