Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/rorschach.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Rebert <code@rebertia.com>2014-07-02 03:56:28 +0400
committerChris Rebert <code@rebertia.com>2014-07-02 03:56:28 +0400
commitad4eb88c917a80e5be7963908e51a5ff12de9615 (patch)
tree35a4a3f26767871883de25ab56657413b53458af
parent388290f84285acc6dd3ded85728c8d6196384336 (diff)
fixup GitHubPullRequestWebHooksDirectives
-rw-r--r--src/main/scala/com/getbootstrap/rorschach/server/GitHubPullRequestWebHooksDirectives.scala17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/main/scala/com/getbootstrap/rorschach/server/GitHubPullRequestWebHooksDirectives.scala b/src/main/scala/com/getbootstrap/rorschach/server/GitHubPullRequestWebHooksDirectives.scala
index f8ea9cb..6ea7d47 100644
--- a/src/main/scala/com/getbootstrap/rorschach/server/GitHubPullRequestWebHooksDirectives.scala
+++ b/src/main/scala/com/getbootstrap/rorschach/server/GitHubPullRequestWebHooksDirectives.scala
@@ -1,23 +1,22 @@
package com.getbootstrap.rorschach.server
-import com.getbootstrap.rorschach.github.{IssueOrCommentEvent, GitHubJsonProtocol}
import scala.util.{Success, Failure, Try}
-import spray.json._
import spray.routing.{Directive1, ValidationRejection}
import spray.routing.directives.{BasicDirectives, RouteDirectives}
+import org.eclipse.egit.github.core.event.PullRequestPayload
+import org.eclipse.egit.github.core.client.GsonUtils
-trait GitHubIssuesWebHooksDirectives {
+trait GitHubPullRequestWebHooksDirectives {
import RouteDirectives.reject
import BasicDirectives.provide
import HubSignatureDirectives.stringEntityMatchingHubSignature
- import GitHubJsonProtocol._
- def authenticatedIssueOrCommentEvent(secretKey: Array[Byte]): Directive1[IssueOrCommentEvent] = stringEntityMatchingHubSignature(secretKey).flatMap{ entityJsonString =>
- Try{ entityJsonString.parseJson.convertTo[IssueOrCommentEvent] } match {
- case Failure(err) => reject(ValidationRejection("JSON either malformed or does not match expected schema!"))
- case Success(event) => provide(event)
+ def authenticatedPullRequestEvent(secretKey: Array[Byte]): Directive1[PullRequestPayload] = stringEntityMatchingHubSignature(secretKey).flatMap{ entityJsonString =>
+ Try { GsonUtils.fromJson(entityJsonString, classOf[PullRequestPayload]) } match {
+ case Failure(exc) => reject(ValidationRejection("JSON was either malformed or did not match expected schema!"))
+ case Success(payload) => provide(payload)
}
}
}
-object GitHubIssuesWebHooksDirectives extends GitHubIssuesWebHooksDirectives
+object GitHubPullRequestWebHooksDirectives extends GitHubPullRequestWebHooksDirectives