Complete functions #15

Merged
MasseR merged 3 commits from sandbox/MasseR/14-error-types into master 2018-08-15 22:10:16 +03:00
Showing only changes of commit c05251525b - Show all commits

View File

@ -51,10 +51,10 @@ booksChannels bookId = fromRels <$> query q
attachChannel :: (MonadMask m, MonadIO m, MonadSelda m) => Username -> BookID -> Text -> m () attachChannel :: (MonadMask m, MonadIO m, MonadSelda m) => Username -> BookID -> Text -> m ()
attachChannel username bookId channel = do attachChannel username bookId channel = do
-- XXX: test what happens if channel doesn't exist mCh <- fromRels <$> query channelQ
[Channel{identifier}] <- fromRels <$> query channelQ forM_ mCh $ \Channel{identifier} ->
whenM (null <$> query (attachQ identifier)) $ whenM (null <$> query (attachQ identifier)) $
void $ insertGen bookChannels [BookChannel identifier bookId] void $ insertGen bookChannels [BookChannel identifier bookId]
where where
attachQ channelId = do attachQ channelId = do
(channelId' :*: bookId') <- select (gen bookChannels) (channelId' :*: bookId') <- select (gen bookChannels)