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:
parent
a22aeb85d0
commit
ba02d62eb5
5 changed files with 29 additions and 6 deletions
src/Web
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue