-- | Construct a comment, auto-approved by 'this' User (because they are
-- established).
makeApprovedComment
    :: UserId
    -> DiscussionId
    -> Maybe CommentId
    -> Markdown
    -> Int
    -> Visibility
    -> Language
    -> YDB Comment
makeApprovedComment
        user_id
        discussion_id
        parent_comment
        comment_text
        depth
        visibility
        language = do

    now <- liftIO getCurrentTime
    maybe_parent_visibility <- case parent_comment of
        Nothing -> return Nothing
        Just parent_comment_id ->
            fmap (fmap commentVisibility) $ get parent_comment_id

    let parent_visibility = fromMaybe VisPublic maybe_parent_visibility

    return $ Comment
        now
        (Just now)
        (Just user_id)
        discussion_id
        parent_comment
        user_id
        comment_text
        depth
        (min visibility parent_visibility)
        language

-- | Get the set of Users that have posted the given Foldable of comments.
makeApprovedComment
    :: UserId
    -> DiscussionId
    -> Maybe CommentId
    -> Markdown
    -> Int
    -> Visibility
    -> Language
    -> YDB Comment
makeApprovedComment
        user_id
        discussion_id
        parent_comment
        comment_text
        depth
        visibility
        language = do

    now <- liftIO getCurrentTime
    maybe_parent_visibility <- case parent_comment of
        Nothing -> return Nothing
        Just parent_comment_id ->
            fmap (fmap commentVisibility) $ get parent_comment_id

    let parent_visibility = fromMaybe VisPublic maybe_parent_visibility

    return $ Comment
        now
        (Just now)
        (Just user_id)
        discussion_id
        parent_comment
        user_id
        comment_text
        depth
        (min visibility parent_visibility)
        language

-- | Get the set of Users that have posted the given Foldable of comments.
makeApprovedComment
        user_id
        discussion_id
        parent_comment
        comment_text
        depth
        visibility
        language = do

    now <- liftIO getCurrentTime
    maybe_parent_visibility <- case parent_comment of
        Nothing -> return Nothing
        Just parent_comment_id ->
            fmap (fmap commentVisibility) $ get parent_comment_id

    let parent_visibility = fromMaybe VisPublic maybe_parent_visibility

    return $ Comment
        now
        (Just now)
        (Just user_id)
        discussion_id
        parent_comment
        user_id
        comment_text
        depth
        (min visibility parent_visibility)
        language

-- | Get the set of Users that have posted the given Foldable of comments.