Skip to content

Commit

Permalink
Log our simply-parsed Webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Oct 4, 2024
1 parent 19eb51b commit 4635733
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Restyled/Disabled.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,40 @@ data Webhook = Webhook
, pull_request :: PullRequest
}
deriving stock (Generic)
deriving anyclass (FromJSON)
deriving anyclass (FromJSON, ToJSON)

newtype Installation = Installation
{ id :: Int
}
deriving stock (Generic)
deriving anyclass (FromJSON)
deriving anyclass (FromJSON, ToJSON)

data PullRequest = PullRequest
{ base :: Commit
, head :: Commit
}
deriving stock (Generic)
deriving anyclass (FromJSON)
deriving anyclass (FromJSON, ToJSON)

data Commit = Commit
{ repo :: Repo
, sha :: Text
}
deriving stock (Generic)
deriving anyclass (FromJSON)
deriving anyclass (FromJSON, ToJSON)

data Repo = Repo
{ owner :: Owner
, name :: Text
}
deriving stock (Generic)
deriving anyclass (FromJSON)
deriving anyclass (FromJSON, ToJSON)

newtype Owner = Owner
{ login :: Text
}
deriving stock (Generic)
deriving anyclass (FromJSON)
deriving anyclass (FromJSON, ToJSON)

-- | Decide if we should emit a disabled status intead of processing
--
Expand All @@ -70,11 +70,12 @@ shouldEmitDisabledStatus webhook =
]

emitDisabledStatus
:: (MonadUnliftIO m, MonadReader env m, HasSettings env)
:: (MonadIO m, MonadLogger m, MonadReader env m, HasSettings env)
=> BSL.ByteString
-> m (Either String GitHub.Status)
emitDisabledStatus body = runExceptT $ do
webhook <- hoistEither $ eitherDecode body
logDebug $ "Webhook" :# ["contents" .= webhook]
guard $ shouldEmitDisabledStatus webhook
settings <- lift $ view settingsL
token <- generateToken settings webhook
Expand Down

0 comments on commit 4635733

Please sign in to comment.