@@ -4,7 +4,8 @@
4 OverloadedLabels,
4 OverloadedLabels,
5 OverloadedStrings ,
5 OverloadedStrings ,
6 TypeApplications ,
6 TypeApplications ,
7− TypeOperators #-}
7+ TypeOperators,
9module Server.API.Messages (
10module Server.API.Messages (
10 MessagesApi,
11 MessagesApi,
@@ -24,6 +25,9 @@ import Server.Query.Dialog
24import Data.Text.Validator
25import Data.Text.Validator
25import Control.Monad
26import Control.Monad
26import Server.Error
27import Server.Error
28+import qualified Data.Map as M
29+import Squeal.PostgreSQL.Schema
28type GetAllChatsDescription = Description "Gets chats starting from/ending with the given message id."
32type GetAllChatsDescription = Description "Gets chats starting from/ending with the given message id."
29type GetGroupChatDescription = Description "Gets information about a given group chat."
33type GetGroupChatDescription = Description "Gets information about a given group chat."
@@ -94,8 +98,9 @@ sendMessageApi uId mes = do
94 runQerror $ sendMessage uId mes
98 runQerror $ sendMessage uId mes
96createGroupChatApi :: UserId -> GroupChatCreation -> App GroupChatId
100createGroupChatApi :: UserId -> GroupChatCreation -> App GroupChatId
97−createGroupChatApi uId group = do
101+createGroupChatApi uId group@GroupChatCreation{..} = do
98 unless (validateText group) $ throwError lengthExceeded
102 unless (validateText group) $ throwError lengthExceeded
103+ unless ((M.size $ getJsonb groupChatCreationUsers) < groupChatSizeLimit) $ throwError amountExceeded
99 runQerror $ createGroupChat uId group
104 runQerror $ createGroupChat uId group
101leaveChatAPI :: UserId -> GroupChatId -> App NoContent
106leaveChatAPI :: UserId -> GroupChatId -> App NoContent