2016-04-30 22:32:22 +00:00
|
|
|
|
{- This file is part of Vervis.
|
|
|
|
|
-
|
2020-01-04 10:49:44 +00:00
|
|
|
|
- Written in 2016, 2018, 2019, 2020 by fr33domlover <fr33domlover@riseup.net>.
|
2016-04-30 22:32:22 +00:00
|
|
|
|
-
|
|
|
|
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
|
|
|
|
-
|
|
|
|
|
- The author(s) have dedicated all copyright and related and neighboring
|
|
|
|
|
- rights to this software to the public domain worldwide. This software is
|
|
|
|
|
- distributed without any warranty.
|
|
|
|
|
-
|
|
|
|
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
|
|
|
|
- with this software. If not, see
|
|
|
|
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
module Vervis.Handler.Ticket
|
|
|
|
|
( getTicketsR
|
2016-08-04 07:36:24 +00:00
|
|
|
|
, getTicketTreeR
|
2016-04-30 22:32:22 +00:00
|
|
|
|
, getTicketNewR
|
2016-04-30 23:02:44 +00:00
|
|
|
|
, getTicketR
|
2016-05-02 06:13:57 +00:00
|
|
|
|
, putTicketR
|
|
|
|
|
, deleteTicketR
|
2016-05-02 11:34:11 +00:00
|
|
|
|
, postTicketR
|
2016-05-02 06:13:57 +00:00
|
|
|
|
, getTicketEditR
|
2016-08-11 07:58:51 +00:00
|
|
|
|
, postTicketAcceptR
|
2016-06-01 19:50:41 +00:00
|
|
|
|
, postTicketCloseR
|
|
|
|
|
, postTicketOpenR
|
2016-06-06 09:03:49 +00:00
|
|
|
|
, postTicketClaimR
|
|
|
|
|
, postTicketUnclaimR
|
2016-06-07 07:33:19 +00:00
|
|
|
|
, getTicketAssignR
|
|
|
|
|
, postTicketAssignR
|
|
|
|
|
, postTicketUnassignR
|
2016-06-07 16:31:55 +00:00
|
|
|
|
, getClaimRequestsPersonR
|
|
|
|
|
, getClaimRequestsProjectR
|
|
|
|
|
, getClaimRequestsTicketR
|
2016-06-08 01:28:18 +00:00
|
|
|
|
, postClaimRequestsTicketR
|
|
|
|
|
, getClaimRequestNewR
|
2016-05-19 16:58:23 +00:00
|
|
|
|
, getTicketDiscussionR
|
2016-05-21 20:01:31 +00:00
|
|
|
|
, postTicketDiscussionR
|
2019-03-22 20:46:42 +00:00
|
|
|
|
, getMessageR
|
2016-05-19 22:07:25 +00:00
|
|
|
|
, postTicketMessageR
|
|
|
|
|
, getTicketTopReplyR
|
|
|
|
|
, getTicketReplyR
|
2016-06-07 20:16:15 +00:00
|
|
|
|
, getTicketDepsR
|
2016-07-28 16:40:10 +00:00
|
|
|
|
, postTicketDepsR
|
|
|
|
|
, getTicketDepNewR
|
2019-07-08 15:54:41 +00:00
|
|
|
|
, postTicketDepOldR
|
|
|
|
|
, deleteTicketDepOldR
|
2016-07-27 08:35:50 +00:00
|
|
|
|
, getTicketReverseDepsR
|
2019-07-11 15:14:16 +00:00
|
|
|
|
, getTicketDepR
|
2019-04-11 13:44:44 +00:00
|
|
|
|
, getTicketParticipantsR
|
|
|
|
|
, getTicketTeamR
|
2019-06-03 21:52:34 +00:00
|
|
|
|
, getTicketEventsR
|
2020-02-08 15:24:36 +00:00
|
|
|
|
|
|
|
|
|
, getSharerTicketsR
|
|
|
|
|
, getSharerTicketR
|
2020-02-10 14:10:01 +00:00
|
|
|
|
, getSharerTicketDiscussionR
|
|
|
|
|
, getSharerTicketDepsR
|
|
|
|
|
, getSharerTicketReverseDepsR
|
|
|
|
|
, getSharerTicketFollowersR
|
|
|
|
|
, getSharerTicketTeamR
|
|
|
|
|
, getSharerTicketEventsR
|
2016-04-30 22:32:22 +00:00
|
|
|
|
)
|
|
|
|
|
where
|
|
|
|
|
|
2016-08-04 07:36:24 +00:00
|
|
|
|
import Control.Applicative (liftA2)
|
2019-06-23 10:00:11 +00:00
|
|
|
|
import Control.Monad
|
2016-05-18 09:15:11 +00:00
|
|
|
|
import Control.Monad.IO.Class (liftIO)
|
2020-02-03 14:53:12 +00:00
|
|
|
|
import Control.Monad.Logger.CallStack
|
2019-06-23 10:00:11 +00:00
|
|
|
|
import Control.Monad.Trans.Except
|
2020-01-16 10:29:47 +00:00
|
|
|
|
import Data.Aeson (encode)
|
2019-05-25 22:05:59 +00:00
|
|
|
|
import Data.Bifunctor
|
2020-02-10 14:10:01 +00:00
|
|
|
|
import Data.Bitraversable
|
2016-08-11 09:27:30 +00:00
|
|
|
|
import Data.Bool (bool)
|
2016-05-22 14:31:56 +00:00
|
|
|
|
import Data.Default.Class (def)
|
2016-08-10 18:52:26 +00:00
|
|
|
|
import Data.Foldable (traverse_)
|
2020-02-10 14:10:01 +00:00
|
|
|
|
import Data.Maybe
|
2016-06-07 07:33:19 +00:00
|
|
|
|
import Data.Monoid ((<>))
|
2016-04-30 22:32:22 +00:00
|
|
|
|
import Data.Text (Text)
|
2016-05-18 09:15:11 +00:00
|
|
|
|
import Data.Time.Calendar (Day (..))
|
|
|
|
|
import Data.Time.Clock (UTCTime (..), getCurrentTime)
|
2016-05-01 09:58:55 +00:00
|
|
|
|
import Data.Time.Format (formatTime, defaultTimeLocale)
|
2016-06-01 16:20:19 +00:00
|
|
|
|
import Data.Traversable (for)
|
2019-05-25 22:04:06 +00:00
|
|
|
|
import Database.Persist
|
2018-07-11 08:15:19 +00:00
|
|
|
|
import Network.HTTP.Types (StdMethod (DELETE, POST))
|
2019-06-23 10:00:11 +00:00
|
|
|
|
import Text.Blaze.Html (Html, toHtml, preEscapedToHtml)
|
2019-06-03 21:52:34 +00:00
|
|
|
|
import Text.Blaze.Html.Renderer.Text
|
2019-06-17 19:55:03 +00:00
|
|
|
|
import Text.HTML.SanitizeXSS
|
2016-06-06 10:00:05 +00:00
|
|
|
|
import Yesod.Auth (requireAuthId, maybeAuthId)
|
2020-02-03 14:53:12 +00:00
|
|
|
|
import Yesod.Core hiding (logWarn)
|
2019-03-15 16:36:02 +00:00
|
|
|
|
import Yesod.Core.Handler
|
2016-05-22 14:31:56 +00:00
|
|
|
|
import Yesod.Form.Functions (runFormGet, runFormPost)
|
2016-05-01 10:15:38 +00:00
|
|
|
|
import Yesod.Form.Types (FormResult (..))
|
2016-05-01 09:58:55 +00:00
|
|
|
|
import Yesod.Persist.Core (runDB, get404, getBy404)
|
2016-04-30 22:32:22 +00:00
|
|
|
|
|
2020-01-16 10:29:47 +00:00
|
|
|
|
import qualified Data.ByteString.Lazy as BL
|
2016-05-02 21:20:25 +00:00
|
|
|
|
import qualified Data.Text as T (filter, intercalate, pack)
|
2019-06-03 21:52:34 +00:00
|
|
|
|
import qualified Data.Text.Lazy as TL
|
2019-05-25 22:04:06 +00:00
|
|
|
|
import qualified Database.Esqueleto as E
|
2016-04-30 22:32:22 +00:00
|
|
|
|
|
2016-07-28 16:40:10 +00:00
|
|
|
|
import Database.Persist.Sql.Graph.TransitiveReduction (trrFix)
|
2019-05-25 22:05:59 +00:00
|
|
|
|
|
|
|
|
|
import Data.Aeson.Encode.Pretty.ToEncoding
|
2020-02-08 15:24:36 +00:00
|
|
|
|
import Data.MediaType
|
2019-05-25 22:05:59 +00:00
|
|
|
|
import Network.FedURI
|
2019-07-11 22:18:30 +00:00
|
|
|
|
import Web.ActivityPub hiding (Ticket (..), TicketDependency)
|
2019-06-03 21:52:34 +00:00
|
|
|
|
import Yesod.ActivityPub
|
2019-06-23 10:00:11 +00:00
|
|
|
|
import Yesod.Auth.Unverified
|
2019-05-25 22:05:59 +00:00
|
|
|
|
import Yesod.FedURI
|
2019-03-29 03:25:32 +00:00
|
|
|
|
import Yesod.Hashids
|
2020-01-16 10:29:47 +00:00
|
|
|
|
import Yesod.MonadSite
|
2020-02-08 15:24:36 +00:00
|
|
|
|
import Yesod.RenderSource
|
2019-03-29 03:25:32 +00:00
|
|
|
|
|
2019-06-03 21:52:34 +00:00
|
|
|
|
import qualified Web.ActivityPub as AP
|
|
|
|
|
|
2019-06-07 04:26:32 +00:00
|
|
|
|
import Data.Either.Local
|
2019-03-29 03:25:32 +00:00
|
|
|
|
import Data.Maybe.Local (partitionMaybePairs)
|
2020-01-16 10:29:47 +00:00
|
|
|
|
import Data.Paginate.Local
|
2019-05-25 22:05:59 +00:00
|
|
|
|
import Database.Persist.Local
|
|
|
|
|
import Yesod.Persist.Local
|
2019-03-29 03:25:32 +00:00
|
|
|
|
|
2019-06-15 04:39:13 +00:00
|
|
|
|
import Vervis.API
|
2019-06-11 12:19:51 +00:00
|
|
|
|
import Vervis.Federation
|
2020-02-08 15:24:36 +00:00
|
|
|
|
import Vervis.FedURI
|
2016-04-30 22:32:22 +00:00
|
|
|
|
import Vervis.Form.Ticket
|
|
|
|
|
import Vervis.Foundation
|
2016-05-19 16:58:23 +00:00
|
|
|
|
import Vervis.Handler.Discussion
|
2016-07-28 16:40:10 +00:00
|
|
|
|
import Vervis.GraphProxy (ticketDepGraph)
|
2016-04-30 22:32:22 +00:00
|
|
|
|
import Vervis.Model
|
2016-05-23 20:46:54 +00:00
|
|
|
|
import Vervis.Model.Ident
|
2016-08-11 00:44:11 +00:00
|
|
|
|
import Vervis.Model.Ticket
|
2016-08-08 20:51:58 +00:00
|
|
|
|
import Vervis.Model.Workflow
|
2020-01-16 10:29:47 +00:00
|
|
|
|
import Vervis.Paginate
|
2019-04-20 21:34:45 +00:00
|
|
|
|
import Vervis.Settings
|
2016-08-11 09:27:30 +00:00
|
|
|
|
import Vervis.Style
|
2016-08-04 07:36:24 +00:00
|
|
|
|
import Vervis.Ticket
|
2016-05-22 14:31:56 +00:00
|
|
|
|
import Vervis.TicketFilter (filterTickets)
|
2016-06-06 07:26:58 +00:00
|
|
|
|
import Vervis.Time (showDate)
|
2018-07-11 08:15:19 +00:00
|
|
|
|
import Vervis.Widget (buttonW)
|
2016-05-18 10:26:19 +00:00
|
|
|
|
import Vervis.Widget.Discussion (discussionW)
|
2019-06-07 04:26:32 +00:00
|
|
|
|
import Vervis.Widget.Sharer
|
2016-07-04 09:58:25 +00:00
|
|
|
|
import Vervis.Widget.Ticket
|
2016-04-30 22:32:22 +00:00
|
|
|
|
|
2020-01-16 10:29:47 +00:00
|
|
|
|
getTicketsR :: ShrIdent -> PrjIdent -> Handler TypedContent
|
|
|
|
|
getTicketsR shr prj = selectRep $ do
|
|
|
|
|
provideRep $ do
|
|
|
|
|
((filtResult, filtWidget), filtEnctype) <- runFormGet ticketFilterForm
|
|
|
|
|
let tf =
|
|
|
|
|
case filtResult of
|
|
|
|
|
FormSuccess filt -> filt
|
|
|
|
|
FormMissing -> def
|
|
|
|
|
FormFailure l ->
|
|
|
|
|
error $ "Ticket filter form failed: " ++ show l
|
|
|
|
|
(total, pages, mpage) <- runDB $ do
|
|
|
|
|
Entity sid _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
let countAllTickets = count [TicketProjectLocalProject ==. jid]
|
2020-01-16 10:29:47 +00:00
|
|
|
|
selectTickets off lim =
|
|
|
|
|
getTicketSummaries
|
|
|
|
|
(filterTickets tf)
|
2020-02-03 14:53:12 +00:00
|
|
|
|
(Just $ \ t -> [E.asc $ t E.^. TicketId])
|
2020-01-16 10:29:47 +00:00
|
|
|
|
(Just (off, lim))
|
|
|
|
|
jid
|
|
|
|
|
getPageAndNavCount countAllTickets selectTickets
|
|
|
|
|
case mpage of
|
|
|
|
|
Nothing -> redirectFirstPage here
|
|
|
|
|
Just (rows, navModel) ->
|
|
|
|
|
let pageNav = navWidget navModel
|
|
|
|
|
in defaultLayout $(widgetFile "ticket/list")
|
|
|
|
|
provideAP' $ do
|
|
|
|
|
(total, pages, mpage) <- runDB $ do
|
|
|
|
|
Entity sid _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
let countAllTickets = count [TicketProjectLocalProject ==. jid]
|
2020-02-06 00:52:15 +00:00
|
|
|
|
selectTickets off lim = do
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tids <-
|
|
|
|
|
map (ticketProjectLocalTicket . entityVal) <$>
|
|
|
|
|
selectList
|
|
|
|
|
[TicketProjectLocalProject ==. jid]
|
|
|
|
|
[ Desc TicketProjectLocalTicket
|
|
|
|
|
, OffsetBy off
|
|
|
|
|
, LimitTo lim
|
|
|
|
|
]
|
2020-02-06 00:52:15 +00:00
|
|
|
|
selectKeysList [LocalTicketTicket <-. tids] [Desc LocalTicketTicket]
|
2020-01-16 10:29:47 +00:00
|
|
|
|
getPageAndNavCount countAllTickets selectTickets
|
|
|
|
|
|
|
|
|
|
encodeRouteHome <- getEncodeRouteHome
|
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
|
encodeRoutePageLocal <- getEncodeRoutePageLocal
|
|
|
|
|
let pageUrl = encodeRoutePageLocal here
|
|
|
|
|
host <- asksSite siteInstanceHost
|
2020-02-03 14:53:12 +00:00
|
|
|
|
encodeTicketKey <- getEncodeKeyHashid
|
|
|
|
|
let ticketUrl = TicketR shr prj . encodeTicketKey
|
2020-01-16 10:29:47 +00:00
|
|
|
|
|
|
|
|
|
return $
|
|
|
|
|
case mpage of
|
|
|
|
|
Nothing -> encodeStrict $ Doc host $ Collection
|
|
|
|
|
{ collectionId = encodeRouteLocal here
|
|
|
|
|
, collectionType = CollectionTypeOrdered
|
|
|
|
|
, collectionTotalItems = Just total
|
|
|
|
|
, collectionCurrent = Nothing
|
|
|
|
|
, collectionFirst = Just $ pageUrl 1
|
|
|
|
|
, collectionLast = Just $ pageUrl pages
|
|
|
|
|
, collectionItems = [] :: [Text]
|
|
|
|
|
}
|
|
|
|
|
Just (tickets, navModel) ->
|
|
|
|
|
let current = nmCurrent navModel
|
|
|
|
|
in encodeStrict $ Doc host $ CollectionPage
|
|
|
|
|
{ collectionPageId = pageUrl current
|
|
|
|
|
, collectionPageType = CollectionPageTypeOrdered
|
|
|
|
|
, collectionPageTotalItems = Nothing
|
|
|
|
|
, collectionPageCurrent = Just $ pageUrl current
|
|
|
|
|
, collectionPageFirst = Just $ pageUrl 1
|
|
|
|
|
, collectionPageLast = Just $ pageUrl pages
|
|
|
|
|
, collectionPagePartOf = encodeRouteLocal here
|
|
|
|
|
, collectionPagePrev =
|
|
|
|
|
if current > 1
|
|
|
|
|
then Just $ pageUrl $ current - 1
|
|
|
|
|
else Nothing
|
|
|
|
|
, collectionPageNext =
|
|
|
|
|
if current < pages
|
|
|
|
|
then Just $ pageUrl $ current + 1
|
|
|
|
|
else Nothing
|
|
|
|
|
, collectionPageStartIndex = Nothing
|
|
|
|
|
, collectionPageItems =
|
2020-02-06 00:52:15 +00:00
|
|
|
|
map (encodeRouteHome . ticketUrl) tickets
|
2020-01-16 10:29:47 +00:00
|
|
|
|
}
|
|
|
|
|
where
|
|
|
|
|
here = TicketsR shr prj
|
|
|
|
|
encodeStrict = BL.toStrict . encode
|
2016-04-30 22:32:22 +00:00
|
|
|
|
|
2016-08-04 07:36:24 +00:00
|
|
|
|
getTicketTreeR :: ShrIdent -> PrjIdent -> Handler Html
|
|
|
|
|
getTicketTreeR shr prj = do
|
|
|
|
|
(summaries, deps) <- runDB $ do
|
|
|
|
|
Entity sid _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
2020-02-03 14:53:12 +00:00
|
|
|
|
(,) <$> getTicketSummaries Nothing Nothing Nothing jid
|
|
|
|
|
<*> getTicketDepEdges jid
|
2016-08-04 07:36:24 +00:00
|
|
|
|
defaultLayout $ ticketTreeDW shr prj summaries deps
|
|
|
|
|
|
2016-05-23 12:24:14 +00:00
|
|
|
|
getTicketNewR :: ShrIdent -> PrjIdent -> Handler Html
|
2019-06-23 10:00:11 +00:00
|
|
|
|
getTicketNewR shr prj = do
|
2016-08-08 23:36:39 +00:00
|
|
|
|
wid <- runDB $ do
|
2019-06-23 10:00:11 +00:00
|
|
|
|
Entity sid _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity _ j <- getBy404 $ UniqueProject prj sid
|
2016-08-08 23:36:39 +00:00
|
|
|
|
return $ projectWorkflow j
|
|
|
|
|
((_result, widget), enctype) <- runFormPost $ newTicketForm wid
|
2016-05-18 09:15:11 +00:00
|
|
|
|
defaultLayout $(widgetFile "ticket/new")
|
2016-04-30 23:02:44 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
getTicketR :: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler TypedContent
|
|
|
|
|
getTicketR shar proj ltkhid = do
|
2016-06-06 10:00:05 +00:00
|
|
|
|
mpid <- maybeAuthId
|
2016-08-09 11:36:14 +00:00
|
|
|
|
( wshr, wfl,
|
2020-02-05 14:09:12 +00:00
|
|
|
|
author, massignee, mcloser, ticket, lticket, tparams, eparams, cparams,
|
2020-01-05 14:33:10 +00:00
|
|
|
|
deps, rdeps) <-
|
2016-08-08 20:51:58 +00:00
|
|
|
|
runDB $ do
|
|
|
|
|
(jid, wshr, wid, wfl) <- do
|
|
|
|
|
Entity s sharer <- getBy404 $ UniqueSharer shar
|
|
|
|
|
Entity p project <- getBy404 $ UniqueProject proj s
|
|
|
|
|
w <- get404 $ projectWorkflow project
|
|
|
|
|
wsharer <-
|
|
|
|
|
if workflowSharer w == s
|
|
|
|
|
then return sharer
|
|
|
|
|
else get404 $ workflowSharer w
|
|
|
|
|
return
|
|
|
|
|
( p
|
|
|
|
|
, sharerIdent wsharer
|
|
|
|
|
, projectWorkflow project
|
|
|
|
|
, workflowIdent w
|
|
|
|
|
)
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
2020-02-07 23:05:42 +00:00
|
|
|
|
Entity tplid tpl <- getBy404 $ UniqueTicketProjectLocal tid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
unless (ticketProjectLocalProject tpl == jid) notFound
|
2019-06-07 04:26:32 +00:00
|
|
|
|
author <-
|
|
|
|
|
requireEitherAlt
|
2020-02-06 03:41:16 +00:00
|
|
|
|
(do mtal <- getValBy $ UniqueTicketAuthorLocal ltid
|
2019-06-07 04:26:32 +00:00
|
|
|
|
for mtal $ \ tal -> do
|
2020-02-08 15:42:55 +00:00
|
|
|
|
_ <- getBy404 $ UniqueTicketUnderProjectProject tplid
|
2019-06-07 04:26:32 +00:00
|
|
|
|
p <- getJust $ ticketAuthorLocalAuthor tal
|
|
|
|
|
getJust $ personIdent p
|
|
|
|
|
)
|
2020-02-07 23:05:42 +00:00
|
|
|
|
(do mtar <- getValBy $ UniqueTicketAuthorRemote tplid
|
2019-06-07 04:26:32 +00:00
|
|
|
|
for mtar $ \ tar -> do
|
|
|
|
|
ra <- getJust $ ticketAuthorRemoteAuthor tar
|
2019-11-06 19:47:50 +00:00
|
|
|
|
ro <- getJust $ remoteActorIdent ra
|
|
|
|
|
i <- getJust $ remoteObjectInstance ro
|
|
|
|
|
return (i, ro, ra)
|
2019-06-07 04:26:32 +00:00
|
|
|
|
)
|
|
|
|
|
"Ticket doesn't have author"
|
|
|
|
|
"Ticket has both local and remote author"
|
2020-02-06 17:25:09 +00:00
|
|
|
|
ticket <- get404 tid
|
2016-08-08 20:51:58 +00:00
|
|
|
|
massignee <- for (ticketAssignee ticket) $ \ apid -> do
|
|
|
|
|
person <- get404 apid
|
|
|
|
|
sharer <- get404 $ personIdent person
|
|
|
|
|
return (sharer, fromMaybe False $ (== apid) <$> mpid)
|
2019-06-07 04:26:32 +00:00
|
|
|
|
mcloser <-
|
2016-08-11 00:44:11 +00:00
|
|
|
|
case ticketStatus ticket of
|
2019-06-07 04:26:32 +00:00
|
|
|
|
TSClosed ->
|
|
|
|
|
case ticketCloser ticket of
|
|
|
|
|
Just pidCloser -> Just <$> do
|
|
|
|
|
person <- getJust pidCloser
|
|
|
|
|
getJust $ personIdent person
|
|
|
|
|
Nothing -> error "Closer not set for closed ticket"
|
|
|
|
|
_ ->
|
|
|
|
|
case ticketCloser ticket of
|
|
|
|
|
Just _ -> error "Closer set for open ticket"
|
|
|
|
|
Nothing -> return Nothing
|
2016-08-10 18:52:26 +00:00
|
|
|
|
tparams <- getTicketTextParams tid wid
|
|
|
|
|
eparams <- getTicketEnumParams tid wid
|
2020-01-05 14:33:10 +00:00
|
|
|
|
cparams <- getTicketClasses tid wid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
deps <- E.select $ E.from $ \ (dep `E.InnerJoin` t `E.InnerJoin` lt) -> do
|
|
|
|
|
E.on $ t E.^. TicketId E.==. lt E.^. LocalTicketTicket
|
2019-05-25 22:04:06 +00:00
|
|
|
|
E.on $ dep E.^. TicketDependencyChild E.==. t E.^. TicketId
|
|
|
|
|
E.where_ $ dep E.^. TicketDependencyParent E.==. E.val tid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
return (lt E.^. LocalTicketId, t)
|
|
|
|
|
rdeps <- E.select $ E.from $ \ (dep `E.InnerJoin` t `E.InnerJoin` lt) -> do
|
|
|
|
|
E.on $ t E.^. TicketId E.==. lt E.^. LocalTicketTicket
|
2019-05-25 22:04:06 +00:00
|
|
|
|
E.on $ dep E.^. TicketDependencyParent E.==. t E.^. TicketId
|
|
|
|
|
E.where_ $ dep E.^. TicketDependencyChild E.==. E.val tid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
return (lt E.^. LocalTicketId, t)
|
2016-08-08 20:51:58 +00:00
|
|
|
|
return
|
|
|
|
|
( wshr, wfl
|
2020-02-05 14:09:12 +00:00
|
|
|
|
, author, massignee, mcloser, ticket, lticket
|
|
|
|
|
, tparams, eparams, cparams
|
2016-08-09 11:36:14 +00:00
|
|
|
|
, deps, rdeps
|
2016-08-08 20:51:58 +00:00
|
|
|
|
)
|
2019-03-29 03:25:32 +00:00
|
|
|
|
encodeHid <- getEncodeKeyHashid
|
2019-06-03 12:45:02 +00:00
|
|
|
|
let desc :: Widget
|
|
|
|
|
desc = toWidget $ preEscapedToMarkup $ ticketDescription ticket
|
2016-05-21 21:27:12 +00:00
|
|
|
|
discuss =
|
|
|
|
|
discussionW
|
2020-02-05 14:09:12 +00:00
|
|
|
|
(return $ localTicketDiscuss lticket)
|
2020-02-06 00:52:15 +00:00
|
|
|
|
(TicketTopReplyR shar proj ltkhid)
|
|
|
|
|
(TicketReplyR shar proj ltkhid . encodeHid)
|
2016-08-11 09:27:30 +00:00
|
|
|
|
cRelevant <- newIdent
|
|
|
|
|
cIrrelevant <- newIdent
|
|
|
|
|
let relevant filt =
|
|
|
|
|
bool cIrrelevant cRelevant $
|
|
|
|
|
case ticketStatus ticket of
|
|
|
|
|
TSNew -> wffNew filt
|
|
|
|
|
TSTodo -> wffTodo filt
|
|
|
|
|
TSClosed -> wffClosed filt
|
2019-06-06 10:25:16 +00:00
|
|
|
|
hLocal <- getsYesod siteInstanceHost
|
2019-06-03 21:52:34 +00:00
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
|
encodeRouteHome <- getEncodeRouteHome
|
2019-07-11 15:53:55 +00:00
|
|
|
|
let host =
|
2019-06-07 04:26:32 +00:00
|
|
|
|
case author of
|
2019-11-06 19:47:50 +00:00
|
|
|
|
Left _ -> hLocal
|
|
|
|
|
Right (i, _, _) -> instanceHost i
|
2019-06-03 21:52:34 +00:00
|
|
|
|
ticketAP = AP.Ticket
|
2019-06-06 10:25:16 +00:00
|
|
|
|
{ AP.ticketLocal = Just
|
|
|
|
|
( hLocal
|
|
|
|
|
, AP.TicketLocal
|
|
|
|
|
{ AP.ticketId =
|
2020-02-06 00:52:15 +00:00
|
|
|
|
encodeRouteLocal $ TicketR shar proj ltkhid
|
2019-06-06 10:25:16 +00:00
|
|
|
|
, AP.ticketContext =
|
|
|
|
|
encodeRouteLocal $ ProjectR shar proj
|
|
|
|
|
, AP.ticketReplies =
|
2020-02-06 00:52:15 +00:00
|
|
|
|
encodeRouteLocal $ TicketDiscussionR shar proj ltkhid
|
2019-06-06 10:25:16 +00:00
|
|
|
|
, AP.ticketParticipants =
|
2020-02-06 00:52:15 +00:00
|
|
|
|
encodeRouteLocal $ TicketParticipantsR shar proj ltkhid
|
2019-06-06 10:25:16 +00:00
|
|
|
|
, AP.ticketTeam =
|
2020-02-06 00:52:15 +00:00
|
|
|
|
encodeRouteLocal $ TicketTeamR shar proj ltkhid
|
2019-06-06 10:25:16 +00:00
|
|
|
|
, AP.ticketEvents =
|
2020-02-06 00:52:15 +00:00
|
|
|
|
encodeRouteLocal $ TicketEventsR shar proj ltkhid
|
2019-07-11 15:53:55 +00:00
|
|
|
|
, AP.ticketDeps =
|
2020-02-06 00:52:15 +00:00
|
|
|
|
encodeRouteLocal $ TicketDepsR shar proj ltkhid
|
2019-07-11 15:53:55 +00:00
|
|
|
|
, AP.ticketReverseDeps =
|
2020-02-06 00:52:15 +00:00
|
|
|
|
encodeRouteLocal $ TicketReverseDepsR shar proj ltkhid
|
2019-06-06 10:25:16 +00:00
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
2019-06-03 21:52:34 +00:00
|
|
|
|
, AP.ticketAttributedTo =
|
2019-06-07 04:26:32 +00:00
|
|
|
|
case author of
|
|
|
|
|
Left sharer ->
|
|
|
|
|
encodeRouteLocal $ SharerR $ sharerIdent sharer
|
2019-11-06 19:47:50 +00:00
|
|
|
|
Right (_inztance, object, _actor) ->
|
|
|
|
|
remoteObjectIdent object
|
2019-06-03 21:52:34 +00:00
|
|
|
|
, AP.ticketPublished = Just $ ticketCreated ticket
|
|
|
|
|
, AP.ticketUpdated = Nothing
|
2020-02-03 14:53:12 +00:00
|
|
|
|
-- , AP.ticketName = Just $ "#" <> T.pack (show num)
|
2019-06-17 19:55:03 +00:00
|
|
|
|
, AP.ticketSummary = TextHtml $ ticketTitle ticket
|
2019-06-03 21:52:34 +00:00
|
|
|
|
, AP.ticketContent = TextHtml $ ticketDescription ticket
|
|
|
|
|
, AP.ticketSource = TextPandocMarkdown $ ticketSource ticket
|
|
|
|
|
, AP.ticketAssignedTo =
|
|
|
|
|
encodeRouteHome . SharerR . sharerIdent . fst <$> massignee
|
|
|
|
|
, AP.ticketIsResolved = ticketStatus ticket == TSClosed
|
|
|
|
|
}
|
2019-10-02 08:07:26 +00:00
|
|
|
|
provideHtmlAndAP' host ticketAP $
|
|
|
|
|
let followButton =
|
|
|
|
|
followW
|
2020-02-06 00:52:15 +00:00
|
|
|
|
(TicketFollowR shar proj ltkhid)
|
|
|
|
|
(TicketUnfollowR shar proj ltkhid)
|
2020-02-05 14:09:12 +00:00
|
|
|
|
(return $ localTicketFollowers lticket)
|
2019-10-02 08:07:26 +00:00
|
|
|
|
in $(widgetFile "ticket/one")
|
2016-05-02 06:13:57 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
putTicketR :: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
putTicketR shr prj ltkhid = do
|
2016-08-10 18:52:26 +00:00
|
|
|
|
(tid, ticket, wid) <- runDB $ do
|
2020-02-03 14:53:12 +00:00
|
|
|
|
Entity sid _sharer <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity pid project <- getBy404 $ UniqueProject prj sid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
|
|
|
|
ticket <- getJust tid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == pid) notFound
|
2016-08-10 18:52:26 +00:00
|
|
|
|
return (tid, ticket, projectWorkflow project)
|
|
|
|
|
((result, widget), enctype) <-
|
|
|
|
|
runFormPost $ editTicketContentForm tid ticket wid
|
2016-05-02 09:15:10 +00:00
|
|
|
|
case result of
|
2020-01-05 14:33:10 +00:00
|
|
|
|
FormSuccess (ticket', tparams, eparams, cparams) -> do
|
2019-06-03 12:45:02 +00:00
|
|
|
|
newDescHtml <-
|
|
|
|
|
case renderPandocMarkdown $ ticketSource ticket' of
|
|
|
|
|
Left err -> do
|
|
|
|
|
setMessage $ toHtml err
|
2020-02-06 00:52:15 +00:00
|
|
|
|
redirect $ TicketEditR shr prj ltkhid
|
2019-06-03 12:45:02 +00:00
|
|
|
|
Right t -> return t
|
|
|
|
|
let ticket'' = ticket' { ticketDescription = newDescHtml }
|
2016-08-10 18:52:26 +00:00
|
|
|
|
runDB $ do
|
2019-06-03 12:45:02 +00:00
|
|
|
|
replace tid ticket''
|
2016-08-10 18:52:26 +00:00
|
|
|
|
let (tdel, tins, tupd) = partitionMaybePairs tparams
|
|
|
|
|
deleteWhere [TicketParamTextId <-. tdel]
|
|
|
|
|
let mktparam (fid, v) = TicketParamText
|
|
|
|
|
{ ticketParamTextTicket = tid
|
|
|
|
|
, ticketParamTextField = fid
|
|
|
|
|
, ticketParamTextValue = v
|
|
|
|
|
}
|
|
|
|
|
insertMany_ $ map mktparam tins
|
|
|
|
|
traverse_
|
|
|
|
|
(\ (aid, (_fid, v)) ->
|
|
|
|
|
update aid [TicketParamTextValue =. v]
|
|
|
|
|
)
|
|
|
|
|
tupd
|
|
|
|
|
let (edel, eins, eupd) = partitionMaybePairs eparams
|
|
|
|
|
deleteWhere [TicketParamEnumId <-. edel]
|
|
|
|
|
let mkeparam (fid, v) = TicketParamEnum
|
|
|
|
|
{ ticketParamEnumTicket = tid
|
|
|
|
|
, ticketParamEnumField = fid
|
|
|
|
|
, ticketParamEnumValue = v
|
|
|
|
|
}
|
|
|
|
|
insertMany_ $ map mkeparam eins
|
|
|
|
|
traverse_
|
|
|
|
|
(\ (aid, (_fid, v)) ->
|
|
|
|
|
update aid [TicketParamEnumValue =. v]
|
|
|
|
|
)
|
|
|
|
|
eupd
|
2020-01-05 14:33:10 +00:00
|
|
|
|
let (cdel, cins, _ckeep) = partitionMaybePairs cparams
|
|
|
|
|
deleteWhere [TicketParamClassId <-. cdel]
|
|
|
|
|
let mkcparam fid = TicketParamClass
|
|
|
|
|
{ ticketParamClassTicket = tid
|
|
|
|
|
, ticketParamClassField = fid
|
|
|
|
|
}
|
|
|
|
|
insertMany_ $ map mkcparam cins
|
2016-05-02 11:33:30 +00:00
|
|
|
|
setMessage "Ticket updated."
|
2020-02-06 00:52:15 +00:00
|
|
|
|
redirect $ TicketR shr prj ltkhid
|
2016-05-02 09:15:10 +00:00
|
|
|
|
FormMissing -> do
|
|
|
|
|
setMessage "Field(s) missing."
|
|
|
|
|
defaultLayout $(widgetFile "ticket/edit")
|
|
|
|
|
FormFailure _l -> do
|
|
|
|
|
setMessage "Ticket update failed, see errors below."
|
|
|
|
|
defaultLayout $(widgetFile "ticket/edit")
|
2016-05-02 06:13:57 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
deleteTicketR :: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
deleteTicketR _shr _prj _ltkhid =
|
2016-05-02 09:15:10 +00:00
|
|
|
|
--TODO: I can easily implement this, but should it even be possible to
|
|
|
|
|
--delete tickets?
|
|
|
|
|
error "Not implemented"
|
2016-05-02 06:13:57 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
postTicketR :: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
postTicketR shr prj ltkhid = do
|
2016-05-02 11:34:11 +00:00
|
|
|
|
mmethod <- lookupPostParam "_method"
|
|
|
|
|
case mmethod of
|
2020-02-06 00:52:15 +00:00
|
|
|
|
Just "PUT" -> putTicketR shr prj ltkhid
|
|
|
|
|
Just "DELETE" -> deleteTicketR shr prj ltkhid
|
2016-05-02 11:34:11 +00:00
|
|
|
|
_ -> notFound
|
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
getTicketEditR :: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
getTicketEditR shr prj ltkhid = do
|
2016-08-10 18:52:26 +00:00
|
|
|
|
(tid, ticket, wid) <- runDB $ do
|
2020-02-03 14:53:12 +00:00
|
|
|
|
Entity sid _sharer <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity pid project <- getBy404 $ UniqueProject prj sid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
|
|
|
|
ticket <- getJust tid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == pid) notFound
|
2016-08-10 18:52:26 +00:00
|
|
|
|
return (tid, ticket, projectWorkflow project)
|
|
|
|
|
((_result, widget), enctype) <-
|
|
|
|
|
runFormPost $ editTicketContentForm tid ticket wid
|
2016-05-19 16:58:23 +00:00
|
|
|
|
defaultLayout $(widgetFile "ticket/edit")
|
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
postTicketAcceptR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
postTicketAcceptR shr prj ltkhid = do
|
2016-08-11 07:58:51 +00:00
|
|
|
|
succ <- runDB $ do
|
|
|
|
|
Entity tid ticket <- do
|
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity p _ <- getBy404 $ UniqueProject prj s
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
|
|
|
|
ticket <- getJust tid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == p) notFound
|
2020-02-03 14:53:12 +00:00
|
|
|
|
return $ Entity tid ticket
|
2016-08-11 07:58:51 +00:00
|
|
|
|
case ticketStatus ticket of
|
|
|
|
|
TSNew -> do
|
|
|
|
|
update tid [TicketStatus =. TSTodo]
|
|
|
|
|
return True
|
|
|
|
|
_ -> return False
|
|
|
|
|
setMessage $
|
|
|
|
|
if succ
|
|
|
|
|
then "Ticket accepted."
|
|
|
|
|
else "Ticket is already accepted."
|
2020-02-06 00:52:15 +00:00
|
|
|
|
redirect $ TicketR shr prj ltkhid
|
2016-08-11 07:58:51 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
postTicketCloseR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
postTicketCloseR shr prj ltkhid = do
|
2016-06-01 19:50:41 +00:00
|
|
|
|
pid <- requireAuthId
|
|
|
|
|
now <- liftIO getCurrentTime
|
|
|
|
|
succ <- runDB $ do
|
|
|
|
|
Entity tid ticket <- do
|
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity p _ <- getBy404 $ UniqueProject prj s
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
|
|
|
|
ticket <- getJust tid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == p) notFound
|
2020-02-03 14:53:12 +00:00
|
|
|
|
return $ Entity tid ticket
|
2016-08-11 00:44:11 +00:00
|
|
|
|
case ticketStatus ticket of
|
|
|
|
|
TSClosed -> return False
|
|
|
|
|
_ -> do
|
2016-06-01 19:50:41 +00:00
|
|
|
|
update tid
|
2016-06-06 07:44:00 +00:00
|
|
|
|
[ TicketAssignee =. Nothing
|
2016-08-11 00:44:11 +00:00
|
|
|
|
, TicketStatus =. TSClosed
|
2016-06-06 07:44:00 +00:00
|
|
|
|
, TicketClosed =. now
|
2019-06-07 04:26:32 +00:00
|
|
|
|
, TicketCloser =. Just pid
|
2016-06-01 19:50:41 +00:00
|
|
|
|
]
|
|
|
|
|
return True
|
|
|
|
|
setMessage $
|
|
|
|
|
if succ
|
|
|
|
|
then "Ticket closed."
|
|
|
|
|
else "Ticket is already closed."
|
2020-02-06 00:52:15 +00:00
|
|
|
|
redirect $ TicketR shr prj ltkhid
|
2016-06-01 19:50:41 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
postTicketOpenR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
postTicketOpenR shr prj ltkhid = do
|
2016-06-01 19:50:41 +00:00
|
|
|
|
pid <- requireAuthId
|
|
|
|
|
now <- liftIO getCurrentTime
|
|
|
|
|
succ <- runDB $ do
|
|
|
|
|
Entity tid ticket <- do
|
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity p _ <- getBy404 $ UniqueProject prj s
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
|
|
|
|
ticket <- getJust tid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == p) notFound
|
2020-02-03 14:53:12 +00:00
|
|
|
|
return $ Entity tid ticket
|
2016-08-11 00:44:11 +00:00
|
|
|
|
case ticketStatus ticket of
|
|
|
|
|
TSClosed -> do
|
2016-06-01 19:50:41 +00:00
|
|
|
|
update tid
|
2016-08-11 00:44:11 +00:00
|
|
|
|
[ TicketStatus =. TSTodo
|
2019-06-07 04:26:32 +00:00
|
|
|
|
, TicketCloser =. Nothing
|
2016-06-01 19:50:41 +00:00
|
|
|
|
]
|
|
|
|
|
return True
|
2016-08-11 00:44:11 +00:00
|
|
|
|
_ -> return False
|
2016-06-01 19:50:41 +00:00
|
|
|
|
setMessage $
|
|
|
|
|
if succ
|
|
|
|
|
then "Ticket reopened"
|
|
|
|
|
else "Ticket is already open."
|
2020-02-06 00:52:15 +00:00
|
|
|
|
redirect $ TicketR shr prj ltkhid
|
2016-06-01 19:50:41 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
postTicketClaimR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
postTicketClaimR shr prj ltkhid = do
|
2016-06-06 09:03:49 +00:00
|
|
|
|
pid <- requireAuthId
|
|
|
|
|
mmsg <- runDB $ do
|
|
|
|
|
Entity tid ticket <- do
|
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity p _ <- getBy404 $ UniqueProject prj s
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
|
|
|
|
ticket <- getJust tid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == p) notFound
|
2020-02-03 14:53:12 +00:00
|
|
|
|
return $ Entity tid ticket
|
2016-08-11 00:44:11 +00:00
|
|
|
|
case (ticketStatus ticket, ticketAssignee ticket) of
|
|
|
|
|
(TSNew, _) ->
|
|
|
|
|
return $
|
|
|
|
|
Just "The ticket isn’t accepted yet. Can’t claim it."
|
|
|
|
|
(TSClosed, _) ->
|
2016-06-06 09:03:49 +00:00
|
|
|
|
return $
|
|
|
|
|
Just "The ticket is closed. Can’t claim closed tickets."
|
2016-08-11 00:44:11 +00:00
|
|
|
|
(TSTodo, Just _) ->
|
2016-06-06 09:03:49 +00:00
|
|
|
|
return $
|
|
|
|
|
Just "The ticket is already assigned to someone."
|
2016-08-11 00:44:11 +00:00
|
|
|
|
(TSTodo, Nothing) -> do
|
2016-06-06 09:03:49 +00:00
|
|
|
|
update tid [TicketAssignee =. Just pid]
|
|
|
|
|
return Nothing
|
|
|
|
|
setMessage $ fromMaybe "The ticket is now assigned to you." mmsg
|
2020-02-06 00:52:15 +00:00
|
|
|
|
redirect $ TicketR shr prj ltkhid
|
2016-06-06 09:03:49 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
postTicketUnclaimR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
postTicketUnclaimR shr prj ltkhid = do
|
2016-06-06 09:03:49 +00:00
|
|
|
|
pid <- requireAuthId
|
|
|
|
|
mmsg <- runDB $ do
|
|
|
|
|
Entity tid ticket <- do
|
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity p _ <- getBy404 $ UniqueProject prj s
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
|
|
|
|
ticket <- getJust tid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == p) notFound
|
2020-02-03 14:53:12 +00:00
|
|
|
|
return $ Entity tid ticket
|
2016-08-11 00:44:11 +00:00
|
|
|
|
case ((== pid) <$> ticketAssignee ticket, ticketStatus ticket) of
|
2016-06-06 09:03:49 +00:00
|
|
|
|
(Nothing, _) ->
|
|
|
|
|
return $ Just "The ticket is already unassigned."
|
|
|
|
|
(Just False, _) ->
|
|
|
|
|
return $ Just "The ticket is assigned to someone else."
|
2016-08-11 00:44:11 +00:00
|
|
|
|
(Just True, TSNew) -> do
|
2020-02-03 14:53:12 +00:00
|
|
|
|
logWarn "Found a new claimed ticket, this is invalid"
|
2016-08-11 00:44:11 +00:00
|
|
|
|
return $
|
|
|
|
|
Just "The ticket isn’t accepted yet. Can’t unclaim it."
|
|
|
|
|
(Just True, TSClosed) -> do
|
2020-02-03 14:53:12 +00:00
|
|
|
|
logWarn "Found a closed claimed ticket, this is invalid"
|
2016-06-06 09:03:49 +00:00
|
|
|
|
return $
|
|
|
|
|
Just "The ticket is closed. Can’t unclaim closed tickets."
|
2016-08-11 00:44:11 +00:00
|
|
|
|
(Just True, TSTodo) -> do
|
2016-06-06 09:03:49 +00:00
|
|
|
|
update tid [TicketAssignee =. Nothing]
|
|
|
|
|
return Nothing
|
|
|
|
|
setMessage $ fromMaybe "The ticket is now unassigned." mmsg
|
2020-02-06 00:52:15 +00:00
|
|
|
|
redirect $ TicketR shr prj ltkhid
|
2016-06-06 09:03:49 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
getTicketAssignR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
getTicketAssignR shr prj ltkhid = do
|
2016-06-07 07:33:19 +00:00
|
|
|
|
vpid <- requireAuthId
|
|
|
|
|
(jid, Entity tid ticket) <- runDB $ do
|
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity j _ <- getBy404 $ UniqueProject prj s
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
|
|
|
|
ticket <- getJust tid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == j) notFound
|
2020-02-03 14:53:12 +00:00
|
|
|
|
return (j, Entity tid ticket)
|
2016-06-07 07:33:19 +00:00
|
|
|
|
let msg t = do
|
|
|
|
|
setMessage t
|
2020-02-06 00:52:15 +00:00
|
|
|
|
redirect $ TicketR shr prj ltkhid
|
2016-08-11 00:44:11 +00:00
|
|
|
|
case (ticketStatus ticket, ticketAssignee ticket) of
|
|
|
|
|
(TSNew, _) -> msg "The ticket isn’t accepted yet. Can’t assign it."
|
|
|
|
|
(TSClosed, _) -> msg "The ticket is closed. Can’t assign it."
|
|
|
|
|
(TSTodo, Just _) -> msg "The ticket is already assigned to someone."
|
|
|
|
|
(TSTodo, Nothing) -> do
|
2016-06-07 07:33:19 +00:00
|
|
|
|
((_result, widget), enctype) <-
|
|
|
|
|
runFormPost $ assignTicketForm vpid jid
|
|
|
|
|
defaultLayout $(widgetFile "ticket/assign")
|
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
postTicketAssignR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
postTicketAssignR shr prj ltkhid = do
|
2016-06-07 07:33:19 +00:00
|
|
|
|
vpid <- requireAuthId
|
|
|
|
|
(jid, Entity tid ticket) <- runDB $ do
|
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity j _ <- getBy404 $ UniqueProject prj s
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
|
|
|
|
ticket <- getJust tid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == j) notFound
|
2020-02-03 14:53:12 +00:00
|
|
|
|
return (j, Entity tid ticket)
|
2016-06-07 07:33:19 +00:00
|
|
|
|
let msg t = do
|
|
|
|
|
setMessage t
|
2020-02-06 00:52:15 +00:00
|
|
|
|
redirect $ TicketR shr prj ltkhid
|
2016-08-11 00:44:11 +00:00
|
|
|
|
case (ticketStatus ticket, ticketAssignee ticket) of
|
|
|
|
|
(TSNew, _) -> msg "The ticket isn’t accepted yet. Can’t assign it."
|
|
|
|
|
(TSClosed, _) -> msg "The ticket is closed. Can’t assign it."
|
|
|
|
|
(TSTodo, Just _) -> msg "The ticket is already assigned to someone."
|
|
|
|
|
(TSTodo, Nothing) -> do
|
2016-06-07 07:33:19 +00:00
|
|
|
|
((result, widget), enctype) <-
|
|
|
|
|
runFormPost $ assignTicketForm vpid jid
|
|
|
|
|
case result of
|
|
|
|
|
FormSuccess pid -> do
|
|
|
|
|
sharer <- runDB $ do
|
|
|
|
|
update tid [TicketAssignee =. Just pid]
|
|
|
|
|
person <- getJust pid
|
|
|
|
|
getJust $ personIdent person
|
|
|
|
|
let si = sharerIdent sharer
|
|
|
|
|
msg $ toHtml $
|
|
|
|
|
"The ticket is now assigned to " <> shr2text si <> "."
|
|
|
|
|
FormMissing -> do
|
|
|
|
|
setMessage "Field(s) missing."
|
|
|
|
|
defaultLayout $(widgetFile "ticket/assign")
|
|
|
|
|
FormFailure _l -> do
|
|
|
|
|
setMessage "Ticket assignment failed, see errors below."
|
|
|
|
|
defaultLayout $(widgetFile "ticket/assign")
|
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
postTicketUnassignR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
postTicketUnassignR shr prj ltkhid = do
|
2016-06-07 07:33:19 +00:00
|
|
|
|
pid <- requireAuthId
|
|
|
|
|
mmsg <- runDB $ do
|
|
|
|
|
Entity tid ticket <- do
|
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity p _ <- getBy404 $ UniqueProject prj s
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
|
|
|
|
ticket <- getJust tid
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == p) notFound
|
2020-02-03 14:53:12 +00:00
|
|
|
|
return $ Entity tid ticket
|
2016-08-11 00:44:11 +00:00
|
|
|
|
case ((== pid) <$> ticketAssignee ticket, ticketStatus ticket) of
|
2016-06-07 07:33:19 +00:00
|
|
|
|
(Nothing, _) ->
|
|
|
|
|
return $ Just "The ticket is already unassigned."
|
|
|
|
|
(Just True, _) ->
|
|
|
|
|
return $ Just "The ticket is assigned to you, unclaim instead."
|
2016-08-11 00:44:11 +00:00
|
|
|
|
(Just False, TSNew) -> do
|
2020-02-03 14:53:12 +00:00
|
|
|
|
logWarn "Found a new claimed ticket, this is invalid"
|
2016-08-11 00:44:11 +00:00
|
|
|
|
return $
|
|
|
|
|
Just "The ticket isn’t accepted yet. Can’t unclaim it."
|
|
|
|
|
(Just False, TSClosed) -> do
|
2020-02-03 14:53:12 +00:00
|
|
|
|
logWarn "Found a closed claimed ticket, this is invalid"
|
2016-06-07 07:33:19 +00:00
|
|
|
|
return $
|
|
|
|
|
Just "The ticket is closed. Can’t unclaim closed tickets."
|
2016-08-11 00:44:11 +00:00
|
|
|
|
(Just False, TSTodo) -> do
|
2016-06-07 07:33:19 +00:00
|
|
|
|
update tid [TicketAssignee =. Nothing]
|
|
|
|
|
return Nothing
|
|
|
|
|
setMessage $ fromMaybe "The ticket is now unassigned." mmsg
|
2020-02-06 00:52:15 +00:00
|
|
|
|
redirect $ TicketR shr prj ltkhid
|
2016-06-07 07:33:19 +00:00
|
|
|
|
|
2016-06-07 15:29:26 +00:00
|
|
|
|
-- | The logged-in user gets a list of the ticket claim requests they have
|
|
|
|
|
-- opened, in any project.
|
2016-06-07 16:31:55 +00:00
|
|
|
|
getClaimRequestsPersonR :: Handler Html
|
|
|
|
|
getClaimRequestsPersonR = do
|
2016-06-07 10:01:57 +00:00
|
|
|
|
pid <- requireAuthId
|
2019-05-25 22:04:06 +00:00
|
|
|
|
rqs <- runDB $ E.select $ E.from $
|
2020-02-06 17:25:09 +00:00
|
|
|
|
\ (tcr `E.InnerJoin` ticket `E.InnerJoin` lticket `E.InnerJoin` tpl `E.InnerJoin` project `E.InnerJoin` sharer) -> do
|
2019-05-25 22:04:06 +00:00
|
|
|
|
E.on $ project E.^. ProjectSharer E.==. sharer E.^. SharerId
|
2020-02-06 17:25:09 +00:00
|
|
|
|
E.on $ tpl E.^. TicketProjectLocalProject E.==. project E.^. ProjectId
|
|
|
|
|
E.on $ ticket E.^. TicketId E.==. tpl E.^. TicketProjectLocalTicket
|
2020-02-06 00:52:15 +00:00
|
|
|
|
E.on $ ticket E.^. TicketId E.==. lticket E.^. LocalTicketTicket
|
2019-05-25 22:04:06 +00:00
|
|
|
|
E.on $ tcr E.^. TicketClaimRequestTicket E.==. ticket E.^. TicketId
|
|
|
|
|
E.where_ $ tcr E.^. TicketClaimRequestPerson E.==. E.val pid
|
|
|
|
|
E.orderBy [E.desc $ tcr E.^. TicketClaimRequestCreated]
|
2016-06-07 10:01:57 +00:00
|
|
|
|
return
|
2019-05-25 22:04:06 +00:00
|
|
|
|
( sharer E.^. SharerIdent
|
|
|
|
|
, project E.^. ProjectIdent
|
2020-02-06 00:52:15 +00:00
|
|
|
|
, lticket E.^. LocalTicketId
|
2019-05-25 22:04:06 +00:00
|
|
|
|
, ticket E.^. TicketTitle
|
|
|
|
|
, tcr E.^. TicketClaimRequestCreated
|
2016-06-07 10:01:57 +00:00
|
|
|
|
)
|
2020-02-03 14:53:12 +00:00
|
|
|
|
encodeHid <- getEncodeKeyHashid
|
2016-06-07 10:01:57 +00:00
|
|
|
|
defaultLayout $(widgetFile "person/claim-requests")
|
|
|
|
|
|
2016-06-07 15:29:26 +00:00
|
|
|
|
-- | Get a list of ticket claim requests for a given project.
|
2016-06-07 16:31:55 +00:00
|
|
|
|
getClaimRequestsProjectR :: ShrIdent -> PrjIdent -> Handler Html
|
|
|
|
|
getClaimRequestsProjectR shr prj = do
|
2016-06-07 15:29:26 +00:00
|
|
|
|
rqs <- runDB $ do
|
|
|
|
|
Entity sid _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
2019-05-25 22:04:06 +00:00
|
|
|
|
E.select $ E.from $
|
2020-02-06 17:25:09 +00:00
|
|
|
|
\ ( tcr `E.InnerJoin`
|
|
|
|
|
ticket `E.InnerJoin`
|
2020-02-06 00:52:15 +00:00
|
|
|
|
lticket `E.InnerJoin`
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl `E.InnerJoin`
|
|
|
|
|
person `E.InnerJoin`
|
2016-06-07 15:29:26 +00:00
|
|
|
|
sharer
|
|
|
|
|
) -> do
|
2019-05-25 22:04:06 +00:00
|
|
|
|
E.on $ person E.^. PersonIdent E.==. sharer E.^. SharerId
|
|
|
|
|
E.on $ tcr E.^. TicketClaimRequestPerson E.==. person E.^. PersonId
|
2020-02-06 17:25:09 +00:00
|
|
|
|
E.on $ ticket E.^. TicketId E.==. tpl E.^. TicketProjectLocalTicket
|
2020-02-06 00:52:15 +00:00
|
|
|
|
E.on $ ticket E.^. TicketId E.==. lticket E.^. LocalTicketTicket
|
2019-05-25 22:04:06 +00:00
|
|
|
|
E.on $ tcr E.^. TicketClaimRequestTicket E.==. ticket E.^. TicketId
|
2020-02-06 17:25:09 +00:00
|
|
|
|
E.where_ $ tpl E.^. TicketProjectLocalProject E.==. E.val jid
|
2019-05-25 22:04:06 +00:00
|
|
|
|
E.orderBy [E.desc $ tcr E.^. TicketClaimRequestCreated]
|
2016-06-07 15:29:26 +00:00
|
|
|
|
return
|
|
|
|
|
( sharer
|
2020-02-06 00:52:15 +00:00
|
|
|
|
, lticket E.^. LocalTicketId
|
2019-05-25 22:04:06 +00:00
|
|
|
|
, ticket E.^. TicketTitle
|
|
|
|
|
, tcr E.^. TicketClaimRequestCreated
|
2016-06-07 15:29:26 +00:00
|
|
|
|
)
|
2020-02-03 14:53:12 +00:00
|
|
|
|
encodeHid <- getEncodeKeyHashid
|
2016-06-07 16:31:55 +00:00
|
|
|
|
defaultLayout $(widgetFile "project/claim-request/list")
|
|
|
|
|
|
|
|
|
|
-- | Get a list of ticket claim requests for a given ticket.
|
2020-02-03 14:53:12 +00:00
|
|
|
|
getClaimRequestsTicketR
|
2020-02-06 00:52:15 +00:00
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
getClaimRequestsTicketR shr prj ltkhid = do
|
2016-06-07 16:31:55 +00:00
|
|
|
|
rqs <- runDB $ do
|
|
|
|
|
Entity sid _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == jid) notFound
|
2019-05-25 22:04:06 +00:00
|
|
|
|
E.select $ E.from $ \ (tcr `E.InnerJoin` person `E.InnerJoin` sharer) -> do
|
|
|
|
|
E.on $ person E.^. PersonIdent E.==. sharer E.^. SharerId
|
|
|
|
|
E.on $ tcr E.^. TicketClaimRequestPerson E.==. person E.^. PersonId
|
|
|
|
|
E.where_ $ tcr E.^. TicketClaimRequestTicket E.==. E.val tid
|
|
|
|
|
E.orderBy [E.desc $ tcr E.^. TicketClaimRequestCreated]
|
2016-06-07 16:31:55 +00:00
|
|
|
|
return (sharer, tcr)
|
2016-06-07 15:29:26 +00:00
|
|
|
|
defaultLayout $(widgetFile "ticket/claim-request/list")
|
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
getClaimRequestNewR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
getClaimRequestNewR shr prj ltkhid = do
|
2016-06-08 01:28:18 +00:00
|
|
|
|
((_result, widget), etype) <- runFormPost claimRequestForm
|
|
|
|
|
defaultLayout $(widgetFile "ticket/claim-request/new")
|
|
|
|
|
|
2020-02-03 14:53:12 +00:00
|
|
|
|
postClaimRequestsTicketR
|
2020-02-06 00:52:15 +00:00
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
postClaimRequestsTicketR shr prj ltkhid = do
|
2016-06-08 01:28:18 +00:00
|
|
|
|
((result, widget), etype) <- runFormPost claimRequestForm
|
|
|
|
|
case result of
|
|
|
|
|
FormSuccess msg -> do
|
|
|
|
|
now <- liftIO getCurrentTime
|
|
|
|
|
pid <- requireAuthId
|
|
|
|
|
runDB $ do
|
|
|
|
|
tid <- do
|
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity j _ <- getBy404 $ UniqueProject prj s
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == j) notFound
|
2020-02-03 14:53:12 +00:00
|
|
|
|
return tid
|
2016-06-08 01:28:18 +00:00
|
|
|
|
let cr = TicketClaimRequest
|
|
|
|
|
{ ticketClaimRequestPerson = pid
|
|
|
|
|
, ticketClaimRequestTicket = tid
|
|
|
|
|
, ticketClaimRequestMessage = msg
|
|
|
|
|
, ticketClaimRequestCreated = now
|
|
|
|
|
}
|
|
|
|
|
insert_ cr
|
|
|
|
|
setMessage "Ticket claim request opened."
|
2020-02-06 00:52:15 +00:00
|
|
|
|
redirect $ TicketR shr prj ltkhid
|
2016-06-08 01:28:18 +00:00
|
|
|
|
FormMissing -> do
|
|
|
|
|
setMessage "Field(s) missing."
|
|
|
|
|
defaultLayout $(widgetFile "ticket/claim-request/new")
|
|
|
|
|
FormFailure _l -> do
|
|
|
|
|
setMessage "Submission failed, see errors below."
|
|
|
|
|
defaultLayout $(widgetFile "ticket/claim-request/new")
|
|
|
|
|
|
2020-02-03 14:53:12 +00:00
|
|
|
|
selectDiscussionId
|
2020-02-06 00:52:15 +00:00
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> AppDB DiscussionId
|
|
|
|
|
selectDiscussionId shr prj ltkhid = do
|
|
|
|
|
Entity sid _sharer <- getBy404 $ UniqueSharer shr
|
2020-02-06 17:25:09 +00:00
|
|
|
|
Entity jid _project <- getBy404 $ UniqueProject prj sid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == jid) notFound
|
2020-02-05 14:09:12 +00:00
|
|
|
|
return $ localTicketDiscuss lticket
|
2016-05-19 22:07:25 +00:00
|
|
|
|
|
2020-02-03 14:53:12 +00:00
|
|
|
|
getTicketDiscussionR
|
2020-02-06 00:52:15 +00:00
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
getTicketDiscussionR shar proj ltkhid = do
|
2019-03-29 03:25:32 +00:00
|
|
|
|
encodeHid <- getEncodeKeyHashid
|
2016-05-19 22:40:54 +00:00
|
|
|
|
getDiscussion
|
2020-02-06 00:52:15 +00:00
|
|
|
|
(TicketReplyR shar proj ltkhid . encodeHid)
|
|
|
|
|
(TicketTopReplyR shar proj ltkhid)
|
|
|
|
|
(selectDiscussionId shar proj ltkhid)
|
2016-05-19 16:58:23 +00:00
|
|
|
|
|
2020-02-03 14:53:12 +00:00
|
|
|
|
postTicketDiscussionR
|
2020-02-06 00:52:15 +00:00
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
postTicketDiscussionR shr prj ltkhid = do
|
2019-04-20 21:34:45 +00:00
|
|
|
|
hLocal <- getsYesod $ appInstanceHost . appSettings
|
2016-05-21 20:01:31 +00:00
|
|
|
|
postTopReply
|
2019-04-20 21:34:45 +00:00
|
|
|
|
hLocal
|
2019-05-17 22:42:01 +00:00
|
|
|
|
[ProjectR shr prj]
|
2019-06-30 02:23:58 +00:00
|
|
|
|
[ ProjectFollowersR shr prj
|
2020-02-06 00:52:15 +00:00
|
|
|
|
, TicketParticipantsR shr prj ltkhid
|
|
|
|
|
, TicketTeamR shr prj ltkhid
|
2019-06-30 02:23:58 +00:00
|
|
|
|
]
|
2020-02-06 00:52:15 +00:00
|
|
|
|
(TicketR shr prj ltkhid)
|
2019-09-30 09:00:44 +00:00
|
|
|
|
(ProjectR shr prj)
|
2020-02-06 00:52:15 +00:00
|
|
|
|
(TicketDiscussionR shr prj ltkhid)
|
|
|
|
|
(const $ TicketR shr prj ltkhid)
|
2016-05-21 20:01:31 +00:00
|
|
|
|
|
2019-03-29 03:25:32 +00:00
|
|
|
|
getMessageR :: ShrIdent -> KeyHashid LocalMessage -> Handler TypedContent
|
2019-03-22 20:46:42 +00:00
|
|
|
|
getMessageR shr hid = do
|
2019-03-29 03:25:32 +00:00
|
|
|
|
lmid <- decodeKeyHashid404 hid
|
2019-03-22 20:46:42 +00:00
|
|
|
|
getDiscussionMessage shr lmid
|
2019-03-15 16:36:02 +00:00
|
|
|
|
|
2020-02-03 14:53:12 +00:00
|
|
|
|
postTicketMessageR
|
|
|
|
|
:: ShrIdent
|
|
|
|
|
-> PrjIdent
|
2020-02-06 00:52:15 +00:00
|
|
|
|
-> KeyHashid LocalTicket
|
2020-02-03 14:53:12 +00:00
|
|
|
|
-> KeyHashid Message
|
|
|
|
|
-> Handler Html
|
2020-02-06 00:52:15 +00:00
|
|
|
|
postTicketMessageR shr prj ltkhid mkhid = do
|
2019-03-29 03:25:32 +00:00
|
|
|
|
encodeHid <- getEncodeKeyHashid
|
2019-04-20 21:34:45 +00:00
|
|
|
|
mid <- decodeKeyHashid404 mkhid
|
|
|
|
|
hLocal <- getsYesod $ appInstanceHost . appSettings
|
2016-05-19 22:07:25 +00:00
|
|
|
|
postReply
|
2019-04-20 21:34:45 +00:00
|
|
|
|
hLocal
|
2019-05-17 22:42:01 +00:00
|
|
|
|
[ProjectR shr prj]
|
2019-06-30 02:23:58 +00:00
|
|
|
|
[ ProjectFollowersR shr prj
|
2020-02-06 00:52:15 +00:00
|
|
|
|
, TicketParticipantsR shr prj ltkhid
|
|
|
|
|
, TicketTeamR shr prj ltkhid
|
2019-06-30 02:23:58 +00:00
|
|
|
|
]
|
2020-02-06 00:52:15 +00:00
|
|
|
|
(TicketR shr prj ltkhid)
|
2019-09-30 09:00:44 +00:00
|
|
|
|
(ProjectR shr prj)
|
2020-02-06 00:52:15 +00:00
|
|
|
|
(TicketReplyR shr prj ltkhid . encodeHid)
|
|
|
|
|
(TicketMessageR shr prj ltkhid . encodeHid)
|
|
|
|
|
(const $ TicketR shr prj ltkhid)
|
|
|
|
|
(selectDiscussionId shr prj ltkhid)
|
2019-03-15 16:36:02 +00:00
|
|
|
|
mid
|
2016-05-19 22:07:25 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
getTicketTopReplyR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
getTicketTopReplyR shr prj ltkhid =
|
|
|
|
|
getTopReply $ TicketDiscussionR shr prj ltkhid
|
2016-05-19 22:07:25 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
getTicketReplyR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> KeyHashid Message -> Handler Html
|
|
|
|
|
getTicketReplyR shr prj ltkhid mkhid = do
|
2019-03-29 03:25:32 +00:00
|
|
|
|
encodeHid <- getEncodeKeyHashid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
mid <- decodeKeyHashid404 mkhid
|
2016-05-19 22:07:25 +00:00
|
|
|
|
getReply
|
2020-02-06 00:52:15 +00:00
|
|
|
|
(TicketReplyR shr prj ltkhid . encodeHid)
|
|
|
|
|
(TicketMessageR shr prj ltkhid . encodeHid)
|
|
|
|
|
(selectDiscussionId shr prj ltkhid)
|
2019-03-15 16:36:02 +00:00
|
|
|
|
mid
|
2016-06-07 20:16:15 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
getTicketDeps
|
|
|
|
|
:: Bool -> ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler TypedContent
|
|
|
|
|
getTicketDeps forward shr prj ltkhid = do
|
2019-07-23 18:15:51 +00:00
|
|
|
|
(deps, rows) <- unzip <$> runDB getDepsFromDB
|
|
|
|
|
depsAP <- makeDepsCollection deps
|
2020-02-03 14:53:12 +00:00
|
|
|
|
encodeHid <- getEncodeKeyHashid
|
2019-07-23 18:15:51 +00:00
|
|
|
|
provideHtmlAndAP depsAP $(widgetFile "ticket/dep/list")
|
|
|
|
|
where
|
|
|
|
|
getDepsFromDB = do
|
|
|
|
|
let from' =
|
|
|
|
|
if forward then TicketDependencyParent else TicketDependencyChild
|
|
|
|
|
to' =
|
|
|
|
|
if forward then TicketDependencyChild else TicketDependencyParent
|
2016-06-07 20:16:15 +00:00
|
|
|
|
Entity sid _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == jid) notFound
|
2019-06-07 04:26:32 +00:00
|
|
|
|
fmap (map toRow) $ E.select $ E.from $
|
|
|
|
|
\ ( td
|
|
|
|
|
`E.InnerJoin` t
|
2020-02-06 00:52:15 +00:00
|
|
|
|
`E.InnerJoin` lt
|
2020-02-07 23:05:42 +00:00
|
|
|
|
`E.InnerJoin` tpl
|
2019-06-07 04:26:32 +00:00
|
|
|
|
`E.LeftOuterJoin` (tal `E.InnerJoin` p `E.InnerJoin` s)
|
2019-11-06 19:47:50 +00:00
|
|
|
|
`E.LeftOuterJoin` (tar `E.InnerJoin` ra `E.InnerJoin` ro `E.InnerJoin` i)
|
2016-06-07 20:16:15 +00:00
|
|
|
|
) -> do
|
2019-11-06 19:47:50 +00:00
|
|
|
|
E.on $ ro E.?. RemoteObjectInstance E.==. i E.?. InstanceId
|
|
|
|
|
E.on $ ra E.?. RemoteActorIdent E.==. ro E.?. RemoteObjectId
|
2019-06-07 04:26:32 +00:00
|
|
|
|
E.on $ tar E.?. TicketAuthorRemoteAuthor E.==. ra E.?. RemoteActorId
|
2020-02-07 23:05:42 +00:00
|
|
|
|
E.on $ E.just (tpl E.^. TicketProjectLocalId) E.==. tar E.?. TicketAuthorRemoteTicket
|
2019-06-07 04:26:32 +00:00
|
|
|
|
E.on $ p E.?. PersonIdent E.==. s E.?. SharerId
|
|
|
|
|
E.on $ tal E.?. TicketAuthorLocalAuthor E.==. p E.?. PersonId
|
2020-02-06 03:41:16 +00:00
|
|
|
|
E.on $ E.just (lt E.^. LocalTicketId) E.==. tal E.?. TicketAuthorLocalTicket
|
2020-02-07 23:05:42 +00:00
|
|
|
|
E.on $ t E.^. TicketId E.==. tpl E.^. TicketProjectLocalTicket
|
2020-02-06 00:52:15 +00:00
|
|
|
|
E.on $ t E.^. TicketId E.==. lt E.^. LocalTicketTicket
|
2019-06-07 04:26:32 +00:00
|
|
|
|
E.on $ td E.^. to' E.==. t E.^. TicketId
|
2019-05-25 22:04:06 +00:00
|
|
|
|
E.where_ $ td E.^. from' E.==. E.val tid
|
2020-02-03 15:44:16 +00:00
|
|
|
|
E.orderBy [E.asc $ t E.^. TicketId]
|
2016-06-07 20:16:15 +00:00
|
|
|
|
return
|
2019-07-23 18:15:51 +00:00
|
|
|
|
( td E.^. TicketDependencyId
|
2020-02-06 00:52:15 +00:00
|
|
|
|
, lt E.^. LocalTicketId
|
2019-06-07 04:26:32 +00:00
|
|
|
|
, s
|
|
|
|
|
, i
|
2019-11-06 19:47:50 +00:00
|
|
|
|
, ro
|
2019-06-07 04:26:32 +00:00
|
|
|
|
, ra
|
|
|
|
|
, t E.^. TicketTitle
|
|
|
|
|
, t E.^. TicketStatus
|
2016-06-07 20:16:15 +00:00
|
|
|
|
)
|
2019-07-23 18:15:51 +00:00
|
|
|
|
where
|
2020-02-06 00:52:15 +00:00
|
|
|
|
toRow (E.Value dep, E.Value ltid, ms, mi, mro, mra, E.Value title, E.Value status) =
|
2019-07-23 18:15:51 +00:00
|
|
|
|
( dep
|
2020-02-06 00:52:15 +00:00
|
|
|
|
, ( ltid
|
2019-11-06 19:47:50 +00:00
|
|
|
|
, case (ms, mi, mro, mra) of
|
|
|
|
|
(Just s, Nothing, Nothing, Nothing) ->
|
2019-07-23 18:15:51 +00:00
|
|
|
|
Left $ entityVal s
|
2019-11-06 19:47:50 +00:00
|
|
|
|
(Nothing, Just i, Just ro, Just ra) ->
|
|
|
|
|
Right (entityVal i, entityVal ro, entityVal ra)
|
2019-07-23 18:15:51 +00:00
|
|
|
|
_ -> error "Ticket author DB invalid state"
|
|
|
|
|
, title
|
|
|
|
|
, status
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
makeDepsCollection tdids = do
|
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
|
encodeRouteHome <- getEncodeRouteHome
|
|
|
|
|
encodeKeyHashid <- getEncodeKeyHashid
|
|
|
|
|
let here =
|
|
|
|
|
let route = if forward then TicketDepsR else TicketReverseDepsR
|
2020-02-06 00:52:15 +00:00
|
|
|
|
in route shr prj ltkhid
|
2019-07-23 18:15:51 +00:00
|
|
|
|
return Collection
|
|
|
|
|
{ collectionId = encodeRouteLocal here
|
|
|
|
|
, collectionType = CollectionTypeUnordered
|
|
|
|
|
, collectionTotalItems = Just $ length tdids
|
|
|
|
|
, collectionCurrent = Nothing
|
|
|
|
|
, collectionFirst = Nothing
|
|
|
|
|
, collectionLast = Nothing
|
|
|
|
|
, collectionItems =
|
|
|
|
|
map (encodeRouteHome . TicketDepR . encodeKeyHashid) tdids
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-03 14:53:12 +00:00
|
|
|
|
getTicketDepsR
|
2020-02-06 00:52:15 +00:00
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler TypedContent
|
2016-07-27 08:35:50 +00:00
|
|
|
|
getTicketDepsR = getTicketDeps True
|
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
postTicketDepsR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
postTicketDepsR shr prj ltkhid = do
|
2016-07-28 16:40:10 +00:00
|
|
|
|
(jid, tid) <- runDB $ do
|
|
|
|
|
Entity sid _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == jid) notFound
|
2016-07-28 16:40:10 +00:00
|
|
|
|
return (jid, tid)
|
|
|
|
|
((result, widget), enctype) <- runFormPost $ ticketDepForm jid tid
|
|
|
|
|
case result of
|
|
|
|
|
FormSuccess ctid -> do
|
2019-07-11 15:14:16 +00:00
|
|
|
|
pidAuthor <- requireVerifiedAuthId
|
|
|
|
|
now <- liftIO getCurrentTime
|
2016-07-28 16:40:10 +00:00
|
|
|
|
runDB $ do
|
|
|
|
|
let td = TicketDependency
|
2019-07-11 15:14:16 +00:00
|
|
|
|
{ ticketDependencyParent = tid
|
|
|
|
|
, ticketDependencyChild = ctid
|
|
|
|
|
, ticketDependencyAuthor = pidAuthor
|
|
|
|
|
, ticketDependencySummary = "(A ticket dependency)"
|
|
|
|
|
, ticketDependencyCreated = now
|
2016-07-28 16:40:10 +00:00
|
|
|
|
}
|
|
|
|
|
insert_ td
|
|
|
|
|
trrFix td ticketDepGraph
|
|
|
|
|
setMessage "Ticket dependency added."
|
2020-02-06 00:52:15 +00:00
|
|
|
|
redirect $ TicketR shr prj ltkhid
|
2016-07-28 16:40:10 +00:00
|
|
|
|
FormMissing -> do
|
|
|
|
|
setMessage "Field(s) missing."
|
|
|
|
|
defaultLayout $(widgetFile "ticket/dep/new")
|
|
|
|
|
FormFailure _l -> do
|
|
|
|
|
setMessage "Submission failed, see errors below."
|
|
|
|
|
defaultLayout $(widgetFile "ticket/dep/new")
|
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
getTicketDepNewR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler Html
|
|
|
|
|
getTicketDepNewR shr prj ltkhid = do
|
2016-07-28 16:40:10 +00:00
|
|
|
|
(jid, tid) <- runDB $ do
|
|
|
|
|
Entity sid _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lticket <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lticket
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == jid) notFound
|
2016-07-28 16:40:10 +00:00
|
|
|
|
return (jid, tid)
|
|
|
|
|
((_result, widget), enctype) <- runFormPost $ ticketDepForm jid tid
|
|
|
|
|
defaultLayout $(widgetFile "ticket/dep/new")
|
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
postTicketDepOldR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> KeyHashid LocalTicket -> Handler Html
|
2020-02-03 15:10:13 +00:00
|
|
|
|
postTicketDepOldR shr prj pnum cnum = do
|
2016-07-28 16:40:10 +00:00
|
|
|
|
mmethod <- lookupPostParam "_method"
|
|
|
|
|
case mmethod of
|
2019-07-08 15:54:41 +00:00
|
|
|
|
Just "DELETE" -> deleteTicketDepOldR shr prj pnum cnum
|
2016-07-28 16:40:10 +00:00
|
|
|
|
_ -> notFound
|
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
deleteTicketDepOldR
|
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> KeyHashid LocalTicket -> Handler Html
|
2020-02-03 15:10:13 +00:00
|
|
|
|
deleteTicketDepOldR shr prj pnum cnum = do
|
2016-07-28 16:40:10 +00:00
|
|
|
|
runDB $ do
|
|
|
|
|
Entity sid _ <- getBy404 $ UniqueSharer shr
|
|
|
|
|
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
2020-02-03 15:10:13 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
pltid <- decodeKeyHashid404 pnum
|
|
|
|
|
plt <- get404 pltid
|
|
|
|
|
let ptid = localTicketTicket plt
|
2020-02-06 17:25:09 +00:00
|
|
|
|
ptpl <- getValBy404 $ UniqueTicketProjectLocal ptid
|
|
|
|
|
unless (ticketProjectLocalProject ptpl == jid) notFound
|
2020-02-03 15:10:13 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
cltid <- decodeKeyHashid404 cnum
|
|
|
|
|
clt <- get404 cltid
|
|
|
|
|
let ctid = localTicketTicket clt
|
2020-02-06 17:25:09 +00:00
|
|
|
|
ctpl <- getValBy404 $ UniqueTicketProjectLocal ctid
|
|
|
|
|
unless (ticketProjectLocalProject ctpl == jid) notFound
|
2020-02-03 15:10:13 +00:00
|
|
|
|
|
2016-07-28 16:40:10 +00:00
|
|
|
|
Entity tdid _ <- getBy404 $ UniqueTicketDependency ptid ctid
|
|
|
|
|
delete tdid
|
|
|
|
|
setMessage "Ticket dependency removed."
|
|
|
|
|
redirect $ TicketDepsR shr prj pnum
|
|
|
|
|
|
2020-02-03 14:53:12 +00:00
|
|
|
|
getTicketReverseDepsR
|
2020-02-06 00:52:15 +00:00
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler TypedContent
|
2016-07-27 08:35:50 +00:00
|
|
|
|
getTicketReverseDepsR = getTicketDeps False
|
2019-04-11 13:44:44 +00:00
|
|
|
|
|
2019-07-11 15:14:16 +00:00
|
|
|
|
getTicketDepR :: KeyHashid TicketDependency -> Handler TypedContent
|
|
|
|
|
getTicketDepR tdkhid = do
|
|
|
|
|
tdid <- decodeKeyHashid404 tdkhid
|
|
|
|
|
( td,
|
2020-02-06 00:52:15 +00:00
|
|
|
|
(sParent, jParent, ltParent),
|
|
|
|
|
(sChild, jChild, ltChild),
|
2019-07-11 15:14:16 +00:00
|
|
|
|
(sAuthor, pAuthor)
|
|
|
|
|
) <- runDB $ do
|
|
|
|
|
tdep <- get404 tdid
|
|
|
|
|
(,,,) tdep
|
|
|
|
|
<$> getTicket (ticketDependencyParent tdep)
|
|
|
|
|
<*> getTicket (ticketDependencyChild tdep)
|
|
|
|
|
<*> getAuthor (ticketDependencyAuthor tdep)
|
|
|
|
|
|
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
|
encodeRouteHome <- getEncodeRouteHome
|
2020-02-03 14:53:12 +00:00
|
|
|
|
encodeHid <- getEncodeKeyHashid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
let ticketRoute s j lt =
|
|
|
|
|
TicketR (sharerIdent s) (projectIdent j) (encodeHid lt)
|
2019-07-11 15:14:16 +00:00
|
|
|
|
here = TicketDepR tdkhid
|
2019-07-11 22:18:30 +00:00
|
|
|
|
tdepAP = AP.TicketDependency
|
|
|
|
|
{ ticketDepId = Just $ encodeRouteHome here
|
|
|
|
|
, ticketDepParent =
|
2020-02-06 00:52:15 +00:00
|
|
|
|
encodeRouteHome $ ticketRoute sParent jParent ltParent
|
2019-07-11 22:18:30 +00:00
|
|
|
|
, ticketDepChild =
|
2020-02-06 00:52:15 +00:00
|
|
|
|
encodeRouteHome $ ticketRoute sChild jChild ltChild
|
2019-07-11 22:18:30 +00:00
|
|
|
|
, ticketDepAttributedTo =
|
2019-07-11 15:14:16 +00:00
|
|
|
|
encodeRouteLocal $ SharerR $ sharerIdent sAuthor
|
2019-07-11 22:18:30 +00:00
|
|
|
|
, ticketDepPublished = Just $ ticketDependencyCreated td
|
|
|
|
|
, ticketDepUpdated = Just $ ticketDependencyCreated td
|
|
|
|
|
, ticketDepSummary = TextHtml $ ticketDependencySummary td
|
2019-07-11 15:14:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
provideHtmlAndAP tdepAP $ redirectToPrettyJSON here
|
|
|
|
|
where
|
|
|
|
|
getTicket tid = do
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- do
|
|
|
|
|
mltid <- getKeyBy $ UniqueLocalTicket tid
|
|
|
|
|
case mltid of
|
|
|
|
|
Nothing -> error "No LocalTicket"
|
2020-02-06 17:25:09 +00:00
|
|
|
|
Just v -> return v
|
|
|
|
|
tpl <- do
|
|
|
|
|
mtpl <- getValBy $ UniqueTicketProjectLocal tid
|
|
|
|
|
case mtpl of
|
|
|
|
|
Nothing -> error "No TicketProjectLocal"
|
|
|
|
|
Just v -> return v
|
|
|
|
|
j <- getJust $ ticketProjectLocalProject tpl
|
2019-07-11 15:14:16 +00:00
|
|
|
|
s <- getJust $ projectSharer j
|
2020-02-06 00:52:15 +00:00
|
|
|
|
return (s, j, ltid)
|
2019-07-11 15:14:16 +00:00
|
|
|
|
getAuthor pid = do
|
|
|
|
|
p <- getJust pid
|
|
|
|
|
s <- getJust $ personIdent p
|
|
|
|
|
return (s, p)
|
|
|
|
|
|
2020-02-03 14:53:12 +00:00
|
|
|
|
getTicketParticipantsR
|
2020-02-06 00:52:15 +00:00
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler TypedContent
|
|
|
|
|
getTicketParticipantsR shr prj ltkhid = getFollowersCollection here getFsid
|
2019-06-11 12:19:51 +00:00
|
|
|
|
where
|
2020-02-06 00:52:15 +00:00
|
|
|
|
here = TicketParticipantsR shr prj ltkhid
|
2019-06-11 12:19:51 +00:00
|
|
|
|
getFsid = do
|
2019-05-25 22:05:59 +00:00
|
|
|
|
sid <- getKeyBy404 $ UniqueSharer shr
|
|
|
|
|
jid <- getKeyBy404 $ UniqueProject prj sid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lt <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lt
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == jid) notFound
|
2020-02-05 14:09:12 +00:00
|
|
|
|
return $ localTicketFollowers lt
|
2019-04-11 13:44:44 +00:00
|
|
|
|
|
2020-02-03 14:53:12 +00:00
|
|
|
|
getTicketTeamR
|
2020-02-06 00:52:15 +00:00
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler TypedContent
|
|
|
|
|
getTicketTeamR shr prj ltkhid = do
|
2019-05-25 22:05:59 +00:00
|
|
|
|
memberShrs <- runDB $ do
|
|
|
|
|
sid <- getKeyBy404 $ UniqueSharer shr
|
2020-02-03 14:53:12 +00:00
|
|
|
|
jid <- getKeyBy404 $ UniqueProject prj sid
|
2020-02-06 00:52:15 +00:00
|
|
|
|
ltid <- decodeKeyHashid404 ltkhid
|
|
|
|
|
lt <- get404 ltid
|
|
|
|
|
let tid = localTicketTicket lt
|
2020-02-06 17:25:09 +00:00
|
|
|
|
tpl <- getValBy404 $ UniqueTicketProjectLocal tid
|
|
|
|
|
unless (ticketProjectLocalProject tpl == jid) notFound
|
2019-05-25 22:05:59 +00:00
|
|
|
|
id_ <-
|
|
|
|
|
requireEitherAlt
|
|
|
|
|
(getKeyBy $ UniquePersonIdent sid)
|
|
|
|
|
(getKeyBy $ UniqueGroup sid)
|
|
|
|
|
"Found sharer that is neither person nor group"
|
|
|
|
|
"Found sharer that is both person and group"
|
|
|
|
|
case id_ of
|
|
|
|
|
Left pid -> return [shr]
|
|
|
|
|
Right gid -> do
|
|
|
|
|
pids <-
|
|
|
|
|
map (groupMemberPerson . entityVal) <$>
|
|
|
|
|
selectList [GroupMemberGroup ==. gid] []
|
|
|
|
|
sids <-
|
|
|
|
|
map (personIdent . entityVal) <$>
|
|
|
|
|
selectList [PersonId <-. pids] []
|
|
|
|
|
map (sharerIdent . entityVal) <$>
|
|
|
|
|
selectList [SharerId <-. sids] []
|
2019-06-11 12:19:51 +00:00
|
|
|
|
|
2020-02-06 00:52:15 +00:00
|
|
|
|
let here = TicketTeamR shr prj ltkhid
|
2019-06-11 12:19:51 +00:00
|
|
|
|
|
2019-05-25 22:05:59 +00:00
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
|
encodeRouteHome <- getEncodeRouteHome
|
2019-06-11 12:19:51 +00:00
|
|
|
|
let team = Collection
|
|
|
|
|
{ collectionId = encodeRouteLocal here
|
2019-05-25 22:05:59 +00:00
|
|
|
|
, collectionType = CollectionTypeUnordered
|
|
|
|
|
, collectionTotalItems = Just $ length memberShrs
|
|
|
|
|
, collectionCurrent = Nothing
|
|
|
|
|
, collectionFirst = Nothing
|
|
|
|
|
, collectionLast = Nothing
|
|
|
|
|
, collectionItems = map (encodeRouteHome . SharerR) memberShrs
|
|
|
|
|
}
|
2020-02-03 14:53:12 +00:00
|
|
|
|
provideHtmlAndAP team $ redirectToPrettyJSON here
|
2019-06-03 21:52:34 +00:00
|
|
|
|
|
2020-02-03 14:53:12 +00:00
|
|
|
|
getTicketEventsR
|
2020-02-06 00:52:15 +00:00
|
|
|
|
:: ShrIdent -> PrjIdent -> KeyHashid LocalTicket -> Handler TypedContent
|
|
|
|
|
getTicketEventsR _shr _prj _ltkhid = error "TODO not implemented"
|
2020-02-08 15:24:36 +00:00
|
|
|
|
|
2020-02-10 14:10:01 +00:00
|
|
|
|
getSharerTicket
|
|
|
|
|
:: ShrIdent
|
|
|
|
|
-> KeyHashid TicketAuthorLocal
|
|
|
|
|
-> AppDB
|
|
|
|
|
( Entity TicketAuthorLocal
|
|
|
|
|
, Entity LocalTicket
|
|
|
|
|
, Entity Ticket
|
|
|
|
|
, Either (Entity TicketProjectLocal) ()
|
|
|
|
|
)
|
|
|
|
|
getSharerTicket shr talkhid = do
|
|
|
|
|
pid <- do
|
|
|
|
|
sid <- getKeyBy404 $ UniqueSharer shr
|
|
|
|
|
getKeyBy404 $ UniquePersonIdent sid
|
|
|
|
|
talid <- decodeKeyHashid404 talkhid
|
|
|
|
|
tal <- get404 talid
|
|
|
|
|
unless (ticketAuthorLocalAuthor tal == pid) notFound
|
|
|
|
|
let ltid = ticketAuthorLocalTicket tal
|
|
|
|
|
lt <- getJust ltid
|
|
|
|
|
let tid = localTicketTicket lt
|
|
|
|
|
t <- getJust tid
|
|
|
|
|
project <-
|
|
|
|
|
requireEitherAlt
|
|
|
|
|
(do mtpl <- getBy $ UniqueTicketProjectLocal tid
|
|
|
|
|
for mtpl $ \ etpl@(Entity tplid tpl) -> do
|
|
|
|
|
mtup1 <- getBy $ UniqueTicketUnderProjectProject tplid
|
|
|
|
|
mtup2 <- getBy $ UniqueTicketUnderProjectAuthor talid
|
|
|
|
|
unless (isJust mtup1 == isJust mtup2) $
|
|
|
|
|
error "TUP points to unrelated TAL and TPL!"
|
|
|
|
|
unless (isNothing mtup1) notFound
|
|
|
|
|
return etpl
|
|
|
|
|
)
|
|
|
|
|
(return Nothing
|
|
|
|
|
)
|
|
|
|
|
"Ticket doesn't have project"
|
|
|
|
|
"Ticket has both local and remote project"
|
|
|
|
|
return (Entity talid tal, Entity ltid lt, Entity tid t, project)
|
|
|
|
|
|
2020-02-08 15:24:36 +00:00
|
|
|
|
getSharerTicketsR :: ShrIdent -> Handler TypedContent
|
|
|
|
|
getSharerTicketsR shr = do
|
|
|
|
|
(total, pages, mpage) <- runDB $ do
|
|
|
|
|
sid <- getKeyBy404 $ UniqueSharer shr
|
|
|
|
|
pid <- getKeyBy404 $ UniquePersonIdent sid
|
|
|
|
|
getPageAndNavCount (countTickets pid) (selectTickets pid)
|
|
|
|
|
encodeRouteHome <- getEncodeRouteHome
|
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
|
encodeRoutePageLocal <- getEncodeRoutePageLocal
|
|
|
|
|
let pageUrl = encodeRoutePageLocal here
|
|
|
|
|
encodeTicketKey <- getEncodeKeyHashid
|
|
|
|
|
let ticketUrl = SharerTicketR shr . encodeTicketKey
|
|
|
|
|
|
|
|
|
|
case mpage of
|
|
|
|
|
Nothing -> provide $ Collection
|
|
|
|
|
{ collectionId = encodeRouteLocal here
|
|
|
|
|
, collectionType = CollectionTypeOrdered
|
|
|
|
|
, collectionTotalItems = Just total
|
|
|
|
|
, collectionCurrent = Nothing
|
|
|
|
|
, collectionFirst = Just $ pageUrl 1
|
|
|
|
|
, collectionLast = Just $ pageUrl pages
|
|
|
|
|
, collectionItems = [] :: [Text]
|
|
|
|
|
}
|
|
|
|
|
Just (tickets, navModel) ->
|
|
|
|
|
let current = nmCurrent navModel
|
|
|
|
|
in provide $ CollectionPage
|
|
|
|
|
{ collectionPageId = pageUrl current
|
|
|
|
|
, collectionPageType = CollectionPageTypeOrdered
|
|
|
|
|
, collectionPageTotalItems = Nothing
|
|
|
|
|
, collectionPageCurrent = Just $ pageUrl current
|
|
|
|
|
, collectionPageFirst = Just $ pageUrl 1
|
|
|
|
|
, collectionPageLast = Just $ pageUrl pages
|
|
|
|
|
, collectionPagePartOf = encodeRouteLocal here
|
|
|
|
|
, collectionPagePrev =
|
|
|
|
|
if current > 1
|
|
|
|
|
then Just $ pageUrl $ current - 1
|
|
|
|
|
else Nothing
|
|
|
|
|
, collectionPageNext =
|
|
|
|
|
if current < pages
|
|
|
|
|
then Just $ pageUrl $ current + 1
|
|
|
|
|
else Nothing
|
|
|
|
|
, collectionPageStartIndex = Nothing
|
|
|
|
|
, collectionPageItems =
|
|
|
|
|
map (encodeRouteHome . ticketUrl . E.unValue) tickets
|
|
|
|
|
}
|
|
|
|
|
where
|
|
|
|
|
here = SharerTicketsR shr
|
|
|
|
|
provide :: ActivityPub a => a URIMode -> Handler TypedContent
|
|
|
|
|
provide a = provideHtmlAndAP a $ redirectToPrettyJSON here
|
|
|
|
|
countTickets pid = fmap toOne $
|
|
|
|
|
E.select $ E.from $ \ (tal `E.LeftOuterJoin` tup) -> do
|
|
|
|
|
E.on $ E.just (tal E.^. TicketAuthorLocalId) E.==. tup E.?. TicketUnderProjectAuthor
|
|
|
|
|
E.where_ $
|
|
|
|
|
tal E.^. TicketAuthorLocalAuthor E.==. E.val pid E.&&.
|
|
|
|
|
E.isNothing (tup E.?. TicketUnderProjectId)
|
|
|
|
|
return $ E.count $ tal E.^. TicketAuthorLocalId
|
|
|
|
|
where
|
|
|
|
|
toOne [x] = E.unValue x
|
|
|
|
|
toOne [] = error "toOne = 0"
|
|
|
|
|
toOne _ = error "toOne > 1"
|
|
|
|
|
selectTickets pid off lim =
|
|
|
|
|
E.select $ E.from $ \ (tal `E.LeftOuterJoin` tup) -> do
|
|
|
|
|
E.on $ E.just (tal E.^. TicketAuthorLocalId) E.==. tup E.?. TicketUnderProjectAuthor
|
|
|
|
|
E.where_ $
|
|
|
|
|
tal E.^. TicketAuthorLocalAuthor E.==. E.val pid E.&&.
|
|
|
|
|
E.isNothing (tup E.?. TicketUnderProjectId)
|
|
|
|
|
E.orderBy [E.desc $ tal E.^. TicketAuthorLocalId]
|
|
|
|
|
E.offset $ fromIntegral off
|
|
|
|
|
E.limit $ fromIntegral lim
|
|
|
|
|
return $ tal E.^. TicketAuthorLocalId
|
|
|
|
|
|
|
|
|
|
getSharerTicketR
|
|
|
|
|
:: ShrIdent -> KeyHashid TicketAuthorLocal -> Handler TypedContent
|
2020-02-10 14:10:01 +00:00
|
|
|
|
getSharerTicketR shr talkhid = do
|
|
|
|
|
(ticket, project, massignee) <- runDB $ do
|
|
|
|
|
(_, _, Entity _ t, tp) <- getSharerTicket shr talkhid
|
|
|
|
|
(,,) t
|
|
|
|
|
<$> bitraverse
|
|
|
|
|
(\ (Entity _ tpl) -> do
|
|
|
|
|
j <- getJust $ ticketProjectLocalProject tpl
|
|
|
|
|
s <- getJust $ projectSharer j
|
|
|
|
|
return (s, j)
|
|
|
|
|
)
|
|
|
|
|
return
|
|
|
|
|
tp
|
|
|
|
|
<*> (for (ticketAssignee t) $ \ pidAssignee -> do
|
|
|
|
|
p <- getJust pidAssignee
|
|
|
|
|
getJust $ personIdent p
|
|
|
|
|
)
|
|
|
|
|
hLocal <- getsYesod siteInstanceHost
|
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
|
encodeRouteHome <- getEncodeRouteHome
|
|
|
|
|
let ticketAP = AP.Ticket
|
|
|
|
|
{ AP.ticketLocal = Just
|
|
|
|
|
( hLocal
|
|
|
|
|
, AP.TicketLocal
|
|
|
|
|
{ AP.ticketId =
|
|
|
|
|
encodeRouteLocal $ SharerTicketR shr talkhid
|
|
|
|
|
, AP.ticketContext =
|
|
|
|
|
encodeRouteLocal $
|
|
|
|
|
case project of
|
|
|
|
|
Left (s, j) ->
|
|
|
|
|
ProjectR (sharerIdent s) (projectIdent j)
|
|
|
|
|
Right () -> error "No TPR yet!"
|
|
|
|
|
, AP.ticketReplies =
|
|
|
|
|
encodeRouteLocal $ SharerTicketDiscussionR shr talkhid
|
|
|
|
|
, AP.ticketParticipants =
|
|
|
|
|
encodeRouteLocal $ SharerTicketFollowersR shr talkhid
|
|
|
|
|
, AP.ticketTeam =
|
|
|
|
|
encodeRouteLocal $ SharerTicketTeamR shr talkhid
|
|
|
|
|
, AP.ticketEvents =
|
|
|
|
|
encodeRouteLocal $ SharerTicketEventsR shr talkhid
|
|
|
|
|
, AP.ticketDeps =
|
|
|
|
|
encodeRouteLocal $ SharerTicketDepsR shr talkhid
|
|
|
|
|
, AP.ticketReverseDeps =
|
|
|
|
|
encodeRouteLocal $ SharerTicketReverseDepsR shr talkhid
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
, AP.ticketAttributedTo = encodeRouteLocal $ SharerR shr
|
|
|
|
|
, AP.ticketPublished = Just $ ticketCreated ticket
|
|
|
|
|
, AP.ticketUpdated = Nothing
|
|
|
|
|
, AP.ticketSummary = TextHtml $ ticketTitle ticket
|
|
|
|
|
, AP.ticketContent = TextHtml $ ticketDescription ticket
|
|
|
|
|
, AP.ticketSource = TextPandocMarkdown $ ticketSource ticket
|
|
|
|
|
, AP.ticketAssignedTo =
|
|
|
|
|
encodeRouteHome . SharerR . sharerIdent <$> massignee
|
|
|
|
|
, AP.ticketIsResolved = ticketStatus ticket == TSClosed
|
|
|
|
|
}
|
|
|
|
|
provideHtmlAndAP ticketAP $ redirectToPrettyJSON here
|
|
|
|
|
where
|
|
|
|
|
here = SharerTicketR shr talkhid
|
|
|
|
|
|
|
|
|
|
getSharerTicketDiscussionR
|
|
|
|
|
:: ShrIdent -> KeyHashid TicketAuthorLocal -> Handler TypedContent
|
|
|
|
|
getSharerTicketDiscussionR shr talkhid = do
|
|
|
|
|
(locals, remotes) <- runDB $ do
|
|
|
|
|
(_, Entity _ lt, _, _) <- getSharerTicket shr talkhid
|
|
|
|
|
let did = localTicketDiscuss lt
|
|
|
|
|
(,) <$> selectLocals did <*> selectRemotes did
|
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
|
encodeRouteHome <- getEncodeRouteHome
|
|
|
|
|
encodeHid <- getEncodeKeyHashid
|
|
|
|
|
let localUri' = localUri encodeRouteHome encodeHid
|
|
|
|
|
replies = Collection
|
|
|
|
|
{ collectionId = encodeRouteLocal here
|
|
|
|
|
, collectionType = CollectionTypeUnordered
|
|
|
|
|
, collectionTotalItems = Just $ length locals + length remotes
|
|
|
|
|
, collectionCurrent = Nothing
|
|
|
|
|
, collectionFirst = Nothing
|
|
|
|
|
, collectionLast = Nothing
|
|
|
|
|
, collectionItems =
|
|
|
|
|
map localUri' locals ++ map remoteUri remotes
|
|
|
|
|
}
|
|
|
|
|
provideHtmlAndAP replies $ redirectToPrettyJSON here
|
|
|
|
|
where
|
|
|
|
|
here = SharerTicketDiscussionR shr talkhid
|
|
|
|
|
selectLocals did =
|
|
|
|
|
E.select $ E.from $
|
|
|
|
|
\ (m `E.InnerJoin` lm `E.InnerJoin` p `E.InnerJoin` s) -> do
|
|
|
|
|
E.on $ p E.^. PersonIdent E.==. s E.^. SharerId
|
|
|
|
|
E.on $ lm E.^. LocalMessageAuthor E.==. p E.^. PersonId
|
|
|
|
|
E.on $ m E.^. MessageId E.==. lm E.^. LocalMessageRest
|
|
|
|
|
E.where_ $
|
|
|
|
|
m E.^. MessageRoot E.==. E.val did E.&&.
|
|
|
|
|
E.isNothing (m E.^. MessageParent) E.&&.
|
|
|
|
|
E.isNothing (lm E.^. LocalMessageUnlinkedParent)
|
|
|
|
|
return (s E.^. SharerIdent, lm E.^. LocalMessageId)
|
|
|
|
|
selectRemotes did =
|
|
|
|
|
E.select $ E.from $
|
|
|
|
|
\ (m `E.InnerJoin` rm `E.InnerJoin` ro `E.InnerJoin` i) -> do
|
|
|
|
|
E.on $ ro E.^. RemoteObjectInstance E.==. i E.^. InstanceId
|
|
|
|
|
E.on $ rm E.^. RemoteMessageIdent E.==. ro E.^. RemoteObjectId
|
|
|
|
|
E.on $ m E.^. MessageId E.==. rm E.^. RemoteMessageRest
|
|
|
|
|
E.where_ $
|
|
|
|
|
m E.^. MessageRoot E.==. E.val did E.&&.
|
|
|
|
|
E.isNothing (m E.^. MessageParent) E.&&.
|
|
|
|
|
E.isNothing (rm E.^. RemoteMessageLostParent)
|
|
|
|
|
return (i E.^. InstanceHost, ro E.^. RemoteObjectIdent)
|
|
|
|
|
localUri encR encH (E.Value shrAuthor, E.Value lmid) =
|
|
|
|
|
encR $ MessageR shrAuthor (encH lmid)
|
|
|
|
|
remoteUri (E.Value h, E.Value lu) = ObjURI h lu
|
|
|
|
|
|
|
|
|
|
getSharerTicketDeps
|
|
|
|
|
:: Bool -> ShrIdent -> KeyHashid TicketAuthorLocal -> Handler TypedContent
|
|
|
|
|
getSharerTicketDeps forward shr talkhid = do
|
|
|
|
|
tdids <- runDB $ do
|
|
|
|
|
(_, _, Entity tid _, _) <- getSharerTicket shr talkhid
|
|
|
|
|
let (from, to) =
|
|
|
|
|
if forward
|
|
|
|
|
then (TicketDependencyParent, TicketDependencyChild)
|
|
|
|
|
else (TicketDependencyChild, TicketDependencyParent)
|
|
|
|
|
E.select $ E.from $ \ (td `E.InnerJoin` t) -> do
|
|
|
|
|
E.on $ td E.^. to E.==. t E.^. TicketId
|
|
|
|
|
E.where_ $ td E.^. from E.==. E.val tid
|
|
|
|
|
return $ td E.^. TicketDependencyId
|
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
|
encodeRouteHome <- getEncodeRouteHome
|
|
|
|
|
encodeHid <- getEncodeKeyHashid
|
|
|
|
|
let deps = Collection
|
|
|
|
|
{ collectionId = encodeRouteLocal here
|
|
|
|
|
, collectionType = CollectionTypeUnordered
|
|
|
|
|
, collectionTotalItems = Just $ length tdids
|
|
|
|
|
, collectionCurrent = Nothing
|
|
|
|
|
, collectionFirst = Nothing
|
|
|
|
|
, collectionLast = Nothing
|
|
|
|
|
, collectionItems =
|
|
|
|
|
map (encodeRouteHome . TicketDepR . encodeHid . E.unValue)
|
|
|
|
|
tdids
|
|
|
|
|
}
|
|
|
|
|
provideHtmlAndAP deps $ redirectToPrettyJSON here
|
|
|
|
|
where
|
|
|
|
|
here =
|
|
|
|
|
let route =
|
|
|
|
|
if forward then SharerTicketDepsR else SharerTicketReverseDepsR
|
|
|
|
|
in route shr talkhid
|
|
|
|
|
|
|
|
|
|
getSharerTicketDepsR
|
|
|
|
|
:: ShrIdent -> KeyHashid TicketAuthorLocal -> Handler TypedContent
|
|
|
|
|
getSharerTicketDepsR = getSharerTicketDeps True
|
|
|
|
|
|
|
|
|
|
getSharerTicketReverseDepsR
|
|
|
|
|
:: ShrIdent -> KeyHashid TicketAuthorLocal -> Handler TypedContent
|
|
|
|
|
getSharerTicketReverseDepsR = getSharerTicketDeps False
|
|
|
|
|
|
|
|
|
|
getSharerTicketFollowersR
|
|
|
|
|
:: ShrIdent -> KeyHashid TicketAuthorLocal -> Handler TypedContent
|
|
|
|
|
getSharerTicketFollowersR shr talkhid = getFollowersCollection here getFsid
|
|
|
|
|
where
|
|
|
|
|
here = SharerTicketFollowersR shr talkhid
|
|
|
|
|
getFsid = do
|
|
|
|
|
(_, Entity _ lt, _, _) <- getSharerTicket shr talkhid
|
|
|
|
|
return $ localTicketFollowers lt
|
|
|
|
|
|
|
|
|
|
getSharerTicketTeamR
|
|
|
|
|
:: ShrIdent -> KeyHashid TicketAuthorLocal -> Handler TypedContent
|
|
|
|
|
getSharerTicketTeamR shr talkhid = do
|
|
|
|
|
_ <- runDB $ getSharerTicket shr talkhid
|
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
|
let team = Collection
|
|
|
|
|
{ collectionId = encodeRouteLocal here
|
|
|
|
|
, collectionType = CollectionTypeUnordered
|
|
|
|
|
, collectionTotalItems = Just 0
|
|
|
|
|
, collectionCurrent = Nothing
|
|
|
|
|
, collectionFirst = Nothing
|
|
|
|
|
, collectionLast = Nothing
|
|
|
|
|
, collectionItems = [] :: [Text]
|
|
|
|
|
}
|
|
|
|
|
provideHtmlAndAP team $ redirectToPrettyJSON here
|
|
|
|
|
where
|
|
|
|
|
here = SharerTicketTeamR shr talkhid
|
|
|
|
|
|
|
|
|
|
getSharerTicketEventsR
|
|
|
|
|
:: ShrIdent -> KeyHashid TicketAuthorLocal -> Handler TypedContent
|
|
|
|
|
getSharerTicketEventsR shr talkhid = do
|
|
|
|
|
_ <- runDB $ getSharerTicket shr talkhid
|
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
|
let team = Collection
|
|
|
|
|
{ collectionId = encodeRouteLocal here
|
|
|
|
|
, collectionType = CollectionTypeOrdered
|
|
|
|
|
, collectionTotalItems = Just 0
|
|
|
|
|
, collectionCurrent = Nothing
|
|
|
|
|
, collectionFirst = Nothing
|
|
|
|
|
, collectionLast = Nothing
|
|
|
|
|
, collectionItems = [] :: [Text]
|
|
|
|
|
}
|
|
|
|
|
provideHtmlAndAP team $ redirectToPrettyJSON here
|
|
|
|
|
where
|
|
|
|
|
here = SharerTicketEventsR shr talkhid
|