Start implementing channel listing (#2)
This commit is contained in:
parent
e50e234747
commit
83e39cbe6c
@ -96,9 +96,23 @@ instance ToNode (Catalog 1) where
|
|||||||
|
|
||||||
class Monad m => VersionedCatalog m (v :: Nat) where
|
class Monad m => VersionedCatalog m (v :: Nat) where
|
||||||
getChannels :: SafeUser -> m (Catalog v)
|
getChannels :: SafeUser -> m (Catalog v)
|
||||||
|
getBooks :: Channel.ChannelID -> SafeUser -> m (Catalog v)
|
||||||
|
|
||||||
instance VersionedCatalog AppM 1 where
|
instance VersionedCatalog AppM 1 where
|
||||||
getChannels = getChannelsV1
|
getChannels = getChannelsV1
|
||||||
|
getBooks = getBooksV1
|
||||||
|
|
||||||
|
getBooksV1 :: Channel.ChannelID -> SafeUser -> AppM (Catalog 1)
|
||||||
|
getBooksV1 identifier SafeUser{} = do
|
||||||
|
updated <- liftIO getCurrentTime
|
||||||
|
let self = Rel ("/api/current" <> selfUrl)
|
||||||
|
start = Rel ("/api/current" <> startUrl)
|
||||||
|
selfUrl = pack . uriPath . linkURI $ safeLink (Proxy @(BaseAPI 1)) (Proxy @(ChannelCatalog 1)) identifier
|
||||||
|
startUrl = pack . uriPath . linkURI $ safeLink (Proxy @(BaseAPI 1)) (Proxy @(RootCatalog 1))
|
||||||
|
entries = mempty
|
||||||
|
pagination = Pagination Nothing Nothing
|
||||||
|
pure CatalogV1{..}
|
||||||
|
|
||||||
|
|
||||||
getChannelsV1 :: SafeUser -> AppM (Catalog 1)
|
getChannelsV1 :: SafeUser -> AppM (Catalog 1)
|
||||||
getChannelsV1 SafeUser{username} = do
|
getChannelsV1 SafeUser{username} = do
|
||||||
@ -133,7 +147,7 @@ handler auth = catalogRoot :<|> catalogChannels
|
|||||||
where
|
where
|
||||||
catalogChannels :: Channel.ChannelID -> AppM (Catalog v)
|
catalogChannels :: Channel.ChannelID -> AppM (Catalog v)
|
||||||
-- Channel specific catalog returns tags inside the catalog
|
-- Channel specific catalog returns tags inside the catalog
|
||||||
catalogChannels _ = throwM err403{errBody="Not implemented"}
|
catalogChannels identifier = flip requireLoggedIn auth (getBooks identifier)
|
||||||
catalogRoot :: AppM (Catalog v)
|
catalogRoot :: AppM (Catalog v)
|
||||||
-- catalog root returns channels
|
-- catalog root returns channels
|
||||||
catalogRoot = flip requireLoggedIn auth getChannels
|
catalogRoot = flip requireLoggedIn auth getChannels
|
||||||
|
Loading…
Reference in New Issue
Block a user