Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function addComment(comment) {
- const post = await fetchPostBySlug(comment.postSlug);
- if (!post.isCommentingEnabled) {
- throw new Error('Commenting is disabled.');
- }
- const isAllowed = await isUserAllowedToComment(post, comment.user);
- if (!isAllowed) {
- throw new Error('The user is not allowed to comment on this post.');
- }
- const result = await insertComment(post.id, comment.user, comment.message);
- return result.record;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement