mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-28 11:54:51 +09:00
Reuse the getSharerInboxR code to implement getProjectInboxR
This commit is contained in:
parent
f4e324e587
commit
bad1844cfc
1 changed files with 19 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue