1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-27 19:14:51 +09:00

Reuse the getSharerInboxR code to implement getProjectInboxR

This commit is contained in:
fr33domlover 2019-06-09 16:45:53 +00:00
parent f4e324e587
commit bad1844cfc

View file

@ -143,16 +143,13 @@ getInboxR = do
<div><pre>#{decodeUtf8 body}
|]
getSharerInboxR :: ShrIdent -> Handler TypedContent
getSharerInboxR shr = do
getInbox :: Route App -> AppDB InboxId -> Handler TypedContent
getInbox here getInboxId = do
(total, pages, mpage) <- runDB $ do
sid <- getKeyBy404 $ UniqueSharer shr
p <- getValBy404 $ UniquePersonIdent sid
let ibid = personInbox p
ibid <- getInboxId
getPageAndNavCount
(countItems ibid)
(\ off lim -> map adaptItem <$> getItems ibid off lim)
let here = SharerInboxR shr
encodeRouteLocal <- getEncodeRouteLocal
encodeRoutePageLocal <- getEncodeRoutePageLocal
let pageUrl = encodeRoutePageLocal here
@ -231,8 +228,23 @@ getSharerInboxR shr = do
(Just act, Nothing) -> Left $ persistJSONValue act
(Nothing, Just obj) -> Right $ persistJSONValue obj
getSharerInboxR :: ShrIdent -> Handler TypedContent
getSharerInboxR shr = getInbox here getInboxId
where
here = SharerInboxR shr
getInboxId = do
sid <- getKeyBy404 $ UniqueSharer shr
p <- getValBy404 $ UniquePersonIdent sid
return $ personInbox p
getProjectInboxR :: ShrIdent -> PrjIdent -> Handler TypedContent
getProjectInboxR _ _ = error "TODO implement getProjectInboxR"
getProjectInboxR shr prj = getInbox here getInboxId
where
here = ProjectInboxR shr prj
getInboxId = do
sid <- getKeyBy404 $ UniqueSharer shr
j <- getValBy404 $ UniqueProject prj sid
return $ projectInbox j
postSharerInboxR :: ShrIdent -> Handler ()
postSharerInboxR shrRecip = do