on 088d930 help sign in
denis/src/Data/PostElement.hs+2−8
since splitsnapshots
unifiedsplit
@@ -16,14 +16,13 @@ module Data.PostElement (
16 PostElementRow(..),
16 PostElementRow(..),
17 PostElement(..),
17 PostElement(..),
18 elementsToRows,
18 elementsToRows,
19− PostQuote(..),
19+ PostQuote(..)
20− stripPostElement
21) where
20) where
22
21
23import Data.Int (Int64)
22import Data.Int (Int64)
24import qualified Generics.SOP as SOP
23import qualified Generics.SOP as SOP
25import qualified GHC.Generics as GHC
24import qualified GHC.Generics as GHC
26−import Data.Text (Text, strip)
25+import Data.Text (Text)
27import Data.Aeson
26import Data.Aeson
28import Control.Applicative ((<|>))
27import Control.Applicative ((<|>))
29import Servant.Docs (ToSample, toSamples, samples)
28import Servant.Docs (ToSample, toSamples, samples)
@@ -55,11 +54,6 @@ data PostElement a = Markdown Text
55 | Attachment Text
54 | Attachment Text
56 deriving (Show, GHC.Generic)
55 deriving (Show, GHC.Generic)
57
56
58−stripPostElement :: (PostElement a) -> (PostElement a)
59−stripPostElement (Markdown t) = Markdown (strip t)
60−stripPostElement (Latex t) = Latex (strip t)
61−stripPostElement u = u
62−
63instance ToJSON (PostElement t) where
57instance ToJSON (PostElement t) where
64 toJSON (Markdown m) = object ["markdown" .= m]
58 toJSON (Markdown m) = object ["markdown" .= m]
65 toJSON (Latex l) = object ["latex" .= l]
59 toJSON (Latex l) = object ["latex" .= l]
denis/src/Data/Query.hs+5−5
@@ -935,7 +935,7 @@ publishPost uId pc = commitedTransactionallyUpdate $ do
935 pId' <- manipulateParams createPostRowQ (uId, postCreationTags pc) >>= firstRow
935 pId' <- manipulateParams createPostRowQ (uId, postCreationTags pc) >>= firstRow
936 case pId' of
936 case pId' of
937 (Just (Only pId)) -> do
937 (Just (Only pId)) -> do
938− traversePrepared_ createPostElementRowsQ $ elementsToRows pId (map stripPostElement $ postCreationBody pc)
938+ traversePrepared_ createPostElementRowsQ $ elementsToRows pId (postCreationBody pc)
939 return pId
939 return pId
940 _ -> lift $ S.throwError S.err404
940 _ -> lift $ S.throwError S.err404
941
941
@@ -1043,14 +1043,14 @@ getMessagesInGroupChat selfId gId mId lim dir = do
1043 return . catMaybes . map restoreMessage $ resp
1043 return . catMaybes . map restoreMessage $ resp
1044
1044
1045sendMessage :: UserId -> MessageCreation -> StaticPQ MessageId
1045sendMessage :: UserId -> MessageCreation -> StaticPQ MessageId
1046−sendMessage selfId (MessageCreation (Just gId) uId@Nothing (Jsonb body)) = do
1046+sendMessage selfId (MessageCreation (Just gId) uId@Nothing body) = do
1047 _ <- getGroupChatForUser selfId gId
1047 _ <- getGroupChatForUser selfId gId
1048− (Only mId) <- manipulateParams createMessageQ (selfId, Just gId, uId, Jsonb $ stripPostElement body)
1048+ (Only mId) <- manipulateParams createMessageQ (selfId, Just gId, uId, body)
1049 >>= firstRow >>= fromMaybe500
1049 >>= firstRow >>= fromMaybe500
1050 return mId
1050 return mId
1051−sendMessage selfId (MessageCreation gId@Nothing (Just uId) (Jsonb body)) = do
1051+sendMessage selfId (MessageCreation gId@Nothing (Just uId) body) = do
1052 verifyUsers [uId]
1052 verifyUsers [uId]
1053− (Only mId) <- manipulateParams createMessageQ (selfId, gId, Just uId, Jsonb $ stripPostElement body)
1053+ (Only mId) <- manipulateParams createMessageQ (selfId, gId, Just uId, body)
1054 >>= firstRow >>= fromMaybe500
1054 >>= firstRow >>= fromMaybe500
1055 return mId
1055 return mId
1056sendMessage _ _ = lift $ S.throwError S.err400
1056sendMessage _ _ = lift $ S.throwError S.err400