In ticket discussion, have links to the individual messages (MessageR route)
This commit is contained in:
parent
9bc78bf303
commit
0e4070db75
5 changed files with 31 additions and 13 deletions
|
@ -27,6 +27,7 @@ import Data.Graph.Inductive.Graph (mkGraph, lab')
|
||||||
import Data.Graph.Inductive.PatriciaTree (Gr)
|
import Data.Graph.Inductive.PatriciaTree (Gr)
|
||||||
import Data.Graph.Inductive.Query.DFS (dffWith)
|
import Data.Graph.Inductive.Query.DFS (dffWith)
|
||||||
import Data.Maybe (isNothing, mapMaybe)
|
import Data.Maybe (isNothing, mapMaybe)
|
||||||
|
import Data.Text (Text)
|
||||||
import Data.Tree (Forest)
|
import Data.Tree (Forest)
|
||||||
import Database.Esqueleto hiding (isNothing)
|
import Database.Esqueleto hiding (isNothing)
|
||||||
import Yesod.Persist.Core (runDB)
|
import Yesod.Persist.Core (runDB)
|
||||||
|
@ -41,7 +42,7 @@ import Vervis.Model
|
||||||
|
|
||||||
data MessageTreeNodeAuthor
|
data MessageTreeNodeAuthor
|
||||||
= MessageTreeNodeLocal LocalMessageId Sharer
|
= MessageTreeNodeLocal LocalMessageId Sharer
|
||||||
| MessageTreeNodeRemote FedURI
|
| MessageTreeNodeRemote Text LocalURI LocalURI
|
||||||
|
|
||||||
data MessageTreeNode = MessageTreeNode
|
data MessageTreeNode = MessageTreeNode
|
||||||
{ mtnMessageId :: MessageId
|
{ mtnMessageId :: MessageId
|
||||||
|
@ -63,13 +64,18 @@ getMessages getdid = runDB $ do
|
||||||
on $ rm ^. RemoteMessageAuthor ==. rs ^. RemoteActorId
|
on $ rm ^. RemoteMessageAuthor ==. rs ^. RemoteActorId
|
||||||
on $ rm ^. RemoteMessageRest ==. m ^. MessageId
|
on $ rm ^. RemoteMessageRest ==. m ^. MessageId
|
||||||
where_ $ m ^. MessageRoot ==. val did
|
where_ $ m ^. MessageRoot ==. val did
|
||||||
return (m, i ^. InstanceHost, rs ^. RemoteActorIdent)
|
return
|
||||||
|
( m
|
||||||
|
, i ^. InstanceHost
|
||||||
|
, rm ^. RemoteMessageIdent
|
||||||
|
, rs ^. RemoteActorIdent
|
||||||
|
)
|
||||||
return $ map mklocal l ++ map mkremote r
|
return $ map mklocal l ++ map mkremote r
|
||||||
where
|
where
|
||||||
mklocal (Entity mid m, Value lmid, Entity _ s) =
|
mklocal (Entity mid m, Value lmid, Entity _ s) =
|
||||||
MessageTreeNode mid m $ MessageTreeNodeLocal lmid s
|
MessageTreeNode mid m $ MessageTreeNodeLocal lmid s
|
||||||
mkremote (Entity mid m, Value h, Value lu) =
|
mkremote (Entity mid m, Value h, Value luMsg, Value luAuthor) =
|
||||||
MessageTreeNode mid m $ MessageTreeNodeRemote $ l2f h lu
|
MessageTreeNode mid m $ MessageTreeNodeRemote h luMsg luAuthor
|
||||||
|
|
||||||
discussionTree :: [MessageTreeNode] -> Forest MessageTreeNode
|
discussionTree :: [MessageTreeNode] -> Forest MessageTreeNode
|
||||||
discussionTree mss =
|
discussionTree mss =
|
||||||
|
|
|
@ -85,8 +85,11 @@ getNode getdid mid = do
|
||||||
(Nothing, Just (Entity _rmid rm)) -> do
|
(Nothing, Just (Entity _rmid rm)) -> do
|
||||||
rs <- getJust $ remoteMessageAuthor rm
|
rs <- getJust $ remoteMessageAuthor rm
|
||||||
i <- getJust $ remoteActorInstance rs
|
i <- getJust $ remoteActorInstance rs
|
||||||
return $ MessageTreeNodeRemote $
|
return $
|
||||||
l2f (instanceHost i) (remoteActorIdent rs)
|
MessageTreeNodeRemote
|
||||||
|
(instanceHost i)
|
||||||
|
(remoteMessageIdent rm)
|
||||||
|
(remoteActorIdent rs)
|
||||||
return $ MessageTreeNode mid m author
|
return $ MessageTreeNode mid m author
|
||||||
|
|
||||||
{-
|
{-
|
||||||
|
|
|
@ -33,9 +33,11 @@ import Yesod.Core.Widget
|
||||||
import qualified Data.Text as T (filter)
|
import qualified Data.Text as T (filter)
|
||||||
|
|
||||||
import Network.FedURI
|
import Network.FedURI
|
||||||
|
import Yesod.Hashids
|
||||||
|
|
||||||
import Data.EventTime.Local
|
import Data.EventTime.Local
|
||||||
import Data.Time.Clock.Local ()
|
import Data.Time.Clock.Local ()
|
||||||
|
|
||||||
import Vervis.Discussion
|
import Vervis.Discussion
|
||||||
import Vervis.Foundation
|
import Vervis.Foundation
|
||||||
import Vervis.MediaType (MediaType (Markdown))
|
import Vervis.MediaType (MediaType (Markdown))
|
||||||
|
@ -48,18 +50,19 @@ import Vervis.Widget.Sharer (personLinkW)
|
||||||
actorLinkW :: MessageTreeNodeAuthor -> Widget
|
actorLinkW :: MessageTreeNodeAuthor -> Widget
|
||||||
actorLinkW actor = $(widgetFile "widget/actor-link")
|
actorLinkW actor = $(widgetFile "widget/actor-link")
|
||||||
where
|
where
|
||||||
shortURI (FedURI h p f) = h <> p <> f
|
shortURI h (LocalURI p f) = h <> p <> f
|
||||||
|
|
||||||
messageW
|
messageW
|
||||||
:: UTCTime -> MessageTreeNode -> (MessageId -> Route App) -> Widget
|
:: UTCTime -> MessageTreeNode -> (MessageId -> Route App) -> Widget
|
||||||
messageW now (MessageTreeNode msgid msg author) reply =
|
messageW now (MessageTreeNode msgid msg author) reply = do
|
||||||
|
encodeHid <- getEncodeKeyHashid
|
||||||
let showTime =
|
let showTime =
|
||||||
showEventTime .
|
showEventTime .
|
||||||
intervalToEventTime .
|
intervalToEventTime .
|
||||||
FriendlyConvert .
|
FriendlyConvert .
|
||||||
diffUTCTime now
|
diffUTCTime now
|
||||||
showContent = renderSourceT Markdown . T.filter (/= '\r')
|
showContent = renderSourceT Markdown . T.filter (/= '\r')
|
||||||
in $(widgetFile "discussion/widget/message")
|
$(widgetFile "discussion/widget/message")
|
||||||
|
|
||||||
messageTreeW
|
messageTreeW
|
||||||
:: (MessageId -> Route App)
|
:: (MessageId -> Route App)
|
||||||
|
|
|
@ -14,6 +14,12 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
^{actorLinkW author}
|
^{actorLinkW author}
|
||||||
<div>
|
<div>
|
||||||
|
$case author
|
||||||
|
$of MessageTreeNodeLocal lmid s
|
||||||
|
<a href=@{MessageR (sharerIdent s) (encodeHid lmid)}>
|
||||||
|
#{showTime $ messageCreated msg}
|
||||||
|
$of MessageTreeNodeRemote h luMsg _luAuthor
|
||||||
|
<a href="#{renderFedURI $ l2f h luMsg}"}>
|
||||||
#{showTime $ messageCreated msg}
|
#{showTime $ messageCreated msg}
|
||||||
<div>
|
<div>
|
||||||
^{showContent $ messageContent msg}
|
^{showContent $ messageContent msg}
|
||||||
|
|
|
@ -21,8 +21,8 @@ $case actor
|
||||||
#{shr2text $ sharerIdent s}
|
#{shr2text $ sharerIdent s}
|
||||||
<span>
|
<span>
|
||||||
./s/#{shr2text $ sharerIdent s}
|
./s/#{shr2text $ sharerIdent s}
|
||||||
$of MessageTreeNodeRemote uAuthor
|
$of MessageTreeNodeRemote h _luMsg luAuthor
|
||||||
<a href="#{renderFedURI uAuthor}">
|
<a href="#{renderFedURI $ l2f h luAuthor}">
|
||||||
(?)
|
(?)
|
||||||
<span>
|
<span>
|
||||||
#{shortURI uAuthor}
|
#{shortURI h luAuthor}
|
||||||
|
|
Loading…
Reference in a new issue