{"action":"created","comment":{"url":"https://api.github.com/repos/HabitRPG/habitrpg/pulls/comments/66721057","id":66721057,"diff_hunk":"@@ -0,0 +1,99 @@\n+import { authWithHeaders } from '../../middlewares/api-v3/auth';\n+import _ from 'lodash';\n+import {\n+  BadRequest,\n+  NotAuthorized,\n+} from '../../libs/api-v3/errors';\n+\n+let api = {};\n+\n+/**\n+ * @apiIgnore\n+ * @api {post} /api/v3/user/add-push-device Add a push device to a user\n+ * @apiVersion 3.0.0\n+ * @apiName UserAddPushDevice\n+ * @apiGroup User\n+ *\n+ * @apiParam {string} regId The id of the push device\n+ * @apiParam {string} type The type of push device\n+ *\n+ * @apiSuccess {Object} data List of push devices\n+ * @apiSuccess {string} message Success message\n+ */\n+api.addPushDevice = {\n+  method: 'POST',\n+  url: '/user/add-push-device',\n+  middlewares: [authWithHeaders()],\n+  async handler (req, res) {\n+    let user = res.locals.user;\n+\n+    let regId = _.get(req, 'body.regId');","path":"website/server/controllers/api-v3/pushNotifications.js","position":30,"original_position":30,"commit_id":"11f5b7fea8208ea0b7a3aa64bc243693392d21c4","original_commit_id":"11f5b7fea8208ea0b7a3aa64bc243693392d21c4","user":{"login":"crookedneighbor","id":2916945,"avatar_url":"https://avatars.githubusercontent.com/u/2916945?v=3","gravatar_id":"","url":"https://api.github.com/users/crookedneighbor","html_url":"https://github.com/crookedneighbor","followers_url":"https://api.github.com/users/crookedneighbor/followers","following_url":"https://api.github.com/users/crookedneighbor/following{/other_user}","gists_url":"https://api.github.com/users/crookedneighbor/gists{/gist_id}","starred_url":"https://api.github.com/users/crookedneighbor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crookedneighbor/subscriptions","organizations_url":"https://api.github.com/users/crookedneighbor/orgs","repos_url":"https://api.github.com/users/crookedneighbor/repos","events_url":"https://api.github.com/users/crookedneighbor/events{/privacy}","received_events_url":"https://api.github.com/users/crookedneighbor/received_events","type":"User","site_admin":false},"body":"You should use the express validator checks for these. IE:\r\n\r\n```js\r\nreq.checkBody('regId', res.t('regIdRequired')).notEmpty();\r\nreq.checkBody('type', res.t('typeRequired')).notEmpty();\r\n\r\nlet validationErrors = req.validationErrors();\r\nif (validationErrors) throw validationErrors;\r\n\r\nlet item = {\r\n  regId: req.body.regId,\r\n  type: req.body.type,\r\n};\r\n```","created_at":"2016-06-12T13:49:05Z","updated_at":"2016-06-12T13:49:05Z","html_url":"https://github.com/HabitRPG/habitrpg/pull/7642#discussion_r66721057","pull_request_url":"https://api.github.com/repos/HabitRPG/habitrpg/pulls/7642","_links":{"self":{"href":"https://api.github.com/repos/HabitRPG/habitrpg/pulls/comments/66721057"},"html":{"href":"https://github.com/HabitRPG/habitrpg/pull/7642#discussion_r66721057"},"pull_request":{"href":"https://api.github.com/repos/HabitRPG/habitrpg/pulls/7642"}}},"pull_request":{"url":"https://api.github.com/repos/HabitRPG/habitrpg/pulls/7642","id":73374541,"html_url":"https://github.com/HabitRPG/habitrpg/pull/7642","diff_url":"https://github.com/HabitRPG/habitrpg/pull/7642.diff","patch_url":"https://github.com/HabitRPG/habitrpg/pull/7642.patch","issue_url":"https://api.github.com/repos/HabitRPG/habitrpg/issues/7642","number":7642,"state":"open","locked":false,"title":"Add/Improve push notification support","user":{"login":"vIiRuS","id":298062,"avatar_url":"https://avatars.githubusercontent.com/u/298062?v=3","gravatar_id":"","url":"https://api.github.com/users/vIiRuS","html_url":"https://github.com/vIiRuS","followers_url":"https://api.github.com/users/vIiRuS/followers","following_url":"https://api.github.com/users/vIiRuS/following{/other_user}","gists_url":"https://api.github.com/users/vIiRuS/gists{/gist_id}","starred_url":"https://api.github.com/users/vIiRuS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vIiRuS/subscriptions","organizations_url":"https://api.github.com/users/vIiRuS/orgs","repos_url":"https://api.github.com/users/vIiRuS/repos","events_url":"https://api.github.com/users/vIiRuS/events{/privacy}","received_events_url":"https://api.github.com/users/vIiRuS/received_events","type":"User","site_admin":false},"body":"### Changes\r\n\r\n- rename /user/addPushDevice to /user/add-push-device\r\n- add API Call to remove an existent Push Device\r\n- send push devices to iOS devices\r\n- include more data in push notifications\r\n- add options to enable/disable each push notification\r\n- add push notifications settings to notification settings page\r\n- add tests for the API calls\r\n\r\nThis PR still has one issue. Apple has an option to check for failed push devices. For some reason I have not yet been able to get one returned. I submit this PR now, so that it can be reviewed while I investigate this.","created_at":"2016-06-10T13:36:21Z","updated_at":"2016-06-12T13:49:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"efdf38cf516abd304314de57da2c86c27190c46b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/HabitRPG/habitrpg/pulls/7642/commits","review_comments_url":"https://api.github.com/repos/HabitRPG/habitrpg/pulls/7642/comments","review_comment_url":"https://api.github.com/repos/HabitRPG/habitrpg/pulls/comments{/number}","comments_url":"https://api.github.com/repos/HabitRPG/habitrpg/issues/7642/comments","statuses_url":"https://api.github.com/repos/HabitRPG/habitrpg/statuses/11f5b7fea8208ea0b7a3aa64bc243693392d21c4","head":{"label":"vIiRuS:push","ref":"push","sha":"11f5b7fea8208ea0b7a3aa64bc243693392d21c4","user":{"login":"vIiRuS","id":298062,"avatar_url":"https://avatars.githubusercontent.com/u/298062?v=3","gravatar_id":"","url":"https://api.github.com/users/vIiRuS","html_url":"https://github.com/vIiRuS","followers_url":"https://api.github.com/users/vIiRuS/followers","following_url":"https://api.github.com/users/vIiRuS/following{/other_user}","gists_url":"https://api.github.com/users/vIiRuS/gists{/gist_id}","starred_url":"https://api.github.com/users/vIiRuS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vIiRuS/subscriptions","organizations_url":"https://api.github.com/users/vIiRuS/orgs","repos_url":"https://api.github.com/users/vIiRuS/repos","events_url":"https://api.github.com/users/vIiRuS/events{/privacy}","received_events_url":"https://api.github.com/users/vIiRuS/received_events","type":"User","site_admin":false},"repo":{"id":15554181,"name":"habitrpg","full_name":"vIiRuS/habitrpg","owner":{"login":"vIiRuS","id":298062,"avatar_url":"https://avatars.githubusercontent.com/u/298062?v=3","gravatar_id":"","url":"https://api.github.com/users/vIiRuS","html_url":"https://github.com/vIiRuS","followers_url":"https://api.github.com/users/vIiRuS/followers","following_url":"https://api.github.com/users/vIiRuS/following{/other_user}","gists_url":"https://api.github.com/users/vIiRuS/gists{/gist_id}","starred_url":"https://api.github.com/users/vIiRuS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vIiRuS/subscriptions","organizations_url":"https://api.github.com/users/vIiRuS/orgs","repos_url":"https://api.github.com/users/vIiRuS/repos","events_url":"https://api.github.com/users/vIiRuS/events{/privacy}","received_events_url":"https://api.github.com/users/vIiRuS/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vIiRuS/habitrpg","description":"A habit tracker app which treats your goals like a Role Playing Game.","fork":true,"url":"https://api.github.com/repos/vIiRuS/habitrpg","forks_url":"https://api.github.com/repos/vIiRuS/habitrpg/forks","keys_url":"https://api.github.com/repos/vIiRuS/habitrpg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vIiRuS/habitrpg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vIiRuS/habitrpg/teams","hooks_url":"https://api.github.com/repos/vIiRuS/habitrpg/hooks","issue_events_url":"https://api.github.com/repos/vIiRuS/habitrpg/issues/events{/number}","events_url":"https://api.github.com/repos/vIiRuS/habitrpg/events","assignees_url":"https://api.github.com/repos/vIiRuS/habitrpg/assignees{/user}","branches_url":"https://api.github.com/repos/vIiRuS/habitrpg/branches{/branch}","tags_url":"https://api.github.com/repos/vIiRuS/habitrpg/tags","blobs_url":"https://api.github.com/repos/vIiRuS/habitrpg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vIiRuS/habitrpg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vIiRuS/habitrpg/git/refs{/sha}","trees_url":"https://api.github.com/repos/vIiRuS/habitrpg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vIiRuS/habitrpg/statuses/{sha}","languages_url":"https://api.github.com/repos/vIiRuS/habitrpg/languages","stargazers_url":"https://api.github.com/repos/vIiRuS/habitrpg/stargazers","contributors_url":"https://api.github.com/repos/vIiRuS/habitrpg/contributors","subscribers_url":"https://api.github.com/repos/vIiRuS/habitrpg/subscribers","subscription_url":"https://api.github.com/repos/vIiRuS/habitrpg/subscription","commits_url":"https://api.github.com/repos/vIiRuS/habitrpg/commits{/sha}","git_commits_url":"https://api.github.com/repos/vIiRuS/habitrpg/git/commits{/sha}","comments_url":"https://api.github.com/repos/vIiRuS/habitrpg/comments{/number}","issue_comment_url":"https://api.github.com/repos/vIiRuS/habitrpg/issues/comments{/number}","contents_url":"https://api.github.com/repos/vIiRuS/habitrpg/contents/{+path}","compare_url":"https://api.github.com/repos/vIiRuS/habitrpg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vIiRuS/habitrpg/merges","archive_url":"https://api.github.com/repos/vIiRuS/habitrpg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vIiRuS/habitrpg/downloads","issues_url":"https://api.github.com/repos/vIiRuS/habitrpg/issues{/number}","pulls_url":"https://api.github.com/repos/vIiRuS/habitrpg/pulls{/number}","milestones_url":"https://api.github.com/repos/vIiRuS/habitrpg/milestones{/number}","notifications_url":"https://api.github.com/repos/vIiRuS/habitrpg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vIiRuS/habitrpg/labels{/name}","releases_url":"https://api.github.com/repos/vIiRuS/habitrpg/releases{/id}","deployments_url":"https://api.github.com/repos/vIiRuS/habitrpg/deployments","created_at":"2013-12-31T17:43:20Z","updated_at":"2014-08-03T18:39:09Z","pushed_at":"2016-06-10T14:25:55Z","git_url":"git://github.com/vIiRuS/habitrpg.git","ssh_url":"git@github.com:vIiRuS/habitrpg.git","clone_url":"https://github.com/vIiRuS/habitrpg.git","svn_url":"https://github.com/vIiRuS/habitrpg","homepage":"habitrpg.com","size":381695,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"HabitRPG:develop","ref":"develop","sha":"441fba2ad04cd079dc291eb5ba495b94c655c19a","user":{"login":"HabitRPG","id":3834775,"avatar_url":"https://avatars.githubusercontent.com/u/3834775?v=3","gravatar_id":"","url":"https://api.github.com/users/HabitRPG","html_url":"https://github.com/HabitRPG","followers_url":"https://api.github.com/users/HabitRPG/followers","following_url":"https://api.github.com/users/HabitRPG/following{/other_user}","gists_url":"https://api.github.com/users/HabitRPG/gists{/gist_id}","starred_url":"https://api.github.com/users/HabitRPG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HabitRPG/subscriptions","organizations_url":"https://api.github.com/users/HabitRPG/orgs","repos_url":"https://api.github.com/users/HabitRPG/repos","events_url":"https://api.github.com/users/HabitRPG/events{/privacy}","received_events_url":"https://api.github.com/users/HabitRPG/received_events","type":"Organization","site_admin":false},"repo":{"id":4578898,"name":"habitrpg","full_name":"HabitRPG/habitrpg","owner":{"login":"HabitRPG","id":3834775,"avatar_url":"https://avatars.githubusercontent.com/u/3834775?v=3","gravatar_id":"","url":"https://api.github.com/users/HabitRPG","html_url":"https://github.com/HabitRPG","followers_url":"https://api.github.com/users/HabitRPG/followers","following_url":"https://api.github.com/users/HabitRPG/following{/other_user}","gists_url":"https://api.github.com/users/HabitRPG/gists{/gist_id}","starred_url":"https://api.github.com/users/HabitRPG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HabitRPG/subscriptions","organizations_url":"https://api.github.com/users/HabitRPG/orgs","repos_url":"https://api.github.com/users/HabitRPG/repos","events_url":"https://api.github.com/users/HabitRPG/events{/privacy}","received_events_url":"https://api.github.com/users/HabitRPG/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HabitRPG/habitrpg","description":"A habit tracker app which treats your goals like a Role Playing Game.","fork":false,"url":"https://api.github.com/repos/HabitRPG/habitrpg","forks_url":"https://api.github.com/repos/HabitRPG/habitrpg/forks","keys_url":"https://api.github.com/repos/HabitRPG/habitrpg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HabitRPG/habitrpg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HabitRPG/habitrpg/teams","hooks_url":"https://api.github.com/repos/HabitRPG/habitrpg/hooks","issue_events_url":"https://api.github.com/repos/HabitRPG/habitrpg/issues/events{/number}","events_url":"https://api.github.com/repos/HabitRPG/habitrpg/events","assignees_url":"https://api.github.com/repos/HabitRPG/habitrpg/assignees{/user}","branches_url":"https://api.github.com/repos/HabitRPG/habitrpg/branches{/branch}","tags_url":"https://api.github.com/repos/HabitRPG/habitrpg/tags","blobs_url":"https://api.github.com/repos/HabitRPG/habitrpg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HabitRPG/habitrpg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HabitRPG/habitrpg/git/refs{/sha}","trees_url":"https://api.github.com/repos/HabitRPG/habitrpg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HabitRPG/habitrpg/statuses/{sha}","languages_url":"https://api.github.com/repos/HabitRPG/habitrpg/languages","stargazers_url":"https://api.github.com/repos/HabitRPG/habitrpg/stargazers","contributors_url":"https://api.github.com/repos/HabitRPG/habitrpg/contributors","subscribers_url":"https://api.github.com/repos/HabitRPG/habitrpg/subscribers","subscription_url":"https://api.github.com/repos/HabitRPG/habitrpg/subscription","commits_url":"https://api.github.com/repos/HabitRPG/habitrpg/commits{/sha}","git_commits_url":"https://api.github.com/repos/HabitRPG/habitrpg/git/commits{/sha}","comments_url":"https://api.github.com/repos/HabitRPG/habitrpg/comments{/number}","issue_comment_url":"https://api.github.com/repos/HabitRPG/habitrpg/issues/comments{/number}","contents_url":"https://api.github.com/repos/HabitRPG/habitrpg/contents/{+path}","compare_url":"https://api.github.com/repos/HabitRPG/habitrpg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HabitRPG/habitrpg/merges","archive_url":"https://api.github.com/repos/HabitRPG/habitrpg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HabitRPG/habitrpg/downloads","issues_url":"https://api.github.com/repos/HabitRPG/habitrpg/issues{/number}","pulls_url":"https://api.github.com/repos/HabitRPG/habitrpg/pulls{/number}","milestones_url":"https://api.github.com/repos/HabitRPG/habitrpg/milestones{/number}","notifications_url":"https://api.github.com/repos/HabitRPG/habitrpg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HabitRPG/habitrpg/labels{/name}","releases_url":"https://api.github.com/repos/HabitRPG/habitrpg/releases{/id}","deployments_url":"https://api.github.com/repos/HabitRPG/habitrpg/deployments","created_at":"2012-06-06T22:49:48Z","updated_at":"2016-06-12T06:44:05Z","pushed_at":"2016-06-12T13:35:11Z","git_url":"git://github.com/HabitRPG/habitrpg.git","ssh_url":"git@github.com:HabitRPG/habitrpg.git","clone_url":"https://github.com/HabitRPG/habitrpg.git","svn_url":"https://github.com/HabitRPG/habitrpg","homepage":"https://habitica.com","size":449379,"stargazers_count":3925,"watchers_count":3925,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1648,"mirror_url":null,"open_issues_count":390,"forks":1648,"open_issues":390,"watchers":3925,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/HabitRPG/habitrpg/pulls/7642"},"html":{"href":"https://github.com/HabitRPG/habitrpg/pull/7642"},"issue":{"href":"https://api.github.com/repos/HabitRPG/habitrpg/issues/7642"},"comments":{"href":"https://api.github.com/repos/HabitRPG/habitrpg/issues/7642/comments"},"review_comments":{"href":"https://api.github.com/repos/HabitRPG/habitrpg/pulls/7642/comments"},"review_comment":{"href":"https://api.github.com/repos/HabitRPG/habitrpg/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/HabitRPG/habitrpg/pulls/7642/commits"},"statuses":{"href":"https://api.github.com/repos/HabitRPG/habitrpg/statuses/11f5b7fea8208ea0b7a3aa64bc243693392d21c4"}}}}
{"actor":{"display_login":"crookedneighbor"}}