@@ -21,6 +21,8 @@ import Data.Channel.NamedChannel
21import Data.Channel.AnonymousChannel
21import Data.Channel.AnonymousChannel
22import qualified Data.Post as P
22import qualified Data.Post as P
23import Server.Query.Pagination
23import Server.Query.Pagination
25-- MARK: Implementation
27-- MARK: Implementation
@@ -47,7 +49,11 @@ getChannel uId (PaginatingRequest pId lim (Just cId) dir) = runQnotFound $ getCh
47getChannel _ (PaginatingRequest pId lim Nothing dir) = maybeNotFound . runQnotFound $ getLastPosts pId lim dir
49getChannel _ (PaginatingRequest pId lim Nothing dir) = maybeNotFound . runQnotFound $ getLastPosts pId lim dir
49createChannelApi :: UserId -> NamedChannelCreationRequest -> App NamedChannelId
51createChannelApi :: UserId -> NamedChannelCreationRequest -> App NamedChannelId
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."
50−createChannelApi uId req = maybeNotFound . runQnotFound $ createNewChannel uId req
56+ else maybeNotFound . runQerror $ createNewChannel uId req
52updateChannelApi :: UserId -> NamedChannel UserId -> App NoContent
58updateChannelApi :: UserId -> NamedChannel UserId -> App NoContent
53updateChannelApi uId req = do
59updateChannelApi uId req = do
@@ -57,4 +63,8 @@ updateChannelApi uId req = do
57deleteChannelApi :: UserId -> NamedChannelId -> App NoContent
63deleteChannelApi :: UserId -> NamedChannelId -> App NoContent
58deleteChannelApi uId cId = do
64deleteChannelApi uId cId = do
59 runQnotFound $ deleteNamedChannel uId cId
65 runQnotFound $ deleteNamedChannel uId cId
60− return NoContent
66+ return NoContent
69+channelCountLimit :: Int64