1
0
Fork 0
mirror of https://code.naskya.net/repos/ndqEd synced 2025-03-20 15:14:54 +09:00

Web.ActivityPub: Add Grant startTime and endTime

This commit is contained in:
Pere Lev 2023-05-29 10:47:41 +03:00
parent a22aeb85d0
commit ba02d62eb5
No known key found for this signature in database
GPG key ID: 5252C5C863E5E57D
5 changed files with 29 additions and 6 deletions

View file

@ -1675,6 +1675,8 @@ data Grant u = Grant
, grantContext :: LocalURI
, grantTarget :: ObjURI u
, grantResult :: Maybe (LocalURI, Maybe Duration)
, grantStart :: Maybe UTCTime
, grantEnd :: Maybe UTCTime
}
parseGrant :: UriMode u => Authority u -> Object -> Parser (Grant u)
@ -1683,24 +1685,30 @@ parseGrant h o =
<$> o .:+ "object"
<*> withAuthorityO h (o .: "context")
<*> o .: "target"
<*> do mres <- o .:+? "result"
<*> (do mres <- o .:+? "result"
for mres $ \case
Left u -> (,Nothing) <$> withAuthorityO h (pure u)
Right r ->
(,) <$> withAuthorityO h (r .: "id") <*> r .:? "duration"
)
<*> o .:? "startTime"
<*> o .:? "endTime"
encodeGrant :: UriMode u => Authority u -> Grant u -> Series
encodeGrant h (Grant obj context target mresult)
encodeGrant h (Grant obj context target mresult mstart mend)
= "object" .=+ obj
<> "context" .= ObjURI h context
<> "target" .= target
<> case mresult of
<> (case mresult of
Nothing -> mempty
Just (result, mduration) ->
"result" `pair` pairs
( "id" .= ObjURI h result
<> "duration" .=? mduration
)
)
<> "startTime" .=? mstart
<> "endTime" .=? mend
data Invite u = Invite
{ inviteInstrument :: Either Role (ObjURI u)