1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-28 09:44:51 +09:00

Web.ActivityPub: Add createTarget field

I'll use this for C2S to allow client to state who the tracker actor is. It's
still possible to do without it, by HTTP GETing the ticket's context and
checking whether we got an actor, or a non-actor with ticketsTrackedBy. Tbh I'm
adding createTarget simply because it's easier for coding, no need for a custom
variant of actor fetching :P
This commit is contained in:
fr33domlover 2020-02-18 13:26:28 +00:00
parent 257a811a8b
commit adc107bb4c
4 changed files with 9 additions and 5 deletions

View file

@ -362,6 +362,7 @@ createNoteC host (Note mluNote luAttrib aud muParent muContext mpublished source
, noteSource = source
, noteContent = content
}
, createTarget = Nothing
}
}
tempUri = topLocalURI

View file

@ -266,7 +266,7 @@ handleSharerInbox now shrRecip (ActivityAuthRemote author) body =
case activitySpecific $ actbActivity body of
AcceptActivity accept ->
sharerAcceptF shrRecip now author body accept
CreateActivity (Create obj) ->
CreateActivity (Create obj _target) ->
case obj of
CreateNote note ->
sharerCreateNoteF now shrRecip author body note
@ -296,7 +296,7 @@ handleProjectInbox now shrRecip prjRecip auth body = do
ActivityAuthLocal local -> throwE $ errorLocalForwarded local
ActivityAuthRemote ra -> return ra
case activitySpecific $ actbActivity body of
CreateActivity (Create obj) ->
CreateActivity (Create obj _target) ->
case obj of
CreateNote note ->
projectCreateNoteF now shrRecip prjRecip remoteAuthor body note

View file

@ -477,6 +477,7 @@ changes hLocal ctx =
, noteSource = msg
, noteContent = contentHtml
}
, createTarget = Nothing
}
}
tempUri = topLocalURI

View file

@ -1086,20 +1086,22 @@ instance ActivityPub CreateObject where
data Create u = Create
{ createObject :: CreateObject u
, createTarget :: Maybe (ObjURI u)
}
parseCreate :: UriMode u => Object -> Authority u -> LocalURI -> Parser (Create u)
parseCreate o a luActor = do
obj <- withAuthorityT a $ parseObject =<< o .: "object"
unless (luActor == attrib obj) $ fail "Create actor != object attrib"
return $ Create obj
Create obj <$> o .:? "target"
where
attrib (CreateNote note) = noteAttrib note
attrib (CreateTicket ticket) = ticketAttributedTo ticket
encodeCreate :: UriMode u => Authority u -> LocalURI -> Create u -> Series
encodeCreate authority actor (Create obj) =
"object" `pair` pairs (toSeries authority obj)
encodeCreate authority actor (Create obj target)
= "object" `pair` pairs (toSeries authority obj)
<> "target" .=? target
data Follow u = Follow
{ followObject :: ObjURI u