insertCommentDB :: Maybe UTCTime
                -> Maybe UserId
                -> (CommentId -> Comment -> SnowdriftEvent)
                -> UTCTime
                -> DiscussionId
                -> Maybe CommentId
                -> UserId
                -> Markdown
                -> Int
                -> Visibility
                -> Language
                -> SDB CommentId
insertCommentDB
        mapproved_ts
        mapproved_by
        mk_event
        created_ts
        discussion_id
        mparent_id
        user_id
        text
        depth
        visibility
        language = do

    mparent <- case mparent_id of
        Nothing -> return Nothing
        Just parent_id -> lift $ get parent_id

    let parent_visibility = maybe VisPublic commentVisibility mparent
        comment = Comment
                    created_ts
                    mapproved_ts
                    mapproved_by
                    discussion_id
                    mparent_id
                    user_id
                    text
                    depth
                    (min visibility parent_visibility)
                    language

    comment_id <- lift $ insert comment
    tell [mk_event comment_id comment]
    return comment_id
insertCommentDB :: Maybe UTCTime
                -> Maybe UserId
                -> (CommentId -> Comment -> SnowdriftEvent)
                -> UTCTime
                -> DiscussionId
                -> Maybe CommentId
                -> UserId
                -> Markdown
                -> Int
                -> Visibility
                -> Language
                -> SDB CommentId
insertCommentDB
        mapproved_ts
        mapproved_by
        mk_event
        created_ts
        discussion_id
        mparent_id
        user_id
        text
        depth
        visibility
        language = do

    mparent <- case mparent_id of
        Nothing -> return Nothing
        Just parent_id -> lift $ get parent_id

    let parent_visibility = maybe VisPublic commentVisibility mparent
        comment = Comment
                    created_ts
                    mapproved_ts
                    mapproved_by
                    discussion_id
                    mparent_id
                    user_id
                    text
                    depth
                    (min visibility parent_visibility)
                    language

    comment_id <- lift $ insert comment
    tell [mk_event comment_id comment]
    return comment_id
insertCommentDB
        mapproved_ts
        mapproved_by
        mk_event
        created_ts
        discussion_id
        mparent_id
        user_id
        text
        depth
        visibility
        language = do

    mparent <- case mparent_id of
        Nothing -> return Nothing
        Just parent_id -> lift $ get parent_id

    let parent_visibility = maybe VisPublic commentVisibility mparent
        comment = Comment
                    created_ts
                    mapproved_ts
                    mapproved_by
                    discussion_id
                    mparent_id
                    user_id
                    text
                    depth
                    (min visibility parent_visibility)
                    language

    comment_id <- lift $ insert comment
    tell [mk_event comment_id comment]
    return comment_id