{"action":"created","comment":{"url":"https://api.github.com/repos/meanjs/mean/pulls/comments/29382959","id":29382959,"diff_hunk":"@@ -54,3 +54,49 @@ exports.update = function(req, res) {\n exports.me = function(req, res) {\n \tres.json(req.user || null);\n };\n+\n+/**\n+ * Record up/down/none Vote On Article\n+ */\n+exports.vote = function(req, res) {\n+\tvar voteIndex = 0;\n+\tvar oldVoteDirection;\n+\n+\t// prevent User cross voting\n+\tif(req.user.id !== req.profile.id) {\n+\t\tvar err = new Error('User ' + req.user.id + ' trying to vote as user ' + req.profile.id);\n+\t\treturn res.status(400).send({\n+\t\t\tmessage: errorHandler.getErrorMessage(err)\n+\t\t});\n+\t}\n+\n+\t// look for existing vote\n+\tfor(voteIndex = 0; voteIndex<req.profile.votes.length; voteIndex++) {\n+\t\tif(req.article._id.equals(req.profile.votes[voteIndex]._id)) {\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\t// if no vote exists, add one\n+\tif(voteIndex === req.profile.votes.length) {\n+\t\treq.profile.votes.push({\n+\t\t\t_id: req.article._id,\n+\t\t\tdirection:'none'\n+\t\t});\n+\t}\n+\n+\toldVoteDirection = req.profile.votes[voteIndex].direction;\n+\treq.profile.votes[voteIndex].direction = req.params.direction;\n+\treq.profile.save(function(err) {\n+\t\tif (err) {\n+\t\t\treturn res.status(400).send({","path":"app/controllers/users/users.profile.server.controller.js","position":39,"original_position":39,"commit_id":"1a8182213c9e17e8326b9c501e03fcfc00d9e98a","original_commit_id":"1a8182213c9e17e8326b9c501e03fcfc00d9e98a","user":{"login":"ilanbiala","id":3695164,"avatar_url":"https://avatars.githubusercontent.com/u/3695164?v=3","gravatar_id":"","url":"https://api.github.com/users/ilanbiala","html_url":"https://github.com/ilanbiala","followers_url":"https://api.github.com/users/ilanbiala/followers","following_url":"https://api.github.com/users/ilanbiala/following{/other_user}","gists_url":"https://api.github.com/users/ilanbiala/gists{/gist_id}","starred_url":"https://api.github.com/users/ilanbiala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilanbiala/subscriptions","organizations_url":"https://api.github.com/users/ilanbiala/orgs","repos_url":"https://api.github.com/users/ilanbiala/repos","events_url":"https://api.github.com/users/ilanbiala/events{/privacy}","received_events_url":"https://api.github.com/users/ilanbiala/received_events","type":"User","site_admin":false},"body":"In which case is this a client error and not a 5xx of sorts?","created_at":"2015-04-29T21:28:31Z","updated_at":"2015-04-29T21:28:31Z","html_url":"https://github.com/meanjs/mean/pull/537#discussion_r29382959","pull_request_url":"https://api.github.com/repos/meanjs/mean/pulls/537","_links":{"self":{"href":"https://api.github.com/repos/meanjs/mean/pulls/comments/29382959"},"html":{"href":"https://github.com/meanjs/mean/pull/537#discussion_r29382959"},"pull_request":{"href":"https://api.github.com/repos/meanjs/mean/pulls/537"}}},"pull_request":{"url":"https://api.github.com/repos/meanjs/mean/pulls/537","id":34378124,"html_url":"https://github.com/meanjs/mean/pull/537","diff_url":"https://github.com/meanjs/mean/pull/537.diff","patch_url":"https://github.com/meanjs/mean/pull/537.patch","issue_url":"https://api.github.com/repos/meanjs/mean/issues/537","number":537,"state":"open","locked":false,"title":"add backend support for Article voting","user":{"login":"ppotoplyak","id":4952152,"avatar_url":"https://avatars.githubusercontent.com/u/4952152?v=3","gravatar_id":"","url":"https://api.github.com/users/ppotoplyak","html_url":"https://github.com/ppotoplyak","followers_url":"https://api.github.com/users/ppotoplyak/followers","following_url":"https://api.github.com/users/ppotoplyak/following{/other_user}","gists_url":"https://api.github.com/users/ppotoplyak/gists{/gist_id}","starred_url":"https://api.github.com/users/ppotoplyak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppotoplyak/subscriptions","organizations_url":"https://api.github.com/users/ppotoplyak/orgs","repos_url":"https://api.github.com/users/ppotoplyak/repos","events_url":"https://api.github.com/users/ppotoplyak/events{/privacy}","received_events_url":"https://api.github.com/users/ppotoplyak/received_events","type":"User","site_admin":false},"body":"Hi,\r\n\r\nThis patch introduces backend support for up/down voting an Article.\r\n\r\nI don't expect it to be merged as is but my intent is to start a conversation on the design decisions and gauge interest for up/down voting.\r\n\r\nthanks","created_at":"2015-04-29T16:00:24Z","updated_at":"2015-04-29T21:28:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"34d6ca866084209d2e3aaf824561771dbc57bc18","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/meanjs/mean/pulls/537/commits","review_comments_url":"https://api.github.com/repos/meanjs/mean/pulls/537/comments","review_comment_url":"https://api.github.com/repos/meanjs/mean/pulls/comments{/number}","comments_url":"https://api.github.com/repos/meanjs/mean/issues/537/comments","statuses_url":"https://api.github.com/repos/meanjs/mean/statuses/1a8182213c9e17e8326b9c501e03fcfc00d9e98a","head":{"label":"ppotoplyak:articles-voting","ref":"articles-voting","sha":"1a8182213c9e17e8326b9c501e03fcfc00d9e98a","user":{"login":"ppotoplyak","id":4952152,"avatar_url":"https://avatars.githubusercontent.com/u/4952152?v=3","gravatar_id":"","url":"https://api.github.com/users/ppotoplyak","html_url":"https://github.com/ppotoplyak","followers_url":"https://api.github.com/users/ppotoplyak/followers","following_url":"https://api.github.com/users/ppotoplyak/following{/other_user}","gists_url":"https://api.github.com/users/ppotoplyak/gists{/gist_id}","starred_url":"https://api.github.com/users/ppotoplyak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppotoplyak/subscriptions","organizations_url":"https://api.github.com/users/ppotoplyak/orgs","repos_url":"https://api.github.com/users/ppotoplyak/repos","events_url":"https://api.github.com/users/ppotoplyak/events{/privacy}","received_events_url":"https://api.github.com/users/ppotoplyak/received_events","type":"User","site_admin":false},"repo":{"id":34800755,"name":"mean","full_name":"ppotoplyak/mean","owner":{"login":"ppotoplyak","id":4952152,"avatar_url":"https://avatars.githubusercontent.com/u/4952152?v=3","gravatar_id":"","url":"https://api.github.com/users/ppotoplyak","html_url":"https://github.com/ppotoplyak","followers_url":"https://api.github.com/users/ppotoplyak/followers","following_url":"https://api.github.com/users/ppotoplyak/following{/other_user}","gists_url":"https://api.github.com/users/ppotoplyak/gists{/gist_id}","starred_url":"https://api.github.com/users/ppotoplyak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppotoplyak/subscriptions","organizations_url":"https://api.github.com/users/ppotoplyak/orgs","repos_url":"https://api.github.com/users/ppotoplyak/repos","events_url":"https://api.github.com/users/ppotoplyak/events{/privacy}","received_events_url":"https://api.github.com/users/ppotoplyak/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ppotoplyak/mean","description":"MEAN.JS - Full-Stack JavaScript Using MongoDB, Express, AngularJS, and Node.js - ","fork":true,"url":"https://api.github.com/repos/ppotoplyak/mean","forks_url":"https://api.github.com/repos/ppotoplyak/mean/forks","keys_url":"https://api.github.com/repos/ppotoplyak/mean/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ppotoplyak/mean/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ppotoplyak/mean/teams","hooks_url":"https://api.github.com/repos/ppotoplyak/mean/hooks","issue_events_url":"https://api.github.com/repos/ppotoplyak/mean/issues/events{/number}","events_url":"https://api.github.com/repos/ppotoplyak/mean/events","assignees_url":"https://api.github.com/repos/ppotoplyak/mean/assignees{/user}","branches_url":"https://api.github.com/repos/ppotoplyak/mean/branches{/branch}","tags_url":"https://api.github.com/repos/ppotoplyak/mean/tags","blobs_url":"https://api.github.com/repos/ppotoplyak/mean/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ppotoplyak/mean/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ppotoplyak/mean/git/refs{/sha}","trees_url":"https://api.github.com/repos/ppotoplyak/mean/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ppotoplyak/mean/statuses/{sha}","languages_url":"https://api.github.com/repos/ppotoplyak/mean/languages","stargazers_url":"https://api.github.com/repos/ppotoplyak/mean/stargazers","contributors_url":"https://api.github.com/repos/ppotoplyak/mean/contributors","subscribers_url":"https://api.github.com/repos/ppotoplyak/mean/subscribers","subscription_url":"https://api.github.com/repos/ppotoplyak/mean/subscription","commits_url":"https://api.github.com/repos/ppotoplyak/mean/commits{/sha}","git_commits_url":"https://api.github.com/repos/ppotoplyak/mean/git/commits{/sha}","comments_url":"https://api.github.com/repos/ppotoplyak/mean/comments{/number}","issue_comment_url":"https://api.github.com/repos/ppotoplyak/mean/issues/comments{/number}","contents_url":"https://api.github.com/repos/ppotoplyak/mean/contents/{+path}","compare_url":"https://api.github.com/repos/ppotoplyak/mean/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ppotoplyak/mean/merges","archive_url":"https://api.github.com/repos/ppotoplyak/mean/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ppotoplyak/mean/downloads","issues_url":"https://api.github.com/repos/ppotoplyak/mean/issues{/number}","pulls_url":"https://api.github.com/repos/ppotoplyak/mean/pulls{/number}","milestones_url":"https://api.github.com/repos/ppotoplyak/mean/milestones{/number}","notifications_url":"https://api.github.com/repos/ppotoplyak/mean/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ppotoplyak/mean/labels{/name}","releases_url":"https://api.github.com/repos/ppotoplyak/mean/releases{/id}","created_at":"2015-04-29T15:07:30Z","updated_at":"2015-04-29T15:07:30Z","pushed_at":"2015-04-29T15:48:17Z","git_url":"git://github.com/ppotoplyak/mean.git","ssh_url":"git@github.com:ppotoplyak/mean.git","clone_url":"https://github.com/ppotoplyak/mean.git","svn_url":"https://github.com/ppotoplyak/mean","homepage":"http://meanjs.org","size":6013,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"meanjs:master","ref":"master","sha":"9f9f4506d0d876fb7b5f85953d2752294b6079ce","user":{"login":"meanjs","id":6232122,"avatar_url":"https://avatars.githubusercontent.com/u/6232122?v=3","gravatar_id":"","url":"https://api.github.com/users/meanjs","html_url":"https://github.com/meanjs","followers_url":"https://api.github.com/users/meanjs/followers","following_url":"https://api.github.com/users/meanjs/following{/other_user}","gists_url":"https://api.github.com/users/meanjs/gists{/gist_id}","starred_url":"https://api.github.com/users/meanjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meanjs/subscriptions","organizations_url":"https://api.github.com/users/meanjs/orgs","repos_url":"https://api.github.com/users/meanjs/repos","events_url":"https://api.github.com/users/meanjs/events{/privacy}","received_events_url":"https://api.github.com/users/meanjs/received_events","type":"Organization","site_admin":false},"repo":{"id":15508537,"name":"mean","full_name":"meanjs/mean","owner":{"login":"meanjs","id":6232122,"avatar_url":"https://avatars.githubusercontent.com/u/6232122?v=3","gravatar_id":"","url":"https://api.github.com/users/meanjs","html_url":"https://github.com/meanjs","followers_url":"https://api.github.com/users/meanjs/followers","following_url":"https://api.github.com/users/meanjs/following{/other_user}","gists_url":"https://api.github.com/users/meanjs/gists{/gist_id}","starred_url":"https://api.github.com/users/meanjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meanjs/subscriptions","organizations_url":"https://api.github.com/users/meanjs/orgs","repos_url":"https://api.github.com/users/meanjs/repos","events_url":"https://api.github.com/users/meanjs/events{/privacy}","received_events_url":"https://api.github.com/users/meanjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/meanjs/mean","description":"MEAN.JS - Full-Stack JavaScript Using MongoDB, Express, AngularJS, and Node.js - ","fork":false,"url":"https://api.github.com/repos/meanjs/mean","forks_url":"https://api.github.com/repos/meanjs/mean/forks","keys_url":"https://api.github.com/repos/meanjs/mean/keys{/key_id}","collaborators_url":"https://api.github.com/repos/meanjs/mean/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/meanjs/mean/teams","hooks_url":"https://api.github.com/repos/meanjs/mean/hooks","issue_events_url":"https://api.github.com/repos/meanjs/mean/issues/events{/number}","events_url":"https://api.github.com/repos/meanjs/mean/events","assignees_url":"https://api.github.com/repos/meanjs/mean/assignees{/user}","branches_url":"https://api.github.com/repos/meanjs/mean/branches{/branch}","tags_url":"https://api.github.com/repos/meanjs/mean/tags","blobs_url":"https://api.github.com/repos/meanjs/mean/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/meanjs/mean/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/meanjs/mean/git/refs{/sha}","trees_url":"https://api.github.com/repos/meanjs/mean/git/trees{/sha}","statuses_url":"https://api.github.com/repos/meanjs/mean/statuses/{sha}","languages_url":"https://api.github.com/repos/meanjs/mean/languages","stargazers_url":"https://api.github.com/repos/meanjs/mean/stargazers","contributors_url":"https://api.github.com/repos/meanjs/mean/contributors","subscribers_url":"https://api.github.com/repos/meanjs/mean/subscribers","subscription_url":"https://api.github.com/repos/meanjs/mean/subscription","commits_url":"https://api.github.com/repos/meanjs/mean/commits{/sha}","git_commits_url":"https://api.github.com/repos/meanjs/mean/git/commits{/sha}","comments_url":"https://api.github.com/repos/meanjs/mean/comments{/number}","issue_comment_url":"https://api.github.com/repos/meanjs/mean/issues/comments{/number}","contents_url":"https://api.github.com/repos/meanjs/mean/contents/{+path}","compare_url":"https://api.github.com/repos/meanjs/mean/compare/{base}...{head}","merges_url":"https://api.github.com/repos/meanjs/mean/merges","archive_url":"https://api.github.com/repos/meanjs/mean/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/meanjs/mean/downloads","issues_url":"https://api.github.com/repos/meanjs/mean/issues{/number}","pulls_url":"https://api.github.com/repos/meanjs/mean/pulls{/number}","milestones_url":"https://api.github.com/repos/meanjs/mean/milestones{/number}","notifications_url":"https://api.github.com/repos/meanjs/mean/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/meanjs/mean/labels{/name}","releases_url":"https://api.github.com/repos/meanjs/mean/releases{/id}","created_at":"2013-12-29T13:01:15Z","updated_at":"2015-04-29T14:45:58Z","pushed_at":"2015-04-29T21:20:58Z","git_url":"git://github.com/meanjs/mean.git","ssh_url":"git@github.com:meanjs/mean.git","clone_url":"https://github.com/meanjs/mean.git","svn_url":"https://github.com/meanjs/mean","homepage":"http://meanjs.org","size":6013,"stargazers_count":1994,"watchers_count":1994,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":642,"mirror_url":null,"open_issues_count":116,"forks":642,"open_issues":116,"watchers":1994,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/meanjs/mean/pulls/537"},"html":{"href":"https://github.com/meanjs/mean/pull/537"},"issue":{"href":"https://api.github.com/repos/meanjs/mean/issues/537"},"comments":{"href":"https://api.github.com/repos/meanjs/mean/issues/537/comments"},"review_comments":{"href":"https://api.github.com/repos/meanjs/mean/pulls/537/comments"},"review_comment":{"href":"https://api.github.com/repos/meanjs/mean/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/meanjs/mean/pulls/537/commits"},"statuses":{"href":"https://api.github.com/repos/meanjs/mean/statuses/1a8182213c9e17e8326b9c501e03fcfc00d9e98a"}}}}