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

Fetch local messages by LocalMessageId, not by MessageId

This commit is contained in:
fr33domlover 2019-03-21 19:06:52 +00:00
parent 9b916c9b75
commit 77324442fc
2 changed files with 16 additions and 5 deletions

View file

@ -75,13 +75,24 @@ getNode getdid mid = do
l2f (instanceHost i) (remoteSharerIdent rs) l2f (instanceHost i) (remoteSharerIdent rs)
return $ MessageTreeNode mid m author 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 getDiscussionMessage
:: (MessageId -> Route App) :: (MessageId -> Route App)
-> AppDB DiscussionId -> AppDB DiscussionId
-> MessageId -> LocalMessageId
-> Handler Html -> Handler Html
getDiscussionMessage reply getdid mid = do getDiscussionMessage reply getdid lmid = do
mtn <- runDB $ getNode getdid mid mtn <- runDB $ getNodeL getdid lmid
now <- liftIO getCurrentTime now <- liftIO getCurrentTime
defaultLayout $ messageW now mtn reply defaultLayout $ messageW now mtn reply

View file

@ -647,14 +647,14 @@ getTicketMessageR :: ShrIdent -> PrjIdent -> Int -> Text -> Handler Html
getTicketMessageR shar proj tnum hid = do getTicketMessageR shar proj tnum hid = do
decodeHid <- getsYesod appHashidDecode decodeHid <- getsYesod appHashidDecode
encodeHid <- getsYesod appHashidEncode encodeHid <- getsYesod appHashidEncode
mid <- lmid <-
case toSqlKey <$> decodeHid hid of case toSqlKey <$> decodeHid hid of
Nothing -> notFound Nothing -> notFound
Just k -> return k Just k -> return k
getDiscussionMessage getDiscussionMessage
(TicketReplyR shar proj tnum . encodeHid . fromSqlKey) (TicketReplyR shar proj tnum . encodeHid . fromSqlKey)
(selectDiscussionId shar proj tnum) (selectDiscussionId shar proj tnum)
mid lmid
postTicketMessageR :: ShrIdent -> PrjIdent -> Int -> Text -> Handler Html postTicketMessageR :: ShrIdent -> PrjIdent -> Int -> Text -> Handler Html
postTicketMessageR shar proj tnum hid = do postTicketMessageR shar proj tnum hid = do