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