mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-27 15:24:51 +09:00
Switch Audience from Vector to list and fix Public bug
* No good reason to use Vector, let's use list, it's just easier * The Public URI recognizing code wasn't being used; now it is
This commit is contained in:
parent
0c280c7af6
commit
1d854423cb
2 changed files with 20 additions and 20 deletions
|
@ -79,12 +79,12 @@ parseAudience :: Monad m => Audience -> Text -> ExceptT Text m FedURI
|
|||
parseAudience (Audience to bto cc bcc aud) t =
|
||||
case toSingleton to of
|
||||
Just fu
|
||||
| V.null bto && V.null cc && V.null bcc && V.null aud ->
|
||||
| null bto && null cc && null bcc && null aud ->
|
||||
return fu
|
||||
_ -> throwE t
|
||||
where
|
||||
toSingleton v =
|
||||
case V.toList v of
|
||||
case v of
|
||||
[x] -> Just x
|
||||
_ -> Nothing
|
||||
|
||||
|
|
|
@ -318,20 +318,20 @@ instance ActivityPub Actor where
|
|||
<> "publicKey" `pair` encodePublicKeySet host pkeys
|
||||
|
||||
data Audience = Audience
|
||||
{ audienceTo :: Vector FedURI
|
||||
, audienceBto :: Vector FedURI
|
||||
, audienceCc :: Vector FedURI
|
||||
, audienceBcc :: Vector FedURI
|
||||
, audienceGeneral :: Vector FedURI
|
||||
{ audienceTo :: [FedURI]
|
||||
, audienceBto :: [FedURI]
|
||||
, audienceCc :: [FedURI]
|
||||
, audienceBcc :: [FedURI]
|
||||
, audienceGeneral :: [FedURI]
|
||||
}
|
||||
|
||||
deliverTo :: FedURI -> Audience
|
||||
deliverTo to = Audience
|
||||
{ audienceTo = V.singleton to
|
||||
, audienceBto = V.empty
|
||||
, audienceCc = V.empty
|
||||
, audienceBcc = V.empty
|
||||
, audienceGeneral = V.empty
|
||||
{ audienceTo = [to]
|
||||
, audienceBto = []
|
||||
, audienceCc = []
|
||||
, audienceBcc = []
|
||||
, audienceGeneral = []
|
||||
}
|
||||
|
||||
newtype AdaptAudience = AdaptAudience
|
||||
|
@ -351,15 +351,15 @@ instance FromJSON AdaptAudience where
|
|||
parseAudience :: Object -> Parser Audience
|
||||
parseAudience o =
|
||||
Audience
|
||||
<$> o .:? "to" .!= V.empty
|
||||
<*> o .:? "bto" .!= V.empty
|
||||
<*> o .:? "cc" .!= V.empty
|
||||
<*> o .:? "bcc" .!= V.empty
|
||||
<*> o .:? "audience" .!= V.empty
|
||||
<$> o .:& "to"
|
||||
<*> o .:& "bto"
|
||||
<*> o .:& "cc"
|
||||
<*> o .:& "bcc"
|
||||
<*> o .:& "audience"
|
||||
where
|
||||
obj .:& key = do
|
||||
vec <- obj .:? key .!= V.empty
|
||||
return $ unAdapt <$> vec
|
||||
l <- obj .:? key .!= []
|
||||
return $ map unAdapt l
|
||||
|
||||
encodeAudience :: Audience -> Series
|
||||
encodeAudience (Audience to bto cc bcc aud)
|
||||
|
@ -370,7 +370,7 @@ encodeAudience (Audience to bto cc bcc aud)
|
|||
<> "audience" .=% aud
|
||||
where
|
||||
t .=% v =
|
||||
if V.null v
|
||||
if null v
|
||||
then mempty
|
||||
else t .= v
|
||||
|
||||
|
|
Loading…
Reference in a new issue