Refactor toward general announcements cntd.
This commit is contained in:
parent
2a6515d872
commit
8e9df1c311
@ -3,7 +3,7 @@ module Handler.Announcements where
|
|||||||
import Import
|
import Import
|
||||||
|
|
||||||
import Handler.Shared
|
import Handler.Shared
|
||||||
import Web.Announcements (runSlackHook)
|
import Web.Announcements (sendAnnouncement)
|
||||||
|
|
||||||
getTestAnnouncementsR :: Handler Html
|
getTestAnnouncementsR :: Handler Html
|
||||||
getTestAnnouncementsR = do
|
getTestAnnouncementsR = do
|
||||||
@ -16,7 +16,7 @@ getTestAnnouncementsR = do
|
|||||||
Nothing -> "Gonito"
|
Nothing -> "Gonito"
|
||||||
|
|
||||||
case webHook of
|
case webHook of
|
||||||
Just hook -> liftIO $ runSlackHook hook ("Test message from " ++ (slackLink app name ""))
|
Just hook -> liftIO $ sendAnnouncement hook ("Test message from " ++ (slackLink app name ""))
|
||||||
Nothing -> return ()
|
Nothing -> return ()
|
||||||
|
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
|
@ -973,7 +973,7 @@ doCreateSubmission' _ userId challengeId challengeSubmissionData chan = do
|
|||||||
msg chan message
|
msg chan message
|
||||||
case appNewBestResultSlackHook $ appSettings app of
|
case appNewBestResultSlackHook $ appSettings app of
|
||||||
Just "" -> return ()
|
Just "" -> return ()
|
||||||
Just hook -> liftIO $ runSlackHook hook message
|
Just hook -> liftIO $ sendAnnouncement hook message
|
||||||
|
|
||||||
Nothing -> return ()
|
Nothing -> return ()
|
||||||
else return ()
|
else return ()
|
||||||
@ -1022,7 +1022,7 @@ checkTarget theNow user submissionLink entries indicator target chan = do
|
|||||||
msg chan message
|
msg chan message
|
||||||
case appNewBestResultSlackHook $ appSettings app of
|
case appNewBestResultSlackHook $ appSettings app of
|
||||||
Just "" -> return ()
|
Just "" -> return ()
|
||||||
Just hook -> liftIO $ runSlackHook hook message
|
Just hook -> liftIO $ sendAnnouncement hook message
|
||||||
Nothing -> return ()
|
Nothing -> return ()
|
||||||
else
|
else
|
||||||
return ()
|
return ()
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module Web.Announcements
|
module Web.Announcements
|
||||||
(runSlackHook,
|
(sendAnnouncement,
|
||||||
formatLink)
|
formatLink)
|
||||||
where
|
where
|
||||||
|
|
||||||
@ -15,8 +15,8 @@ import Data.Aeson
|
|||||||
import Data.Default
|
import Data.Default
|
||||||
|
|
||||||
|
|
||||||
runSlackHook :: Text -> Text -> IO ()
|
sendAnnouncement :: Text -> Text -> IO ()
|
||||||
runSlackHook hook message = do
|
sendAnnouncement hook message = do
|
||||||
let (Just (hookUrl, _)) = parseUrlHttps $ DTE.encodeUtf8 hook
|
let (Just (hookUrl, _)) = parseUrlHttps $ DTE.encodeUtf8 hook
|
||||||
|
|
||||||
R.runReq def $ do
|
R.runReq def $ do
|
||||||
|
Loading…
Reference in New Issue
Block a user