forked from schmittlauch/Hash2Pub
normalise hastag unicode representation of incoming posts
This commit is contained in:
parent
daae9d0b38
commit
736815ea83
2 changed files with 4 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue