@@ -23,9 +23,12 @@ import qualified Data.Post as P
23import Server.Query.Pagination
23import Server.Query.Pagination
24import Data.Int
24import Data.Int
25import Server.Error
25import Server.Error
26+import Data.Text (Text)
27type CreateDescription = Description "Creates a new channel\n\nReturns 406 if the channel limit has been exceeded."
28type CreateDescription = Description "Creates a new channel\n\nReturns 406 if the channel limit has been exceeded."
30+type SearchDescription = Description "Search for user channels."
29-- MARK: Implementation
32-- MARK: Implementation
31type ChannelsApi = Post '[JSON] [NamedChannel UserId] :<|>
34type ChannelsApi = Post '[JSON] [NamedChannel UserId] :<|>
@@ -33,10 +36,11 @@ type ChannelsApi = Post '[JSON] [NamedChannel UserId] :<|>
33 "getAnonymous" :> ReqBody '[JSON] (PaginatingRequest P.PostId (Maybe AnonymousChannel)) :> Post '[JSON] (ResponseWithUsers [P.Post]) :<|>
36 "getAnonymous" :> ReqBody '[JSON] (PaginatingRequest P.PostId (Maybe AnonymousChannel)) :> Post '[JSON] (ResponseWithUsers [P.Post]) :<|>
34 "create" :> CreateDescription :> ReqBody '[JSON] NamedChannelCreationRequest :> Post '[JSON] NamedChannelId :<|>
37 "create" :> CreateDescription :> ReqBody '[JSON] NamedChannelCreationRequest :> Post '[JSON] NamedChannelId :<|>
35 "update" :> ReqBody '[JSON] (NamedChannel UserId) :> PostNoContent '[JSON, FormUrlEncoded, PlainText] NoContent :<|>
38 "update" :> ReqBody '[JSON] (NamedChannel UserId) :> PostNoContent '[JSON, FormUrlEncoded, PlainText] NoContent :<|>
36− "delete" :> ReqBody '[JSON] NamedChannelId :> PostNoContent '[JSON, FormUrlEncoded, PlainText] NoContent
39+ "delete" :> ReqBody '[JSON] NamedChannelId :> PostNoContent '[JSON, FormUrlEncoded, PlainText] NoContent :<|>
40+ "search" :> SearchDescription :> ReqBody '[JSON, PlainText] Text :> Post '[JSON] [NamedChannel UserId]
38channelsApi :: UserId -> ServerT ChannelsApi App
42channelsApi :: UserId -> ServerT ChannelsApi App
39−channelsApi uId = getChannelsApi uId :<|> getChannel uId :<|> getAnonymousChannelsApi :<|> createChannelApi uId :<|> updateChannelApi uId :<|> deleteChannelApi uId
43+channelsApi uId = getChannelsApi uId :<|> getChannel uId :<|> getAnonymousChannelsApi :<|> createChannelApi uId :<|> updateChannelApi uId :<|> deleteChannelApi uId :<|> searchChannelsApi uId
42getChannelsApi :: UserId -> App [NamedChannel UserId]
46getChannelsApi :: UserId -> App [NamedChannel UserId]
@@ -67,6 +71,9 @@ deleteChannelApi uId cId = do
67 runQnotFound $ deleteNamedChannel uId cId
71 runQnotFound $ deleteNamedChannel uId cId
68 return NoContent
72 return NoContent
74+searchChannelsApi :: UserId -> Text -> App [NamedChannel UserId]
75+searchChannelsApi uId = runQerror . searchChannels uId
70-- TODO: Increase
77-- TODO: Increase
71channelCountLimit :: Int64
78channelCountLimit :: Int64
72channelCountLimit = 5
79channelCountLimit = 5