1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-29 00:04: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)
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

View file

@ -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