@@ -16,7 +16,7 @@ module Data.PostElement (
1616 MkElementRow,
1717 PostElementRow(..),
1818 elementsToRows
19−) where
19+) where
2020
2121import Data.Int (Int64)
2222import qualified Generics.SOP as SOP
@@ -25,7 +25,6 @@ import Data.Text (Text)
2525import Data.Aeson
2626import Control.Applicative ((<|>))
2727import Servant.Docs (ToSample, toSamples, samples)
28−import Data.Sanitizer
2928
3029-- MARK: Documentation
3130
@@ -44,14 +43,7 @@ data PostElement a = Markdown Text
4443 | Quote PostQuote
4544 | Attachment Text
4645
47−instance {-# Overlapping #-} Sanitizable (PostElement t) where
48− sanitize f (Markdown m) = Markdown (sanitize f m)
49− sanitize f (Latex l) = Latex (sanitize f l)
50− sanitize f (Image i) = Image (sanitize f i)
51− sanitize f (Quote q) = Quote (sanitize f q)
52− sanitize f (Attachment a) = Attachment (sanitize f a)
53−
54−instance ToJSON (PostElement t) where
46+instance ToJSON (PostElement t) where
5547 toJSON (Markdown m) = object ["markdown" .= m]
5648 toJSON (Latex l) = object ["latex" .= l]
5749 toJSON (Image i) = object ["image" .= i]
@@ -59,7 +51,7 @@ instance ToJSON (PostElement t) where
5951 toJSON (Attachment a) = object ["attachment" .= a]
6052
6153instance FromJSON (PostElement t) where
62− parseJSON = withObject "post element" $ \e ->
54+ parseJSON = withObject "post element" $ \e ->
6355 Markdown <$> e .: "markdown" <|>
6456 Latex <$> e .: "latex" <|>
6557 Image <$> e .: "image" <|>
@@ -83,7 +75,7 @@ rowsToElement :: MkElementRow (Maybe (PostElement p))
8375rowsToElement (Just m) Nothing Nothing Nothing Nothing = Just $ Markdown m
8476rowsToElement Nothing (Just l) Nothing Nothing Nothing = Just $ Latex l
8577rowsToElement Nothing Nothing (Just i) Nothing Nothing = Just $ Image i
86−-- rowsToElement Nothing Nothing Nothing (Just q) Nothing =
78+-- rowsToElement Nothing Nothing Nothing (Just q) Nothing =
8779-- fmap Quote $ M.lookup q pqrs >>= rowsToQuote erqs pqrs
8880rowsToElement Nothing Nothing Nothing Nothing (Just a) = Just $ Attachment a
8981rowsToElement _ _ _ _ _ = Nothing
@@ -106,7 +98,7 @@ elementsToRows :: Int64 -> [PostElement a] -> [PostElementRow a]
10698elementsToRows pId els = map (\(el, f) -> elemenToRow f el) . zip els . map (PostElementRow pId) $ [0..]
10799
108100
109−-- -- MARK: Quote
101+-- -- MARK: Quote
110102
111103data PostQuote = PostQuote {
112104 quoteId :: Int64,
@@ -114,16 +106,13 @@ data PostQuote = PostQuote {
114106 quotePostId :: Int64
115107}
116108
117−instance Sanitizable PostQuote where
118− sanitize f (PostQuote qId qB qPId) = PostQuote qId (sanitize f qB) qPId
119−
120109instance ToJSON PostQuote where
121110 toJSON (PostQuote qId pb pId) = object [
122− "id" .= qId,
111+ "id" .= qId,
123112 "postId" .= pId,
124113 "quoteBody" .= pb ]
125114
126−
115+
127116-- -- MARK: PostQuoteRow
128117
129118-- data PostQuoteRow = PostQuoteRow {
@@ -133,7 +122,7 @@ instance ToJSON PostQuote where
133122
134123-- instance SOP.Generic PostQuoteRow
135124-- instance SOP.HasDatatypeInfo PostQuoteRow
136−
125+
137126-- rowsToQuote :: M.Map Int64 [ElementRow PostQuote] -> M.Map Int64 PostQuoteRow -> PostQuoteRow -> Maybe PostQuote
138127-- rowsToQuote erqs pqrs (PostQuoteRow qId pId) = do
139128-- elementRows <- M.lookup qId erqs