on master help sign in
Merge pull request #87 from ilyakooo0/develop

passing `null` as `request` to `/channels/get` and `/channels/getAnon…

commit7c8446bcfb645c26d62bc36fd130c704c46592fa authoriko <ilyakooo0@gmail.com> dateWed 8 May 2019, 12:52 (7 years ago) parent8c019f9b6e3aa5
2 files changed+10−8
denis/src/Data/Query.hs+2−2 denis/src/Server/API/Channels.hs+8−6
denis/src/Data/Query.hs+2−2
@@ -257,7 +257,7 @@ getChannelPostsQ
257257 -> Vector Text
258258 -> Query
259259 Schema
260− (TuplePG (Only (Maybe PostId))) -- ^ post id from which to start
260+ (TuplePG (Only (Maybe PostId))) -- post id from which to start
261261 (RowPG PostRowResponse)
262262getChannelPostsQ lim dir uIds tags = getLastPostsQ
263263 (where_ $ jsonbLit tags .?| #postRowTags .|| isUser #postRowAuthorId)
@@ -320,7 +320,7 @@ type ConditionOp schema from grouping params nullity0 nullity1 (ty :: PGType)
320320
321321type ChatQueryParams = TuplePG
322322 ( UserId
323− , Maybe String -- ^ Just UserId as String
323+ , Maybe String -- Just UserId as String
324324 , Maybe MessageId
325325 )
326326
denis/src/Server/API/Channels.hs+8−6
@@ -25,8 +25,8 @@ import Server.Query.Pagination
2525-- MARK: Implementation
2626
2727type ChannelsApi = Post '[JSON] [NamedChannel UserId] :<|>
28− "get" :> ReqBody '[JSON] (PaginatingRequest P.PostId NamedChannelId) :> Post '[JSON] (ResponseWithUsers [P.Post]) :<|>
29− "getAnonymous" :> ReqBody '[JSON] (PaginatingRequest P.PostId AnonymousChannel) :> Post '[JSON] (ResponseWithUsers [P.Post]) :<|>
28+ "get" :> ReqBody '[JSON] (PaginatingRequest P.PostId (Maybe NamedChannelId)) :> Post '[JSON] (ResponseWithUsers [P.Post]) :<|>
29+ "getAnonymous" :> ReqBody '[JSON] (PaginatingRequest P.PostId (Maybe AnonymousChannel)) :> Post '[JSON] (ResponseWithUsers [P.Post]) :<|>
3030 "create" :> ReqBody '[JSON] NamedChannelCreationRequest :> Post '[JSON] NamedChannelId :<|>
3131 "update" :> ReqBody '[JSON] (NamedChannel UserId) :> PostNoContent '[JSON, FormUrlEncoded, PlainText] NoContent :<|>
3232 "delete" :> ReqBody '[JSON] NamedChannelId :> PostNoContent '[JSON, FormUrlEncoded, PlainText] NoContent
@@ -38,11 +38,13 @@ channelsApi uId = getChannelsApi uId :<|> getChannel uId :<|> getAnonymousChanne
3838getChannelsApi :: UserId -> App [NamedChannel UserId]
3939getChannelsApi uId = runQnotFound $ getAllChannels uId
4040
41−getAnonymousChannelsApi :: PaginatingRequest P.PostId AnonymousChannel -> App (ResponseWithUsers [P.Post])
42−getAnonymousChannelsApi (PaginatingRequest pId lim req dir) = runQnotFound $ getAnonymousChannelPosts pId lim dir req
41+getAnonymousChannelsApi :: PaginatingRequest P.PostId (Maybe AnonymousChannel) -> App (ResponseWithUsers [P.Post])
42+getAnonymousChannelsApi (PaginatingRequest pId lim (Just req) dir) = runQnotFound $ getAnonymousChannelPosts pId lim dir req
43+getAnonymousChannelsApi (PaginatingRequest pId lim Nothing dir) = maybeNotFound . runQnotFound $ getLastPosts pId lim dir
4344
44−getChannel :: UserId -> PaginatingRequest P.PostId NamedChannelId -> App (ResponseWithUsers [P.Post])
45−getChannel uId (PaginatingRequest pId lim cId dir) = runQnotFound $ getChannelPosts uId pId lim dir cId
45+getChannel :: UserId -> PaginatingRequest P.PostId (Maybe NamedChannelId) -> App (ResponseWithUsers [P.Post])
46+getChannel uId (PaginatingRequest pId lim (Just cId) dir) = runQnotFound $ getChannelPosts uId pId lim dir cId
47+getChannel _ (PaginatingRequest pId lim Nothing dir) = maybeNotFound . runQnotFound $ getLastPosts pId lim dir
4648
4749createChannelApi :: UserId -> NamedChannelCreationRequest -> App NamedChannelId
4850createChannelApi uId req = maybeNotFound . runQnotFound $ createNewChannel uId req