Add project outbox and outbox item routes
This commit is contained in:
parent
a65979f5af
commit
e1ae75b50c
3 changed files with 58 additions and 14 deletions
|
@ -96,6 +96,8 @@
|
||||||
/s/#ShrIdent/p/!new ProjectNewR GET
|
/s/#ShrIdent/p/!new ProjectNewR GET
|
||||||
/s/#ShrIdent/p/#PrjIdent ProjectR GET PUT POST
|
/s/#ShrIdent/p/#PrjIdent ProjectR GET PUT POST
|
||||||
/s/#ShrIdent/p/#PrjIdent/inbox ProjectInboxR GET POST
|
/s/#ShrIdent/p/#PrjIdent/inbox ProjectInboxR GET POST
|
||||||
|
/s/#ShrIdent/p/#PrjIdent/outbox ProjectOutboxR GET
|
||||||
|
/s/#ShrIdent/p/#PrjIdent/outbox/#OutboxItemKeyHashid ProjectOutboxItemR GET
|
||||||
/s/#ShrIdent/p/#PrjIdent/team ProjectTeamR GET
|
/s/#ShrIdent/p/#PrjIdent/team ProjectTeamR GET
|
||||||
/s/#ShrIdent/p/#PrjIdent/followers ProjectFollowersR GET
|
/s/#ShrIdent/p/#PrjIdent/followers ProjectFollowersR GET
|
||||||
/s/#ShrIdent/p/#PrjIdent/edit ProjectEditR GET
|
/s/#ShrIdent/p/#PrjIdent/edit ProjectEditR GET
|
||||||
|
|
|
@ -808,6 +808,10 @@ instance YesodBreadcrumbs App where
|
||||||
, Just $ ProjectsR shar
|
, Just $ ProjectsR shar
|
||||||
)
|
)
|
||||||
ProjectInboxR shr prj -> ("Inbox", Just $ ProjectR shr prj)
|
ProjectInboxR shr prj -> ("Inbox", Just $ ProjectR shr prj)
|
||||||
|
ProjectOutboxR shr prj -> ("Outbox", Just $ ProjectR shr prj)
|
||||||
|
ProjectOutboxItemR shr prj hid -> ( "#" <> keyHashidText hid
|
||||||
|
, Just $ ProjectOutboxR shr prj
|
||||||
|
)
|
||||||
ProjectEditR shr prj -> ("Edit", Just $ ProjectR shr prj)
|
ProjectEditR shr prj -> ("Edit", Just $ ProjectR shr prj)
|
||||||
ProjectDevsR shr prj -> ( "Collaborators"
|
ProjectDevsR shr prj -> ( "Collaborators"
|
||||||
, Just $ ProjectR shr prj
|
, Just $ ProjectR shr prj
|
||||||
|
|
|
@ -23,6 +23,8 @@ module Vervis.Handler.Inbox
|
||||||
, getSharerOutboxR
|
, getSharerOutboxR
|
||||||
, getSharerOutboxItemR
|
, getSharerOutboxItemR
|
||||||
, postSharerOutboxR
|
, postSharerOutboxR
|
||||||
|
, getProjectOutboxR
|
||||||
|
, getProjectOutboxItemR
|
||||||
, getActorKey1R
|
, getActorKey1R
|
||||||
, getActorKey2R
|
, getActorKey2R
|
||||||
, getNotificationsR
|
, getNotificationsR
|
||||||
|
@ -367,16 +369,13 @@ getPublishR = do
|
||||||
((_result, widget), enctype) <- runFormPost activityForm
|
((_result, widget), enctype) <- runFormPost activityForm
|
||||||
defaultLayout $ activityWidget shr widget enctype
|
defaultLayout $ activityWidget shr widget enctype
|
||||||
|
|
||||||
getSharerOutboxR :: ShrIdent -> Handler TypedContent
|
getOutbox :: Route App -> AppDB OutboxId -> Handler TypedContent
|
||||||
getSharerOutboxR shr = do
|
getOutbox here getObid = do
|
||||||
(total, pages, mpage) <- runDB $ do
|
(total, pages, mpage) <- runDB $ do
|
||||||
sid <- getKeyBy404 $ UniqueSharer shr
|
obid <- getObid
|
||||||
p <- getValBy404 $ UniquePersonIdent sid
|
let countAllItems = count [OutboxItemOutbox ==. obid]
|
||||||
let obid = personOutbox p
|
|
||||||
countAllItems = count [OutboxItemOutbox ==. obid]
|
|
||||||
selectItems off lim = selectList [OutboxItemOutbox ==. obid] [Desc OutboxItemId, OffsetBy off, LimitTo lim]
|
selectItems off lim = selectList [OutboxItemOutbox ==. obid] [Desc OutboxItemId, OffsetBy off, LimitTo lim]
|
||||||
getPageAndNavCount countAllItems selectItems
|
getPageAndNavCount countAllItems selectItems
|
||||||
let here = SharerOutboxR shr
|
|
||||||
encodeRouteLocal <- getEncodeRouteLocal
|
encodeRouteLocal <- getEncodeRouteLocal
|
||||||
encodeRoutePageLocal <- getEncodeRoutePageLocal
|
encodeRoutePageLocal <- getEncodeRoutePageLocal
|
||||||
let pageUrl = encodeRoutePageLocal here
|
let pageUrl = encodeRoutePageLocal here
|
||||||
|
@ -425,17 +424,37 @@ getSharerOutboxR shr = do
|
||||||
diffUTCTime now
|
diffUTCTime now
|
||||||
defaultLayout $(widgetFile "person/outbox")
|
defaultLayout $(widgetFile "person/outbox")
|
||||||
|
|
||||||
getSharerOutboxItemR :: ShrIdent -> KeyHashid OutboxItem -> Handler TypedContent
|
getOutboxItem
|
||||||
getSharerOutboxItemR shr obikhid = do
|
:: Route App
|
||||||
|
-> AppDB OutboxId
|
||||||
|
-> KeyHashid OutboxItem
|
||||||
|
-> Handler TypedContent
|
||||||
|
getOutboxItem here getObid obikhid = do
|
||||||
obiid <- decodeKeyHashid404 obikhid
|
obiid <- decodeKeyHashid404 obikhid
|
||||||
Doc h act <- runDB $ do
|
Doc h act <- runDB $ do
|
||||||
|
obid <- getObid
|
||||||
|
obi <- get404 obiid
|
||||||
|
unless (outboxItemOutbox obi == obid) notFound
|
||||||
|
return $ persistJSONValue $ outboxItemActivity obi
|
||||||
|
provideHtmlAndAP' h act $ redirect (here, [("prettyjson", "true")])
|
||||||
|
|
||||||
|
getSharerOutboxR :: ShrIdent -> Handler TypedContent
|
||||||
|
getSharerOutboxR shr = getOutbox here getObid
|
||||||
|
where
|
||||||
|
here = SharerOutboxR shr
|
||||||
|
getObid = do
|
||||||
sid <- getKeyBy404 $ UniqueSharer shr
|
sid <- getKeyBy404 $ UniqueSharer shr
|
||||||
p <- getValBy404 $ UniquePersonIdent sid
|
p <- getValBy404 $ UniquePersonIdent sid
|
||||||
obi <- get404 obiid
|
return $ personOutbox p
|
||||||
unless (outboxItemOutbox obi == personOutbox p) notFound
|
|
||||||
return $ persistJSONValue $ outboxItemActivity obi
|
getSharerOutboxItemR :: ShrIdent -> KeyHashid OutboxItem -> Handler TypedContent
|
||||||
let here = SharerOutboxItemR shr obikhid
|
getSharerOutboxItemR shr obikhid = getOutboxItem here getObid obikhid
|
||||||
provideHtmlAndAP' h act $ redirect (here, [("prettyjson", "true")])
|
where
|
||||||
|
here = SharerOutboxItemR shr obikhid
|
||||||
|
getObid = do
|
||||||
|
sid <- getKeyBy404 $ UniqueSharer shr
|
||||||
|
p <- getValBy404 $ UniquePersonIdent sid
|
||||||
|
return $ personOutbox p
|
||||||
|
|
||||||
postSharerOutboxR :: ShrIdent -> Handler Html
|
postSharerOutboxR :: ShrIdent -> Handler Html
|
||||||
postSharerOutboxR shrAuthor = do
|
postSharerOutboxR shrAuthor = do
|
||||||
|
@ -488,6 +507,25 @@ postSharerOutboxR shrAuthor = do
|
||||||
setMessage $ toHtml $ "Message created! ID: " <> u
|
setMessage $ toHtml $ "Message created! ID: " <> u
|
||||||
defaultLayout $ activityWidget shrAuthor widget enctype
|
defaultLayout $ activityWidget shrAuthor widget enctype
|
||||||
|
|
||||||
|
getProjectOutboxR :: ShrIdent -> PrjIdent -> Handler TypedContent
|
||||||
|
getProjectOutboxR shr prj = getOutbox here getObid
|
||||||
|
where
|
||||||
|
here = ProjectOutboxR shr prj
|
||||||
|
getObid = do
|
||||||
|
sid <- getKeyBy404 $ UniqueSharer shr
|
||||||
|
j <- getValBy404 $ UniqueProject prj sid
|
||||||
|
return $ projectOutbox j
|
||||||
|
|
||||||
|
getProjectOutboxItemR
|
||||||
|
:: ShrIdent -> PrjIdent -> KeyHashid OutboxItem -> Handler TypedContent
|
||||||
|
getProjectOutboxItemR shr prj obikhid = getOutboxItem here getObid obikhid
|
||||||
|
where
|
||||||
|
here = ProjectOutboxItemR shr prj obikhid
|
||||||
|
getObid = do
|
||||||
|
sid <- getKeyBy404 $ UniqueSharer shr
|
||||||
|
j <- getValBy404 $ UniqueProject prj sid
|
||||||
|
return $ projectOutbox j
|
||||||
|
|
||||||
getActorKey :: ((ActorKey, ActorKey, Bool) -> ActorKey) -> Route App -> Handler TypedContent
|
getActorKey :: ((ActorKey, ActorKey, Bool) -> ActorKey) -> Route App -> Handler TypedContent
|
||||||
getActorKey choose route = do
|
getActorKey choose route = do
|
||||||
actorKey <-
|
actorKey <-
|
||||||
|
|
Loading…
Reference in a new issue