made something working

This commit is contained in:
Yann Esposito (Yogsototh) 2019-06-14 23:20:14 +02:00
parent 4e3888ae12
commit 1386a2d482
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
3 changed files with 16 additions and 15 deletions

View file

@ -45,6 +45,7 @@ import Protolude
import Aggreact.Auth
import Aggreact.Authorization
import Aggreact.Comments
import Aggreact.DB
import Aggreact.Homepage
import Aggreact.Slugs
import Aggreact.Users
@ -56,12 +57,12 @@ import Servant.Auth.Server
data Conf =
Conf
{ port :: Int
, jwtKeyFilePath :: FilePath
, cookieSettings :: CookieSettings
, userDBConf :: UserDBConf
, slugDBConf :: SlugDBConf
, commentDBConf :: CommentDBConf
{ port :: Int
, jwtKeyFilePath :: FilePath
, cookieSettings :: CookieSettings
, userDBConf :: UserDBConf
, slugDBConf :: SlugDBConf
, commentDBConf :: CommentDBConf
, authorizationStrategy :: AuthorizationStrategy
} deriving (Eq, Show)
@ -85,11 +86,11 @@ serverAuthenticated Settings{..} authresult =
:<|> userAPI userHandler authorizationHandler authresult
data Settings =
Settings { cookieSettings :: CookieSettings
, jwtSettings :: JWTSettings
, slugHandler :: SlugHandler
, userHandler :: UserHandler
, commentHandler :: CommentHandler
Settings { cookieSettings :: CookieSettings
, jwtSettings :: JWTSettings
, slugHandler :: SlugHandler
, userHandler :: UserHandler
, commentHandler :: CommentHandler
, authorizationHandler :: AuthorizationHandler
}
@ -108,7 +109,7 @@ mainServe conf = do
initialize :: Conf -> IO (Settings,Application)
initialize Conf{..} = do
uh <- newUserHandler userDBConf defaultAdminUser
ch <- newCommentHandler (dbstore uh) commentDBConf
ch <- newCommentHandler aggreactDB (dbstore uh) commentDBConf
sh <- newSlugHandler slugDBConf
ah <- newAuthorizationHandler authorizationStrategy
myKey <- readKey jwtKeyFilePath

View file

@ -122,7 +122,7 @@ commentsView' conn db (Slug sl) = do
(Beam.all_ (_aggreactUsers db))
(\u -> (Beam.maybe_
(Beam.val_ False)
(`references_` u)
(Beam.==. (User._id u))
(_userid comment)))
pure (comment,muser)
traverse (\(c,mu) -> pure $

View file

@ -151,14 +151,14 @@ bCommentToCommentNoUser bc =
, created = _created bc })
data BCommentT f =
BComment
BCommentT
{ _parent :: Beam.Columnar (Beam.Nullable f) Text -- ^ UUID
, _slug :: Beam.Columnar f Text -- ^ Text (URL)
, _content :: Beam.Columnar f Text -- ^ Text
, _created :: Beam.Columnar f UTCTime
, _updated :: Beam.Columnar f (Maybe UTCTime)
, _id :: Beam.Columnar f Text
, _userid :: Beam.PrimaryKey BUserT (Beam.Nullable f) -- ^ UUID
, _userid :: Beam.Columnar f (Maybe Text) -- ^ UUID
} deriving (Generic)
type BComment = BCommentT Identity
type BCommentId = Beam.PrimaryKey BCommentT Identity