on 0771fc6 help sign in
4 files changed+11−24
since splitsnapshots
unifiedsplit
denis/src/Data/Channel/AnonymousChannel.hs+1−5 denis/src/Data/PostElement.hs+2−8 denis/src/Data/Query.hs+5−5 denis/src/Data/Tags/Validation.hs+3−6
denis/src/Data/Channel/AnonymousChannel.hs+1−5
@@ -1,4 +1,4 @@
1−{-# LANGUAGE
1+ {-# LANGUAGE
22 DataKinds ,
33 DeriveGeneric ,
44 OverloadedLabels,
@@ -9,11 +9,9 @@
99 RecordWildCards #-}
1010
1111module Data.Channel.AnonymousChannel (
12− AnonymousChannelId,
1312 AnonymousChannel(..)
1413) where
1514
16−import Data.Int (Int64)
1715import qualified Generics.SOP as SOP
1816import qualified GHC.Generics as GHC
1917import Data.Aeson
@@ -36,8 +34,6 @@ instance HasValidatableText AnonymousChannel where
3634
3735-- MARK: Implementation
3836
39−type AnonymousChannelId = Int64
40−
4137data AnonymousChannel = AnonymousChannel {
4238 anonymousChannelTags :: V.Vector Text,
4339 anonymousChannelPeopleIds :: [UserId]
denis/src/Data/PostElement.hs+2−8
@@ -16,14 +16,13 @@ module Data.PostElement (
1616 PostElementRow(..),
1717 PostElement(..),
1818 elementsToRows,
19− PostQuote(..),
20− stripPostElement
19+ PostQuote(..)
2120) where
2221
2322import Data.Int (Int64)
2423import qualified Generics.SOP as SOP
2524import qualified GHC.Generics as GHC
26−import Data.Text (Text, strip)
25+import Data.Text (Text)
2726import Data.Aeson
2827import Control.Applicative ((<|>))
2928import Servant.Docs (ToSample, toSamples, samples)
@@ -55,11 +54,6 @@ data PostElement a = Markdown Text
5554 | Attachment Text
5655 deriving (Show, GHC.Generic)
5756
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−
6357instance ToJSON (PostElement t) where
6458 toJSON (Markdown m) = object ["markdown" .= m]
6559 toJSON (Latex l) = object ["latex" .= l]
denis/src/Data/Query.hs+5−5
@@ -935,7 +935,7 @@ publishPost uId pc = commitedTransactionallyUpdate $ do
935935 pId' <- manipulateParams createPostRowQ (uId, postCreationTags pc) >>= firstRow
936936 case pId' of
937937 (Just (Only pId)) -> do
938− traversePrepared_ createPostElementRowsQ $ elementsToRows pId (map stripPostElement $ postCreationBody pc)
938+ traversePrepared_ createPostElementRowsQ $ elementsToRows pId (postCreationBody pc)
939939 return pId
940940 _ -> lift $ S.throwError S.err404
941941
@@ -1043,14 +1043,14 @@ getMessagesInGroupChat selfId gId mId lim dir = do
10431043 return . catMaybes . map restoreMessage $ resp
10441044
10451045sendMessage :: 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
10471047 _ <- 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)
10491049 >>= firstRow >>= fromMaybe500
10501050 return mId
1051−sendMessage selfId (MessageCreation gId@Nothing (Just uId) (Jsonb body)) = do
1051+sendMessage selfId (MessageCreation gId@Nothing (Just uId) body) = do
10521052 verifyUsers [uId]
1053− (Only mId) <- manipulateParams createMessageQ (selfId, gId, Just uId, Jsonb $ stripPostElement body)
1053+ (Only mId) <- manipulateParams createMessageQ (selfId, gId, Just uId, body)
10541054 >>= firstRow >>= fromMaybe500
10551055 return mId
10561056sendMessage _ _ = lift $ S.throwError S.err400
denis/src/Data/Tags/Validation.hs+3−6
@@ -4,8 +4,7 @@ module Data.Tags.Validation (
44 ) where
55
66import Data.Text as T
7−import Data.Char as C
8−import qualified Data.Set as S
7+import Data.Char
98
109validateTag :: T.Text -> Maybe T.Text
1110validateTag tag =
@@ -18,8 +17,6 @@ validateTag tag =
1817validateTag' :: T.Text -> Bool
1918validateTag' = T.all validChar
2019
21−validChars :: S.Set Char
22−validChars = S.fromList "йцукенгшщзхъфывапролджэёячсмитьбюqwertyuiopasdfghjklzxcvbnm1234567890_"
23−
2420validChar :: Char -> Bool
25−validChar c = S.member (C.toLower c) validChars
21+validChar '-' = True
22+validChar c = isAlphaNum c