@@ -23,9 +23,12 @@ import qualified Data.Post as P
2323import Server.Query.Pagination
2424import Data.Int
2525import Server.Error
26+import Data.Text (Text)
2627
2728type CreateDescription = Description "Creates a new channel\n\nReturns 406 if the channel limit has been exceeded."
2829
30+type SearchDescription = Description "Search for user channels."
31+
2932-- MARK: Implementation
3033
3134type ChannelsApi = Post '[JSON] [NamedChannel UserId] :<|>
@@ -33,10 +36,11 @@ type ChannelsApi = Post '[JSON] [NamedChannel UserId] :<|>
3336 "getAnonymous" :> ReqBody '[JSON] (PaginatingRequest P.PostId (Maybe AnonymousChannel)) :> Post '[JSON] (ResponseWithUsers [P.Post]) :<|>
3437 "create" :> CreateDescription :> ReqBody '[JSON] NamedChannelCreationRequest :> Post '[JSON] NamedChannelId :<|>
3538 "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]
3741
3842channelsApi :: 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
4044
4145
4246getChannelsApi :: UserId -> App [NamedChannel UserId]
@@ -67,6 +71,9 @@ deleteChannelApi uId cId = do
6771 runQnotFound $ deleteNamedChannel uId cId
6872 return NoContent
6973
74+searchChannelsApi :: UserId -> Text -> App [NamedChannel UserId]
75+searchChannelsApi uId = runQerror . searchChannels uId
76+
7077-- TODO: Increase
7178channelCountLimit :: Int64
7279channelCountLimit = 5