diff --git a/src/Vervis/Handler/Inbox.hs b/src/Vervis/Handler/Inbox.hs index b76e997..a4e5d0d 100644 --- a/src/Vervis/Handler/Inbox.hs +++ b/src/Vervis/Handler/Inbox.hs @@ -143,16 +143,13 @@ getInboxR = do
#{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