aboutsummaryrefslogtreecommitdiff
path: root/src/Ssb/Feed.hs
diff options
context:
space:
mode:
authorCypher <cypher@server.ky>2022-05-03 15:05:40 -0500
committerCypher <cypher@server.ky>2022-05-03 15:05:40 -0500
commit1a10c09d6150dbc9e8a1718b710252cb7b38b776 (patch)
tree34139f56373ad9e93d267543166c0c3da0f434d0 /src/Ssb/Feed.hs
parent0732fbc8925efb9753b543d721ea845b9b4f338f (diff)
downloadssb-haskell-1a10c09d6150dbc9e8a1718b710252cb7b38b776.tar.xz
use stack lts-18.8
Update text handling to keep uptodate with changes with string conversion, using 'encodeUtf' and 'decodeUtf' where necessary. One update uses an odd encoding to and from JSON, which must be looked at later.
Diffstat (limited to 'src/Ssb/Feed.hs')
-rw-r--r--src/Ssb/Feed.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Ssb/Feed.hs b/src/Ssb/Feed.hs
index f4e96c2..ebdd2f4 100644
--- a/src/Ssb/Feed.hs
+++ b/src/Ssb/Feed.hs
@@ -72,7 +72,7 @@ extractMessageID (MessageID buf) = buf
-- Format of '%[base64 messageId].sha256', the '.sha256' is appended for
-- forward compatibility, and is currently assumed.
formatMessageID :: MessageID -> Text
-formatMessageID (MessageID buf) = "%" <> toS (Base64.encode buf) <> ".sha256"
+formatMessageID (MessageID buf) = "%" <> decodeUtf8 (Base64.encode buf) <> ".sha256"
-- | TODO: make safe
parseMessageID :: Text -> Either Text MessageID
@@ -80,7 +80,7 @@ parseMessageID arg = decode $ T.dropEnd constLen $ T.drop 1 arg
where
constLen = T.length ".sha256"
decode :: Text -> Either Text MessageID
- decode = mapRight MessageID . mapLeft toS . Base64.decode . toS
+ decode = mapRight MessageID . mapLeft toS . Base64.decode . encodeUtf8
instance FromJSON MessageID where
parseJSON = Aeson.withText "MessageID" $ \v -> case parseMessageID v of
@@ -115,14 +115,14 @@ extractSignature :: Signature -> ByteString
extractSignature (Signature buf) = buf
formatSignature :: Signature -> Text
-formatSignature (Signature buf) = toS (Base64.encode buf) <> ".sig.ed25519"
+formatSignature (Signature buf) = decodeUtf8 (Base64.encode buf) <> ".sig.ed25519"
parseSignature :: Text -> Either Text Signature
parseSignature txt = decode $ T.dropEnd constLen txt
where
constLen = T.length ".sig.ed25519"
decode :: Text -> Either Text Signature
- decode = mapRight Signature . mapLeft toS . Base64.decode . toS
+ decode = mapRight Signature . mapLeft toS . Base64.decode . encodeUtf8
instance FromJSON Signature where
parseJSON = Aeson.withText "Signature" $ \v -> case parseSignature v of
@@ -206,7 +206,7 @@ withSignature signature buf = (dropEnd (BS.length endTxt) buf) <> sigTxt
sigTxt =
",\n \"signature\": "
<> "\""
- <> toS (formatSignature signature)
+ <> encodeUtf8 (formatSignature signature)
<> "\""
<> endTxt
endTxt = "\n}"
@@ -332,9 +332,9 @@ encodeForSigning contentOrder arg = do
then
return (error "external V8 byte string encoder not initialized")
else do
- atomically $ putTMVar v8Input (cmd <> toS arg)
+ atomically $ putTMVar v8Input (cmd <> arg)
ret <- atomically $ takeTMVar v8Output
- let ret' = Base64.decode (toS ret)
+ let ret' = Base64.decode ret
return $ mapLeft toS ret'
where
cmd = if contentOrder