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