diff --git a/src/Vervis/Handler/Discussion.hs b/src/Vervis/Handler/Discussion.hs index 80e41a6..62a41ef 100644 --- a/src/Vervis/Handler/Discussion.hs +++ b/src/Vervis/Handler/Discussion.hs @@ -75,13 +75,24 @@ getNode getdid mid = do l2f (instanceHost i) (remoteSharerIdent rs) return $ MessageTreeNode mid m author +getNodeL :: AppDB DiscussionId -> LocalMessageId -> AppDB MessageTreeNode +getNodeL getdid lmid = do + did <- getdid + lm <- get404 lmid + let mid = localMessageRest lm + m <- getJust mid + unless (messageRoot m == did) notFound + p <- getJust $ localMessageAuthor lm + s <- getJust $ personIdent p + return $ MessageTreeNode mid m $ MessageTreeNodeLocal lmid s + getDiscussionMessage :: (MessageId -> Route App) -> AppDB DiscussionId - -> MessageId + -> LocalMessageId -> Handler Html -getDiscussionMessage reply getdid mid = do - mtn <- runDB $ getNode getdid mid +getDiscussionMessage reply getdid lmid = do + mtn <- runDB $ getNodeL getdid lmid now <- liftIO getCurrentTime defaultLayout $ messageW now mtn reply diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index fdce0e2..566ceb6 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -647,14 +647,14 @@ getTicketMessageR :: ShrIdent -> PrjIdent -> Int -> Text -> Handler Html getTicketMessageR shar proj tnum hid = do decodeHid <- getsYesod appHashidDecode encodeHid <- getsYesod appHashidEncode - mid <- + lmid <- case toSqlKey <$> decodeHid hid of Nothing -> notFound Just k -> return k getDiscussionMessage (TicketReplyR shar proj tnum . encodeHid . fromSqlKey) (selectDiscussionId shar proj tnum) - mid + lmid postTicketMessageR :: ShrIdent -> PrjIdent -> Int -> Text -> Handler Html postTicketMessageR shar proj tnum hid = do