Refactor toward general announcements cntd.

This commit is contained in:
Filip Gralinski 2021-08-21 09:49:30 +02:00
parent 2a6515d872
commit 8e9df1c311
3 changed files with 7 additions and 7 deletions

View File

@ -3,7 +3,7 @@ module Handler.Announcements where
import Import
import Handler.Shared
import Web.Announcements (runSlackHook)
import Web.Announcements (sendAnnouncement)
getTestAnnouncementsR :: Handler Html
getTestAnnouncementsR = do
@ -16,7 +16,7 @@ getTestAnnouncementsR = do
Nothing -> "Gonito"
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 ()
defaultLayout $ do

View File

@ -973,7 +973,7 @@ doCreateSubmission' _ userId challengeId challengeSubmissionData chan = do
msg chan message
case appNewBestResultSlackHook $ appSettings app of
Just "" -> return ()
Just hook -> liftIO $ runSlackHook hook message
Just hook -> liftIO $ sendAnnouncement hook message
Nothing -> return ()
else return ()
@ -1022,7 +1022,7 @@ checkTarget theNow user submissionLink entries indicator target chan = do
msg chan message
case appNewBestResultSlackHook $ appSettings app of
Just "" -> return ()
Just hook -> liftIO $ runSlackHook hook message
Just hook -> liftIO $ sendAnnouncement hook message
Nothing -> return ()
else
return ()

View File

@ -2,7 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
module Web.Announcements
(runSlackHook,
(sendAnnouncement,
formatLink)
where
@ -15,8 +15,8 @@ import Data.Aeson
import Data.Default
runSlackHook :: Text -> Text -> IO ()
runSlackHook hook message = do
sendAnnouncement :: Text -> Text -> IO ()
sendAnnouncement hook message = do
let (Just (hookUrl, _)) = parseUrlHttps $ DTE.encodeUtf8 hook
R.runReq def $ do