mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-29 01:34:52 +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:
parent
257a811a8b
commit
adc107bb4c
4 changed files with 9 additions and 5 deletions
|
@ -362,6 +362,7 @@ createNoteC host (Note mluNote luAttrib aud muParent muContext mpublished source
|
||||||
, noteSource = source
|
, noteSource = source
|
||||||
, noteContent = content
|
, noteContent = content
|
||||||
}
|
}
|
||||||
|
, createTarget = Nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tempUri = topLocalURI
|
tempUri = topLocalURI
|
||||||
|
|
|
@ -266,7 +266,7 @@ handleSharerInbox now shrRecip (ActivityAuthRemote author) body =
|
||||||
case activitySpecific $ actbActivity body of
|
case activitySpecific $ actbActivity body of
|
||||||
AcceptActivity accept ->
|
AcceptActivity accept ->
|
||||||
sharerAcceptF shrRecip now author body accept
|
sharerAcceptF shrRecip now author body accept
|
||||||
CreateActivity (Create obj) ->
|
CreateActivity (Create obj _target) ->
|
||||||
case obj of
|
case obj of
|
||||||
CreateNote note ->
|
CreateNote note ->
|
||||||
sharerCreateNoteF now shrRecip author body note
|
sharerCreateNoteF now shrRecip author body note
|
||||||
|
@ -296,7 +296,7 @@ handleProjectInbox now shrRecip prjRecip auth body = do
|
||||||
ActivityAuthLocal local -> throwE $ errorLocalForwarded local
|
ActivityAuthLocal local -> throwE $ errorLocalForwarded local
|
||||||
ActivityAuthRemote ra -> return ra
|
ActivityAuthRemote ra -> return ra
|
||||||
case activitySpecific $ actbActivity body of
|
case activitySpecific $ actbActivity body of
|
||||||
CreateActivity (Create obj) ->
|
CreateActivity (Create obj _target) ->
|
||||||
case obj of
|
case obj of
|
||||||
CreateNote note ->
|
CreateNote note ->
|
||||||
projectCreateNoteF now shrRecip prjRecip remoteAuthor body note
|
projectCreateNoteF now shrRecip prjRecip remoteAuthor body note
|
||||||
|
|
|
@ -477,6 +477,7 @@ changes hLocal ctx =
|
||||||
, noteSource = msg
|
, noteSource = msg
|
||||||
, noteContent = contentHtml
|
, noteContent = contentHtml
|
||||||
}
|
}
|
||||||
|
, createTarget = Nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tempUri = topLocalURI
|
tempUri = topLocalURI
|
||||||
|
|
|
@ -1086,20 +1086,22 @@ instance ActivityPub CreateObject where
|
||||||
|
|
||||||
data Create u = Create
|
data Create u = Create
|
||||||
{ createObject :: CreateObject u
|
{ createObject :: CreateObject u
|
||||||
|
, createTarget :: Maybe (ObjURI u)
|
||||||
}
|
}
|
||||||
|
|
||||||
parseCreate :: UriMode u => Object -> Authority u -> LocalURI -> Parser (Create u)
|
parseCreate :: UriMode u => Object -> Authority u -> LocalURI -> Parser (Create u)
|
||||||
parseCreate o a luActor = do
|
parseCreate o a luActor = do
|
||||||
obj <- withAuthorityT a $ parseObject =<< o .: "object"
|
obj <- withAuthorityT a $ parseObject =<< o .: "object"
|
||||||
unless (luActor == attrib obj) $ fail "Create actor != object attrib"
|
unless (luActor == attrib obj) $ fail "Create actor != object attrib"
|
||||||
return $ Create obj
|
Create obj <$> o .:? "target"
|
||||||
where
|
where
|
||||||
attrib (CreateNote note) = noteAttrib note
|
attrib (CreateNote note) = noteAttrib note
|
||||||
attrib (CreateTicket ticket) = ticketAttributedTo ticket
|
attrib (CreateTicket ticket) = ticketAttributedTo ticket
|
||||||
|
|
||||||
encodeCreate :: UriMode u => Authority u -> LocalURI -> Create u -> Series
|
encodeCreate :: UriMode u => Authority u -> LocalURI -> Create u -> Series
|
||||||
encodeCreate authority actor (Create obj) =
|
encodeCreate authority actor (Create obj target)
|
||||||
"object" `pair` pairs (toSeries authority obj)
|
= "object" `pair` pairs (toSeries authority obj)
|
||||||
|
<> "target" .=? target
|
||||||
|
|
||||||
data Follow u = Follow
|
data Follow u = Follow
|
||||||
{ followObject :: ObjURI u
|
{ followObject :: ObjURI u
|
||||||
|
|
Loading…
Reference in a new issue