@@ -21,6 +21,8 @@ import Data.Channel.NamedChannel
2121import Data.Channel.AnonymousChannel
2222import qualified Data.Post as P
2323import Server.Query.Pagination
24+import Data.Int
25+import Server.Error
2426
2527-- MARK: Implementation
2628
@@ -47,7 +49,11 @@ getChannel uId (PaginatingRequest pId lim (Just cId) dir) = runQnotFound $ getCh
4749getChannel _ (PaginatingRequest pId lim Nothing dir) = maybeNotFound . runQnotFound $ getLastPosts pId lim dir
4850
4951createChannelApi :: UserId -> NamedChannelCreationRequest -> App NamedChannelId
50−createChannelApi uId req = maybeNotFound . runQnotFound $ createNewChannel uId req
52+createChannelApi uId req = do
53+ cCount <- runQerror $ channelCountForUser uId
54+ if cCount >= channelCountLimit
55+ then throwError $ limitExceeded "You have exceeded the number of channels you can create."
56+ else maybeNotFound . runQerror $ createNewChannel uId req
5157
5258updateChannelApi :: UserId -> NamedChannel UserId -> App NoContent
5359updateChannelApi uId req = do
@@ -57,4 +63,8 @@ updateChannelApi uId req = do
5763deleteChannelApi :: UserId -> NamedChannelId -> App NoContent
5864deleteChannelApi uId cId = do
5965 runQnotFound $ deleteNamedChannel uId cId
60− return NoContent
66+ return NoContent
67+
68+-- TODO: Increase
69+channelCountLimit :: Int64
70+channelCountLimit = 5