Trigger via simple GET/POST URL

This commit is contained in:
Filip Gralinski 2020-02-21 22:56:39 +01:00
parent 56cfc57d7d
commit e935cb6182
4 changed files with 17 additions and 0 deletions

View File

@ -181,6 +181,7 @@ instance Yesod App where
isAuthorized (AvatarR _) _ = return Authorized isAuthorized (AvatarR _) _ = return Authorized
isAuthorized TriggerRemotelyR _ = return Authorized isAuthorized TriggerRemotelyR _ = return Authorized
isAuthorized (TriggerRemotelySimpleR _ _ _ _) _ = return Authorized
isAuthorized TriggerLocallyR _ = return Authorized isAuthorized TriggerLocallyR _ = return Authorized
isAuthorized (OpenViewProgressR _) _ = return Authorized isAuthorized (OpenViewProgressR _) _ = return Authorized

View File

@ -276,6 +276,18 @@ postTriggerRemotelyR = do
(Just token) <- lookupPostParam "token" (Just token) <- lookupPostParam "token"
mBranch <- lookupPostParam "branch" mBranch <- lookupPostParam "branch"
mGitAnnexRemote <- lookupPostParam "git-annex-remote" mGitAnnexRemote <- lookupPostParam "git-annex-remote"
doTrigger token challengeName url mBranch mGitAnnexRemote
postTriggerRemotelySimpleR :: Text -> Text -> Text -> Text -> Handler TypedContent
postTriggerRemotelySimpleR token challengeName url branch =
doTrigger token challengeName url (Just branch) Nothing
getTriggerRemotelySimpleR :: Text -> Text -> Text -> Text -> Handler TypedContent
getTriggerRemotelySimpleR token challengeName url branch =
doTrigger token challengeName url (Just branch) Nothing
doTrigger :: Text -> Text -> Text -> Maybe Text -> Maybe Text -> Handler TypedContent
doTrigger token challengeName url mBranch mGitAnnexRemote = do
[Entity userId _] <- runDB $ selectList [UserTriggerToken ==. Just token] [] [Entity userId _] <- runDB $ selectList [UserTriggerToken ==. Just token] []
trigger userId challengeName url mBranch mGitAnnexRemote trigger userId challengeName url mBranch mGitAnnexRemote

View File

@ -25,6 +25,7 @@
/challenge-discussion-rss/#Text ChallengeDiscussionFeedR GET /challenge-discussion-rss/#Text ChallengeDiscussionFeedR GET
/challenge-update/#ChallengeId ChallengeUpdateR GET POST /challenge-update/#ChallengeId ChallengeUpdateR GET POST
/trigger-remotely TriggerRemotelyR POST /trigger-remotely TriggerRemotelyR POST
/trigger-remotely-simple/#Text/#Text/#Text/#Text TriggerRemotelySimpleR GET POST
/trigger-locally TriggerLocallyR POST /trigger-locally TriggerLocallyR POST
/indicator-graph-data/#IndicatorId IndicatorGraphDataR GET /indicator-graph-data/#IndicatorId IndicatorGraphDataR GET

View File

@ -131,6 +131,9 @@ $maybe token <- mToken
<p>Your webook is: <p>Your webook is:
<pre> <pre>
wget --timeout=0 --quiet -O - '#{appRoot settings}/trigger-remotely' --post-data 'token=#{token}&branch=#{myBranch}&challenge=#{challengeName challenge}&url=URL_TO_YOUR_REPO' wget --timeout=0 --quiet -O - '#{appRoot settings}/trigger-remotely' --post-data 'token=#{token}&branch=#{myBranch}&challenge=#{challengeName challenge}&url=URL_TO_YOUR_REPO'
<p>or you can just use the following URL:
<pre>
#{appRoot settings}/trigger-remotely-simple/#{token}/#{challengeName challenge}/URL_TO_YOUR_REPO/#{myBranch}
<h3>Manual submission <h3>Manual submission