Allow actors not to list any public keys at all
This commit is contained in:
parent
716487f2b8
commit
6f3df6d569
2 changed files with 15 additions and 14 deletions
|
@ -145,6 +145,7 @@ getPerson shr person = do
|
||||||
, actorUsername = shr2text shr
|
, actorUsername = shr2text shr
|
||||||
, actorInbox = route2local InboxR
|
, actorInbox = route2local InboxR
|
||||||
, actorPublicKeys =
|
, actorPublicKeys =
|
||||||
Left (route2local ActorKey1R) :|
|
[ Left $ route2local ActorKey1R
|
||||||
[ Left $ route2local ActorKey2R ]
|
, Left $ route2local ActorKey2R
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,17 +238,17 @@ instance ActivityPub PublicKey where
|
||||||
mkOwner h OwnerInstance = FedURI h "" ""
|
mkOwner h OwnerInstance = FedURI h "" ""
|
||||||
mkOwner h (OwnerActor lu) = l2f h lu
|
mkOwner h (OwnerActor lu) = l2f h lu
|
||||||
|
|
||||||
parsePublicKeySet :: Value -> Parser (Text, NonEmpty (Either LocalURI PublicKey))
|
parsePublicKeySet :: Value -> Parser (Text, [Either LocalURI PublicKey])
|
||||||
parsePublicKeySet v =
|
parsePublicKeySet v =
|
||||||
case v of
|
case v of
|
||||||
Array a ->
|
Array a ->
|
||||||
case nonEmpty $ V.toList a of
|
case V.toList a of
|
||||||
Nothing -> fail "No public keys"
|
[] -> fail "No public keys"
|
||||||
Just (k :| ks) -> do
|
k : ks -> do
|
||||||
(h, e) <- parseKey k
|
(h, e) <- parseKey k
|
||||||
es <- traverse (withHost h . parseKey) ks
|
es <- traverse (withHost h . parseKey) ks
|
||||||
return (h, e :| es)
|
return (h, e : es)
|
||||||
_ -> second (:| []) <$> parseKey v
|
_ -> second (: []) <$> parseKey v
|
||||||
where
|
where
|
||||||
parseKey (String t) = second Left . f2l <$> either fail return (parseFedURI t)
|
parseKey (String t) = second Left . f2l <$> either fail return (parseFedURI t)
|
||||||
parseKey (Object o) = second Right <$> parseObject o
|
parseKey (Object o) = second Right <$> parseObject o
|
||||||
|
@ -259,11 +259,11 @@ parsePublicKeySet v =
|
||||||
then return v
|
then return v
|
||||||
else fail "URI host mismatch"
|
else fail "URI host mismatch"
|
||||||
|
|
||||||
encodePublicKeySet :: Text -> NonEmpty (Either LocalURI PublicKey) -> Encoding
|
encodePublicKeySet :: Text -> [Either LocalURI PublicKey] -> Encoding
|
||||||
encodePublicKeySet host (e :| es) =
|
encodePublicKeySet host es =
|
||||||
if null es
|
case es of
|
||||||
then renderKey e
|
[e] -> renderKey e
|
||||||
else listEncoding renderKey $ e : es
|
_ -> listEncoding renderKey es
|
||||||
where
|
where
|
||||||
renderKey (Left lu) = toEncoding $ l2f host lu
|
renderKey (Left lu) = toEncoding $ l2f host lu
|
||||||
renderKey (Right pk) = pairs $ toSeries host pk
|
renderKey (Right pk) = pairs $ toSeries host pk
|
||||||
|
@ -273,7 +273,7 @@ data Actor = Actor
|
||||||
, actorType :: ActorType
|
, actorType :: ActorType
|
||||||
, actorUsername :: Text
|
, actorUsername :: Text
|
||||||
, actorInbox :: LocalURI
|
, actorInbox :: LocalURI
|
||||||
, actorPublicKeys :: NonEmpty (Either LocalURI PublicKey)
|
, actorPublicKeys :: [Either LocalURI PublicKey]
|
||||||
}
|
}
|
||||||
|
|
||||||
instance ActivityPub Actor where
|
instance ActivityPub Actor where
|
||||||
|
|
Loading…
Reference in a new issue