@@ -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
@@ -1006,6 +1006,7 @@ deleteNamedChannel uId cId = do
10061006 _ <- commitedTransactionallyUpdate $ manipulateParams deleteNamedChannelQ (Only cId)
10071007 return ()
10081008
1009+-- Returns n most popular
10091010getTags :: Limit -> StaticPQ [String]
10101011getTags lim = map fromOnly <$> (runQuery (getNpopularTagsQ lim) >>= getRows)
10111012
@@ -1043,37 +1044,33 @@ getMessagesInGroupChat selfId gId mId lim dir = do
10431044 return . catMaybes . map restoreMessage $ resp
10441045
10451046sendMessage :: UserId -> MessageCreation -> StaticPQ MessageId
1046−sendMessage selfId (MessageCreation (Just gId) uId@Nothing (Jsonb body)) = do
1047+sendMessage selfId (MessageCreation (Just gId) uId@Nothing body) = do
10471048 _ <- getGroupChatForUser selfId gId
1048− (Only mId) <- manipulateParams createMessageQ (selfId, Just gId, uId, Jsonb $ stripPostElement body)
1049+ (Only mId) <- manipulateParams createMessageQ (selfId, Just gId, uId, body)
10491050 >>= firstRow >>= fromMaybe500
10501051 return mId
1051−sendMessage selfId (MessageCreation gId@Nothing (Just uId) (Jsonb body)) = do
1052+sendMessage selfId (MessageCreation gId@Nothing (Just uId) body) = do
10521053 verifyUsers [uId]
1053− (Only mId) <- manipulateParams createMessageQ (selfId, gId, Just uId, Jsonb $ stripPostElement body)
1054+ (Only mId) <- manipulateParams createMessageQ (selfId, gId, Just uId, body)
10541055 >>= firstRow >>= fromMaybe500
10551056 return mId
10561057sendMessage _ _ = lift $ S.throwError S.err400
10571058
10581059createGroupChat :: UserId -> GroupChatCreation -> StaticPQ GroupChatId
1059−createGroupChat uId (GroupChatCreation (Jsonb chatUsers) name) = do
1060− verifyUsers . M.keys $ chatUsers
1061− commitedTransactionallyUpdate $ do
1062− let chatUsers' = M.insert uId maxChatPermissions chatUsers
1063− (Only chatId) <- manipulateParams createGroupChatQ (GroupChatCreation (Jsonb chatUsers') name)
1064− >>= firstRow >>= fromMaybe500
1065− _ <- manipulateParams createPhantomMessageQ (Only chatId)
1066− return chatId
1060+createGroupChat uId (GroupChatCreation (Jsonb chatUsers) name) = commitedTransactionallyUpdate $ do
1061+ let chatUsers' = M.insert uId maxChatPermissions chatUsers
1062+ (Only chatId) <- manipulateParams createGroupChatQ (GroupChatCreation (Jsonb chatUsers') name)
1063+ >>= firstRow >>= fromMaybe500
1064+ _ <- manipulateParams createPhantomMessageQ (Only chatId)
1065+ return chatId
10671066
10681067updateGroupChat :: UserId -> GroupChat -> StaticPQ ()
1069−updateGroupChat uId (GroupChat gId (Jsonb perms) name) = do
1070− verifyUsers . M.keys $ perms
1071− commitedTransactionallyUpdate $ do
1072− (GroupChat _ (Jsonb perms') _) <- getGroupChatForUser uId gId
1073− let userPerm = fromMaybe minChatPermissions $ M.lookup uId perms'
1074− unless (isAdmin userPerm) $ lift $ S.throwError $ S.err401
1075− let newPerms = M.insert uId userPerm perms
1076− void $ manipulateParams updateGroupChatQ (GroupChat gId (Jsonb newPerms) name)
1068+updateGroupChat uId (GroupChat gId (Jsonb perms) name) = commitedTransactionallyUpdate $ do
1069+ (GroupChat _ (Jsonb perms') _) <- getGroupChatForUser uId gId
1070+ let userPerm = fromMaybe minChatPermissions $ M.lookup uId perms'
1071+ unless (isAdmin userPerm) $ lift $ S.throwError $ S.err401
1072+ let newPerms = M.insert uId userPerm perms
1073+ void $ manipulateParams updateGroupChatQ (GroupChat gId (Jsonb newPerms) name)
10771074
10781075leaveGroupChat :: UserId -> GroupChatId -> StaticPQ ()
10791076leaveGroupChat uId gId = commitedTransactionallyUpdate $ do