Turn some AP ticket fields into Maybes

This commit is contained in:
fr33domlover 2019-06-04 09:36:14 +00:00
parent 04a2e9a817
commit e31c8c600b
2 changed files with 16 additions and 16 deletions

View file

@ -301,18 +301,18 @@ getTicketR shar proj num = do
, AP.ticketContent = TextHtml $ ticketDescription ticket , AP.ticketContent = TextHtml $ ticketDescription ticket
, AP.ticketSource = TextPandocMarkdown $ ticketSource ticket , AP.ticketSource = TextPandocMarkdown $ ticketSource ticket
, AP.ticketReplies = , AP.ticketReplies =
encodeRouteLocal $ TicketDiscussionR shar proj num Just $ encodeRouteLocal $ TicketDiscussionR shar proj num
, AP.ticketAssignedTo = , AP.ticketAssignedTo =
encodeRouteHome . SharerR . sharerIdent . fst <$> massignee encodeRouteHome . SharerR . sharerIdent . fst <$> massignee
, AP.ticketIsResolved = ticketStatus ticket == TSClosed , AP.ticketIsResolved = ticketStatus ticket == TSClosed
, AP.ticketParticipants = , AP.ticketParticipants =
encodeRouteLocal $ TicketParticipantsR shar proj num Just $ encodeRouteLocal $ TicketParticipantsR shar proj num
, AP.ticketTeam = , AP.ticketTeam =
encodeRouteLocal $ TicketTeamR shar proj num Just $ encodeRouteLocal $ TicketTeamR shar proj num
, AP.ticketDependsOn = map siblingUri deps , AP.ticketDependsOn = map siblingUri deps
, AP.ticketDependedBy = map siblingUri rdeps , AP.ticketDependedBy = map siblingUri rdeps
, AP.ticketEvents = , AP.ticketEvents =
encodeRouteLocal $ TicketEventsR shar proj num Just $ encodeRouteLocal $ TicketEventsR shar proj num
} }
provideHtmlAndAP ticketAP $(widgetFile "ticket/one") provideHtmlAndAP ticketAP $(widgetFile "ticket/one")

View file

@ -625,14 +625,14 @@ data Ticket = Ticket
, ticketSummary :: TextHtml , ticketSummary :: TextHtml
, ticketContent :: TextHtml , ticketContent :: TextHtml
, ticketSource :: TextPandocMarkdown , ticketSource :: TextPandocMarkdown
, ticketReplies :: LocalURI , ticketReplies :: Maybe LocalURI
, ticketAssignedTo :: Maybe FedURI , ticketAssignedTo :: Maybe FedURI
, ticketIsResolved :: Bool , ticketIsResolved :: Bool
, ticketParticipants :: LocalURI , ticketParticipants :: Maybe LocalURI
, ticketTeam :: LocalURI , ticketTeam :: Maybe LocalURI
, ticketDependsOn :: [FedURI] , ticketDependsOn :: [FedURI]
, ticketDependedBy :: [FedURI] , ticketDependedBy :: [FedURI]
, ticketEvents :: LocalURI , ticketEvents :: Maybe LocalURI
} }
instance ActivityPub Ticket where instance ActivityPub Ticket where
@ -664,14 +664,14 @@ instance ActivityPub Ticket where
<*> (TextHtml . sanitizeBalance <$> o .: "summary") <*> (TextHtml . sanitizeBalance <$> o .: "summary")
<*> (TextHtml . sanitizeBalance <$> o .: "content") <*> (TextHtml . sanitizeBalance <$> o .: "content")
<*> source .: "content" <*> source .: "content"
<*> withHost h (f2l <$> o .: "replies") <*> withHostMaybe h (fmap f2l <$> o .:? "replies")
<*> o .:? (frg <> "assignedTo") <*> o .:? (frg <> "assignedTo")
<*> o .: (frg <> "isResolved") <*> o .: (frg <> "isResolved")
<*> withHost h (f2l <$> o .: (frg <> "participants")) <*> withHostMaybe h (fmap f2l <$> o .:? (frg <> "participants"))
<*> withHost h (f2l <$> o .: (frg <> "team")) <*> withHostMaybe h (fmap f2l <$> o .:? (frg <> "team"))
<*> o .:? (frg <> "dependsOn") .!= [] <*> o .:? (frg <> "dependsOn") .!= []
<*> o .:? (frg <> "dependedBy") .!= [] <*> o .:? (frg <> "dependedBy") .!= []
<*> withHost h (f2l <$> o .: (frg <> "events")) <*> withHostMaybe h (fmap f2l <$> o .:? (frg <> "events"))
toSeries host toSeries host
(Ticket id_ attributedTo published updated context name summary content (Ticket id_ attributedTo published updated context name summary content
@ -691,14 +691,14 @@ instance ActivityPub Ticket where
[ "content" .= source [ "content" .= source
, "mediaType" .= ("text/markdown; variant=Pandoc" :: Text) , "mediaType" .= ("text/markdown; variant=Pandoc" :: Text)
] ]
<> "replies" .= l2f host replies <> "replies" .=? (l2f host <$> replies)
<> (frg <> "assignedTo") .=? assignedTo <> (frg <> "assignedTo") .=? assignedTo
<> (frg <> "isResolved") .= isResolved <> (frg <> "isResolved") .= isResolved
<> (frg <> "participants") .= l2f host participants <> (frg <> "participants") .=? (l2f host <$> participants)
<> (frg <> "team") .= l2f host team <> (frg <> "team") .=? (l2f host <$> team)
<> (frg <> "dependsOn") .=% dependsOn <> (frg <> "dependsOn") .=% dependsOn
<> (frg <> "dependedBy") .=% dependedBy <> (frg <> "dependedBy") .=% dependedBy
<> (frg <> "events") .= l2f host events <> (frg <> "events") .=? (l2f host <$> events)
data Accept = Accept data Accept = Accept
{ acceptObject :: FedURI { acceptObject :: FedURI