normalise hastag unicode representation of incoming posts

This commit is contained in:
Trolli Schmittlauch 2020-07-27 21:49:42 +02:00
parent daae9d0b38
commit 736815ea83
2 changed files with 4 additions and 2 deletions

View file

@ -21,6 +21,8 @@ import qualified Data.HashSet as HSet
import Data.Maybe (fromMaybe)
import Data.String (fromString)
import qualified Data.Text.Lazy as Txt
import Data.Text.Normalize (NormalizationMode (NFC),
normalize)
import Data.Time.Clock.POSIX
import System.Random
@ -135,7 +137,7 @@ relayInbox :: PostService d -> Txt.Text -> Handler NoContent
relayInbox serv post = do
-- extract contained hashtags
let
containedTags = fmap Txt.tail . filter ((==) '#' . Txt.head) . Txt.words $ post
containedTags = fmap (Txt.fromStrict . normalize NFC . Txt.toStrict . Txt.tail) . filter ((==) '#' . Txt.head) . Txt.words $ post
-- generate post ID
postId <- liftIO $ Txt.pack . show <$> (randomRIO (0, 2^128-1) :: IO Integer)
-- add ID to own posts