@@ -4,7 +4,8 @@
44 OverloadedLabels,
55 OverloadedStrings ,
66 TypeApplications ,
7− TypeOperators #-}
7+ TypeOperators,
8+ RecordWildCards #-}
89
910module Server.API.Messages (
1011 MessagesApi,
@@ -24,6 +25,9 @@ import Server.Query.Dialog
2425import Data.Text.Validator
2526import Control.Monad
2627import Server.Error
28+import qualified Data.Map as M
29+import Squeal.PostgreSQL.Schema
30+import Data.Limits
2731
2832type GetAllChatsDescription = Description "Gets chats starting from/ending with the given message id."
2933type GetGroupChatDescription = Description "Gets information about a given group chat."
@@ -94,8 +98,9 @@ sendMessageApi uId mes = do
9498 runQerror $ sendMessage uId mes
9599
96100createGroupChatApi :: UserId -> GroupChatCreation -> App GroupChatId
97−createGroupChatApi uId group = do
101+createGroupChatApi uId group@GroupChatCreation{..} = do
98102 unless (validateText group) $ throwError lengthExceeded
103+ unless ((M.size $ getJsonb groupChatCreationUsers) < groupChatSizeLimit) $ throwError amountExceeded
99104 runQerror $ createGroupChat uId group
100105
101106leaveChatAPI :: UserId -> GroupChatId -> App NoContent