add interested api endpoint
This commit is contained in:
parent
9a8a1208db
commit
8451509cac
3 changed files with 41 additions and 1 deletions
19
src/Interested.hs
Normal file
19
src/Interested.hs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Interested (register) where
|
||||
|
||||
import Data.Text qualified as T
|
||||
import Data.UUID qualified as UUID
|
||||
import Data.UUID.V4 qualified as UUID.V4
|
||||
|
||||
register :: T.Text -> Maybe T.Text -> IO T.Text
|
||||
register event identifier = do
|
||||
cookie_uuid <- case ( case identifier of
|
||||
Just i -> UUID.fromString (T.unpack i)
|
||||
Nothing -> Nothing
|
||||
) of
|
||||
Just i -> pure i
|
||||
Nothing -> UUID.V4.nextRandom
|
||||
appendFile "test.txt" (T.unpack (T.filter (\c -> c /= '\n' && c /= ',') event) <> "," <> (UUID.toString cookie_uuid) <> "\n")
|
||||
|
||||
pure $ (UUID.toText cookie_uuid)
|
||||
Loading…
Add table
Add a link
Reference in a new issue