forked from filipg/gonito
Switch to more general announcements
Compatibility break: switch NEW_BEST_RESULT_SLACK_HOOK env to ANNOUNCEMENT_HOOK
This commit is contained in:
parent
3dc9ae5dd8
commit
5f4af21006
@ -9,14 +9,14 @@ getTestAnnouncementsR :: Handler Html
|
||||
getTestAnnouncementsR = do
|
||||
app <- getYesod
|
||||
|
||||
let webHook = appNewBestResultSlackHook $ appSettings app
|
||||
let webHook = appAnnouncementHook $ appSettings app
|
||||
|
||||
let name = case appLocation $ appSettings app of
|
||||
Just loc -> "Gonito@" ++ loc
|
||||
Nothing -> "Gonito"
|
||||
|
||||
case webHook of
|
||||
Just hook -> liftIO $ sendAnnouncement hook ("Test message from " ++ (slackLink (Just hook) app name ""))
|
||||
Just hook -> liftIO $ sendAnnouncement hook ("Test message from " ++ (linkInAnnouncement (Just hook) app name ""))
|
||||
Nothing -> return ()
|
||||
|
||||
defaultLayout $ do
|
||||
|
@ -743,8 +743,8 @@ compareFun :: MetricOrdering -> Double -> Double -> Ordering
|
||||
compareFun TheLowerTheBetter = flip compare
|
||||
compareFun TheHigherTheBetter = compare
|
||||
|
||||
slackLink :: Maybe AnnouncementHook -> App -> Text -> Text -> Text
|
||||
slackLink hook app title addr = formatLink hook slink title
|
||||
linkInAnnouncement :: Maybe AnnouncementHook -> App -> Text -> Text -> Text
|
||||
linkInAnnouncement hook app title addr = formatLink hook slink title
|
||||
where slink = (appRoot $ appSettings app) ++ "/" ++ addr
|
||||
|
||||
formatVersion :: (Int, Int, Int) -> Text
|
||||
|
@ -933,9 +933,9 @@ doCreateSubmission' _ userId challengeId challengeSubmissionData chan = do
|
||||
msg chan "SUBMISSION CREATED"
|
||||
|
||||
app <- getYesod
|
||||
let mHook = appNewBestResultSlackHook $ appSettings app
|
||||
let mHook = appAnnouncementHook $ appSettings app
|
||||
|
||||
let submissionLink = slackLink mHook app "submission" ("q/" ++ (fromSHA1ToText (repoCurrentCommit repo)))
|
||||
let submissionLink = linkInAnnouncement mHook app "submission" ("q/" ++ (fromSHA1ToText (repoCurrentCommit repo)))
|
||||
|
||||
case mMainEnt of
|
||||
Just (Entity mainTestId mainTest) -> do
|
||||
@ -953,8 +953,8 @@ doCreateSubmission' _ userId challengeId challengeSubmissionData chan = do
|
||||
(s:_) -> if compOp s b
|
||||
then
|
||||
do
|
||||
let challengeLink = slackLink mHook app (challengeTitle challenge) ("challenge/"
|
||||
++ (challengeName challenge))
|
||||
let challengeLink = linkInAnnouncement mHook app (challengeTitle challenge) ("challenge/"
|
||||
++ (challengeName challenge))
|
||||
let message = ("Whoa! New best result for "
|
||||
++ challengeLink
|
||||
++ " challenge by "
|
||||
@ -1020,7 +1020,7 @@ checkTarget theNow user submissionLink entries indicator target chan = do
|
||||
++ " See " ++ submissionLink ++ "."
|
||||
++ (T.replicate 10 " :champagne: ") ++ " :mleczko: "
|
||||
msg chan message
|
||||
case appNewBestResultSlackHook $ appSettings app of
|
||||
case appAnnouncementHook $ appSettings app of
|
||||
Just hook -> liftIO $ sendAnnouncement hook message
|
||||
Nothing -> return ()
|
||||
else
|
||||
|
@ -102,7 +102,7 @@ data AppSettings = AppSettings
|
||||
, appTagPermissions :: TagPermissions
|
||||
, appAutoOpening :: Bool
|
||||
, appLeaderboardStyle :: LeaderboardStyle
|
||||
, appNewBestResultSlackHook :: Maybe AnnouncementHook
|
||||
, appAnnouncementHook :: Maybe AnnouncementHook
|
||||
, appServerSSHPublicKey :: Maybe Text
|
||||
-- ^ Are challenges, submission, etc. visible without logging in
|
||||
, appIsPublic :: Bool
|
||||
@ -154,7 +154,7 @@ instance FromJSON AppSettings where
|
||||
appAutoOpening <- o .:? "auto-opening" .!= False
|
||||
appLeaderboardStyle <- toLeaderboardStyle <$> o .: "leaderboard-style"
|
||||
|
||||
appNewBestResultSlackHook <- toAnnouncementHook' <$> (o .:? "new-best-result-slack-hook")
|
||||
appAnnouncementHook <- toAnnouncementHook' <$> (o .:? "announcement-hook")
|
||||
|
||||
appServerSSHPublicKey <- o .:? "server-ssh-public-key"
|
||||
|
||||
|
@ -13,7 +13,7 @@ repo-scheme: "_env:REPO_SCHEME:selfhosted"
|
||||
tag-permissions: "_env:TAG_PERMISSIONS:only-admin-can-add-new-tags"
|
||||
auto-opening: "_env:AUTO_OPENING:false"
|
||||
leaderboard-style: "_env:LEADERBOARD_STYLE:by-submitter"
|
||||
new-best-result-slack-hook: "_env:NEW_BEST_RESULT_SLACK_HOOK:"
|
||||
announcement-hook: "_env:ANNOUNCEMENT_HOOK:"
|
||||
server-ssh-public-key: "_env:SERVER_SSH_PUBLIC_KEY:"
|
||||
is-public: "_env:IS_PUBLIC:true"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user