Skip to content

Commit

Permalink
Emit disabled status for *all* webhooks
Browse files Browse the repository at this point in the history
:salute:
  • Loading branch information
pbrisbin committed Nov 11, 2024
1 parent 67675a4 commit 690a818
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/Restyled/Disabled.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,12 @@ newtype Owner = Owner
deriving stock (Generic)
deriving anyclass (FromJSON, ToJSON)

-- | Decide if we should emit a disabled status intead of processing
--
-- Rough plan:
--
-- - [x] Our own testing repositories
-- - [x] All public repositories
-- - [ ] All except those orgs who are still paying
-- - [ ] Every
shouldEmitDisabledStatus :: Webhook -> Bool
shouldEmitDisabledStatus webhook
| webhook.pull_request.base.repo.owner.login == "restyled-io" = True
| not webhook.pull_request.base.repo.private = True
| otherwise = False

emitDisabledStatus
:: (MonadIO m, MonadLogger m, MonadReader env m, HasSettings env)
=> BSL.ByteString
-> m (Either String GitHub.Status)
emitDisabledStatus body = runExceptT $ do
webhook <- hoistEither $ eitherDecode body
guard $ shouldEmitDisabledStatus webhook

settings <- lift $ view settingsL
token <- generateToken settings webhook

Expand Down Expand Up @@ -140,5 +124,5 @@ createStatus token webhook =
docs :: Text
docs = "https://docs.restyled.io/docs/migrating-to-github-actions/"

unTry :: (MonadError String m, Show e) => m (Either e a) -> m a
unTry f = either (throwError . show) pure =<< f
unTry :: (MonadError String m, Exception e) => m (Either e a) -> m a
unTry f = either (throwError . displayException) pure =<< f

0 comments on commit 690a818

Please sign in to comment.