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.ticketSource = TextPandocMarkdown $ ticketSource ticket
, AP.ticketReplies =
encodeRouteLocal $ TicketDiscussionR shar proj num
Just $ encodeRouteLocal $ TicketDiscussionR shar proj num
, AP.ticketAssignedTo =
encodeRouteHome . SharerR . sharerIdent . fst <$> massignee
, AP.ticketIsResolved = ticketStatus ticket == TSClosed
, AP.ticketParticipants =
encodeRouteLocal $ TicketParticipantsR shar proj num
Just $ encodeRouteLocal $ TicketParticipantsR shar proj num
, AP.ticketTeam =
encodeRouteLocal $ TicketTeamR shar proj num
Just $ encodeRouteLocal $ TicketTeamR shar proj num
, AP.ticketDependsOn = map siblingUri deps
, AP.ticketDependedBy = map siblingUri rdeps
, AP.ticketEvents =
encodeRouteLocal $ TicketEventsR shar proj num
Just $ encodeRouteLocal $ TicketEventsR shar proj num
}
provideHtmlAndAP ticketAP $(widgetFile "ticket/one")

View file

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