Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions web/GitHub/Types/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,58 @@ import Data.Text (Text)



------------------------------------------------------------------------------
-- CommitComment

data CommitComment = CommitComment
{ commitCommentUrl :: Text
, commitCommentHtmlUrl :: Text
, commitCommentId :: Int
, commitCommentUser :: User
, commitCommentPosition :: Maybe Int
, commitCommentLine :: Maybe Int
, commitCommentPath :: Maybe Text
, commitCommentCommitId :: Text
, commitCommentCreatedAt :: DateTime
, commitCommentUpdatedAt :: DateTime
, commitCommentBody :: Text
} deriving (Eq, Show, Read)


instance FromJSON CommitComment where
parseJSON (Object x) = CommitComment
<$> x .: "url"
<*> x .: "html_url"
<*> x .: "id"
<*> x .: "user"
<*> x .: "position"
<*> x .: "line"
<*> x .: "path"
<*> x .: "commit_id"
<*> x .: "created_at"
<*> x .: "updated_at"
<*> x .: "body"

parseJSON _ = fail "CommitComment"


instance ToJSON CommitComment where
toJSON CommitComment{..} = object
[ "url" .= commitCommentUrl
, "html_url" .= commitCommentHtmlUrl
, "id" .= commitCommentId
, "user" .= commitCommentUser
, "position" .= commitCommentPosition
, "line" .= commitCommentLine
, "path" .= commitCommentPath
, "commit_id" .= commitCommentCommitId
, "created_at" .= commitCommentCreatedAt
, "updated_at" .= commitCommentUpdatedAt
, "body" .= commitCommentBody
]



------------------------------------------------------------------------------
-- IssueComment

Expand Down
18 changes: 15 additions & 3 deletions web/GitHub/Types/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,30 @@ webhookPayloadParser eventType x =
-- CommitCommentEvent

data CommitCommentEvent = CommitCommentEvent
{ commitCommentEventComment :: Value
{ commitCommentEventAction :: Text
, commitCommentEventComment :: CommitComment
, commitCommentEventRepository :: Repository
, commitCommentEventSender :: User
, commitCommentEventOrganization :: Organization
} deriving (Eq, Show, Read)

instance FromJSON CommitCommentEvent where
parseJSON (Object x) = CommitCommentEvent
<$> x .: "comment"
<$> x .: "action"
<*> x .: "comment"
<*> x .: "repository"
<*> x .: "sender"
<*> x .: "organization"

parseJSON _ = fail "CommitCommentEvent"

instance ToJSON CommitCommentEvent where
toJSON CommitCommentEvent{..} = object
[ "comment" .= commitCommentEventComment
[ "action" .= commitCommentEventAction
, "comment" .= commitCommentEventComment
, "repository" .= commitCommentEventRepository
, "sender" .= commitCommentEventSender
, "organization" .= commitCommentEventOrganization
]


Expand Down