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GUWZDP6BRGP423FTYKF67T5IF5YHHLNXKQ5REAC
MGOF7IUFGXYQKZOKMM2GGULFFVAULEHLZDSHMUW6B5DBKVXXR74AC
2XQD6KKKD6QVHFHAEMVE3XXY7X2T7BLTLL7XIILZAXNJJH2YONUQC
HALRDT2F22DAQ54M334YSKD2XJCAXDXEZPDKGMOWKH7XELBAS6MAC
parseCreditTo :: Value -> Parser CreditTo
parseCreditTo = unversion $ \x -> case x of
Version 1 0 -> withObject "BtcAddr" parseCreditToV1
Version 2 0 -> withObject "CreditTo" parseCreditToV2
_ -> badVersion "EventAmendment" x
parseLogEvent :: Object -> Parser LogEvent
parseLogEvent x =
(StartWork <$> x .: "start") <|> (StopWork <$> x .: "stop")
parseLogEntry :: Value -> Parser LogEntry
parseLogEntry = unversion parseLogEntry' where
parseLogEntry' (Version 2 0) (Object x) =
LogEntry <$> (x .: "creditTo" >>= parseCreditTo)
<*> (x .: "event" >>= parseLogEvent)
<*> (x .: "eventMeta")
parseLogEntry' v x = badVersion "LogEntry" v x
snapEval $ createEvent pid uid (LogEntry addr (evCtr timestamp) (A.decode requestBody))
snapEval . createEvent pid uid $
LogEntry (CreditToAddress addr) (evCtr timestamp) (A.decode requestBody)
recordLogEntryHandler :: Handler App App EventId
recordLogEntryHandler = do
uid <- requireUserId
pid <- requireProjectId
requestBody <- readRequestBody 4096
timestamp <- liftIO C.getCurrentTime
case A.eitherDecode requestBody >>= parseEither parseLogEntry of
Left err -> snapError 400 $ "Unable to parse log entry " <> (tshow requestBody) <> ": " <> tshow err
Right entry -> snapEval $ createEvent pid uid (event.eventTime .~ timestamp $ entry)
let loginRoute = requireLogin >> redirect "/home"
registerRoute = void $ method POST registerHandler
acceptInviteRoute = void $ method POST acceptInvitationHandler
let loginRoute = requireLogin >> redirect "/home"
registerRoute = void $ method POST registerHandler
acceptInviteRoute = void $ method POST acceptInvitationHandler
projectCreateRoute = serveJSON projectIdJSON $ method POST projectCreateHandler
listProjectsRoute = serveJSON (fmap qdbProjectJSON) $ method GET projectListHandler
projectCreateRoute = serveJSON projectIdJSON $ method POST projectCreateHandler
listProjectsRoute = serveJSON (fmap qdbProjectJSON) $ method GET projectListHandler
projectRoute = serveJSON projectJSON $ method GET projectGetHandler
logEventRoute f = serveJSON eventIdJSON $ method POST (logWorkHandler f)
logEntriesRoute = serveJSON (fmap logEntryJSON) $ method GET logEntriesHandler
logIntervalsRoute = serveJSON workIndexJSON $ method GET loggedIntervalsHandler
payoutsRoute = serveJSON payoutsJSON $ method GET payoutsHandler
inviteRoute = void . method POST $ projectInviteHandler cfg
projectRoute = serveJSON projectJSON $ method GET projectGetHandler
logWorkRoute f = serveJSON eventIdJSON $ method POST (logWorkHandler f)
recordLogEntryRoute = serveJSON eventIdJSON $ method POST recordLogEntryHandler
logEntriesRoute = serveJSON (fmap logEntryJSON) $ method GET logEntriesHandler
logIntervalsRoute = serveJSON workIndexJSON $ method GET loggedIntervalsHandler
payoutsRoute = serveJSON payoutsJSON $ method GET payoutsHandler
inviteRoute = void . method POST $ projectInviteHandler cfg
auctionCreateRoute = serveJSON auctionIdJSON $ method POST auctionCreateHandler
auctionRoute = serveJSON auctionJSON $ method GET auctionGetHandler
auctionBidRoute = serveJSON bidIdJSON $ method POST auctionBidHandler
auctionCreateRoute = serveJSON auctionIdJSON $ method POST auctionCreateHandler
auctionRoute = serveJSON auctionJSON $ method GET auctionGetHandler
auctionBidRoute = serveJSON bidIdJSON $ method POST auctionBidHandler
, ("projects/:projectId/logStart/:btcAddr", logEventRoute StartWork)
, ("projects/:projectId/logEnd/:btcAddr", logEventRoute StopWork)
, ("projects/:projectId/logStart/:btcAddr", logWorkRoute StartWork)
, ("projects/:projectId/logEnd/:btcAddr", logWorkRoute StopWork)
, ("projects/:projectId/logWorkEvent", recordLogEntryRoute)