Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. function addComment(comment) {
  2. return fetchPostBySlug(comment.postSlug).then((post) => {
  3. if (!post.isCommentingEnabled) {
  4. return Promise.reject(new Error('Commenting is disabled.'));
  5. }
  6.  
  7. return isUserAllowedToComment(post, comment.user).then((isAllowed) => {
  8. if (!isAllowed) {
  9. return Promise.reject(
  10. new Error('The user is not allowed to comment on this post.')
  11. );
  12. }
  13.  
  14. return insertComment(post.id, comment.user, comment.message).then((result) => {
  15. return result.record;
  16. })
  17. });
  18. })
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement