{"action":"created","comment":{"url":"https://api.github.com/repos/getlarky/nudge-peen/pulls/comments/176117107","pull_request_review_id":105763711,"id":176117107,"diff_hunk":"@@ -0,0 +1,44 @@\n+const express = require('express');\n+const async = require('async');\n+const router = express.Router();\n+const Token = require('../models/token');\n+const fcmWrapper = require('../utils/fcmWrapper');\n+const utils = require('../utils/utils');\n+const config = require('../common').config()\n+\n+/* GET users listing. */\n+router.post('/sendMessage', function(req, res, next) {\n+    var postData = req.body;\n+    if (!postData.title || !postData.body || !postData.user_ids) {\n+        return res.status(500).send(\"You must include a title, body, and a list of user ids\");\n+    };\n+    if (typeof(postData.title) != \"string\" || typeof(postData.body) != \"string\") {\n+        return res.status(500).send(\"title and body must be strings\");\n+    };\n+    Token.selectByUserIds(postData.user_ids, (err, results) => {\n+        if (err) {\n+            return res.status(500).send(\"Error getting tokens from the database: \" + err);\n+        }\n+        let tokens = results.map(result => result.token);\n+        let batchedTokens = utils.batchArrayOfValues(tokens, config.fcmTokenLimit);\n+        let data = fcmWrapper.createMessageObject(postData.title, postData.body);\n+\n+        async.each(batchedTokens, (tokenBatch, cb) => {\n+            fcmWrapper.firebaseApp.messaging().sendToDevice(tokenBatch, data).then((response) => {\n+                cb();\n+                // TODO: Send error status to all impacted tokens.\n+            }).catch((err) => {\n+                console.log(\"Error with one batch: \" + err);\n+                // TODO: Send error status to all impacted tokens.\n+            });\n+        }, (err) =>{\n+            if (err) {\n+                return res.status(500).send(\"Error sending push notifications: err\")\n+            }\n+            return res.status(200).json(results);","path":"push/routes/messages.js","position":40,"original_position":38,"commit_id":"4feab524361a4b24722994a62398263fb4ed6ee8","original_commit_id":"b820847d9e5be039a1c834571e688a9148ef8ee0","user":{"login":"bromeostasis","id":3764641,"avatar_url":"https://avatars3.githubusercontent.com/u/3764641?v=4","gravatar_id":"","url":"https://api.github.com/users/bromeostasis","html_url":"https://github.com/bromeostasis","followers_url":"https://api.github.com/users/bromeostasis/followers","following_url":"https://api.github.com/users/bromeostasis/following{/other_user}","gists_url":"https://api.github.com/users/bromeostasis/gists{/gist_id}","starred_url":"https://api.github.com/users/bromeostasis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bromeostasis/subscriptions","organizations_url":"https://api.github.com/users/bromeostasis/orgs","repos_url":"https://api.github.com/users/bromeostasis/repos","events_url":"https://api.github.com/users/bromeostasis/events{/privacy}","received_events_url":"https://api.github.com/users/bromeostasis/received_events","type":"User","site_admin":false},"body":"@ishotjr I guess what makes sense to me is:\r\n\r\n1. Comment/fix on getlarky/nudge#29 if you agree it needs to be changed (since that hasn't been finished)\r\n1. Comment/update to getlarky/nudge#39 to adhere to getlarky/nudge#52 specs","created_at":"2018-03-21T15:08:52Z","updated_at":"2018-03-21T15:08:52Z","html_url":"https://github.com/getlarky/nudge-peen/pull/2#discussion_r176117107","pull_request_url":"https://api.github.com/repos/getlarky/nudge-peen/pulls/2","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/getlarky/nudge-peen/pulls/comments/176117107"},"html":{"href":"https://github.com/getlarky/nudge-peen/pull/2#discussion_r176117107"},"pull_request":{"href":"https://api.github.com/repos/getlarky/nudge-peen/pulls/2"}},"in_reply_to_id":175894811},"pull_request":{"url":"https://api.github.com/repos/getlarky/nudge-peen/pulls/2","id":166681717,"html_url":"https://github.com/getlarky/nudge-peen/pull/2","diff_url":"https://github.com/getlarky/nudge-peen/pull/2.diff","patch_url":"https://github.com/getlarky/nudge-peen/pull/2.patch","issue_url":"https://api.github.com/repos/getlarky/nudge-peen/issues/2","number":2,"state":"open","locked":false,"title":"nudge PEEN send notifications #27","user":{"login":"bromeostasis","id":3764641,"avatar_url":"https://avatars3.githubusercontent.com/u/3764641?v=4","gravatar_id":"","url":"https://api.github.com/users/bromeostasis","html_url":"https://github.com/bromeostasis","followers_url":"https://api.github.com/users/bromeostasis/followers","following_url":"https://api.github.com/users/bromeostasis/following{/other_user}","gists_url":"https://api.github.com/users/bromeostasis/gists{/gist_id}","starred_url":"https://api.github.com/users/bromeostasis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bromeostasis/subscriptions","organizations_url":"https://api.github.com/users/bromeostasis/orgs","repos_url":"https://api.github.com/users/bromeostasis/repos","events_url":"https://api.github.com/users/bromeostasis/events{/privacy}","received_events_url":"https://api.github.com/users/bromeostasis/received_events","type":"User","site_admin":false},"body":"Closes getlarky/nudge#27\r\n\r\nTesting [here](https://github.com/getlarky/nudge/issues/27#issuecomment-364453714)","created_at":"2018-02-01T23:35:08Z","updated_at":"2018-03-21T15:08:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"95f1c09aef5dbe7999aa8f2deb53c7eb4a76745c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/getlarky/nudge-peen/pulls/2/commits","review_comments_url":"https://api.github.com/repos/getlarky/nudge-peen/pulls/2/comments","review_comment_url":"https://api.github.com/repos/getlarky/nudge-peen/pulls/comments{/number}","comments_url":"https://api.github.com/repos/getlarky/nudge-peen/issues/2/comments","statuses_url":"https://api.github.com/repos/getlarky/nudge-peen/statuses/4feab524361a4b24722994a62398263fb4ed6ee8","head":{"label":"getlarky:27-send","ref":"27-send","sha":"4feab524361a4b24722994a62398263fb4ed6ee8","user":{"login":"getlarky","id":8038497,"avatar_url":"https://avatars1.githubusercontent.com/u/8038497?v=4","gravatar_id":"","url":"https://api.github.com/users/getlarky","html_url":"https://github.com/getlarky","followers_url":"https://api.github.com/users/getlarky/followers","following_url":"https://api.github.com/users/getlarky/following{/other_user}","gists_url":"https://api.github.com/users/getlarky/gists{/gist_id}","starred_url":"https://api.github.com/users/getlarky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getlarky/subscriptions","organizations_url":"https://api.github.com/users/getlarky/orgs","repos_url":"https://api.github.com/users/getlarky/repos","events_url":"https://api.github.com/users/getlarky/events{/privacy}","received_events_url":"https://api.github.com/users/getlarky/received_events","type":"Organization","site_admin":false},"repo":{"id":118965652,"name":"nudge-peen","full_name":"getlarky/nudge-peen","owner":{"login":"getlarky","id":8038497,"avatar_url":"https://avatars1.githubusercontent.com/u/8038497?v=4","gravatar_id":"","url":"https://api.github.com/users/getlarky","html_url":"https://github.com/getlarky","followers_url":"https://api.github.com/users/getlarky/followers","following_url":"https://api.github.com/users/getlarky/following{/other_user}","gists_url":"https://api.github.com/users/getlarky/gists{/gist_id}","starred_url":"https://api.github.com/users/getlarky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getlarky/subscriptions","organizations_url":"https://api.github.com/users/getlarky/orgs","repos_url":"https://api.github.com/users/getlarky/repos","events_url":"https://api.github.com/users/getlarky/events{/privacy}","received_events_url":"https://api.github.com/users/getlarky/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/getlarky/nudge-peen","description":"PEEN microservice for nudge!","fork":false,"url":"https://api.github.com/repos/getlarky/nudge-peen","forks_url":"https://api.github.com/repos/getlarky/nudge-peen/forks","keys_url":"https://api.github.com/repos/getlarky/nudge-peen/keys{/key_id}","collaborators_url":"https://api.github.com/repos/getlarky/nudge-peen/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/getlarky/nudge-peen/teams","hooks_url":"https://api.github.com/repos/getlarky/nudge-peen/hooks","issue_events_url":"https://api.github.com/repos/getlarky/nudge-peen/issues/events{/number}","events_url":"https://api.github.com/repos/getlarky/nudge-peen/events","assignees_url":"https://api.github.com/repos/getlarky/nudge-peen/assignees{/user}","branches_url":"https://api.github.com/repos/getlarky/nudge-peen/branches{/branch}","tags_url":"https://api.github.com/repos/getlarky/nudge-peen/tags","blobs_url":"https://api.github.com/repos/getlarky/nudge-peen/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/getlarky/nudge-peen/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/getlarky/nudge-peen/git/refs{/sha}","trees_url":"https://api.github.com/repos/getlarky/nudge-peen/git/trees{/sha}","statuses_url":"https://api.github.com/repos/getlarky/nudge-peen/statuses/{sha}","languages_url":"https://api.github.com/repos/getlarky/nudge-peen/languages","stargazers_url":"https://api.github.com/repos/getlarky/nudge-peen/stargazers","contributors_url":"https://api.github.com/repos/getlarky/nudge-peen/contributors","subscribers_url":"https://api.github.com/repos/getlarky/nudge-peen/subscribers","subscription_url":"https://api.github.com/repos/getlarky/nudge-peen/subscription","commits_url":"https://api.github.com/repos/getlarky/nudge-peen/commits{/sha}","git_commits_url":"https://api.github.com/repos/getlarky/nudge-peen/git/commits{/sha}","comments_url":"https://api.github.com/repos/getlarky/nudge-peen/comments{/number}","issue_comment_url":"https://api.github.com/repos/getlarky/nudge-peen/issues/comments{/number}","contents_url":"https://api.github.com/repos/getlarky/nudge-peen/contents/{+path}","compare_url":"https://api.github.com/repos/getlarky/nudge-peen/compare/{base}...{head}","merges_url":"https://api.github.com/repos/getlarky/nudge-peen/merges","archive_url":"https://api.github.com/repos/getlarky/nudge-peen/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/getlarky/nudge-peen/downloads","issues_url":"https://api.github.com/repos/getlarky/nudge-peen/issues{/number}","pulls_url":"https://api.github.com/repos/getlarky/nudge-peen/pulls{/number}","milestones_url":"https://api.github.com/repos/getlarky/nudge-peen/milestones{/number}","notifications_url":"https://api.github.com/repos/getlarky/nudge-peen/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/getlarky/nudge-peen/labels{/name}","releases_url":"https://api.github.com/repos/getlarky/nudge-peen/releases{/id}","deployments_url":"https://api.github.com/repos/getlarky/nudge-peen/deployments","created_at":"2018-01-25T20:44:19Z","updated_at":"2018-03-14T14:26:19Z","pushed_at":"2018-03-21T14:47:02Z","git_url":"git://github.com/getlarky/nudge-peen.git","ssh_url":"git@github.com:getlarky/nudge-peen.git","clone_url":"https://github.com/getlarky/nudge-peen.git","svn_url":"https://github.com/getlarky/nudge-peen","homepage":null,"size":261,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"getlarky:staging","ref":"staging","sha":"70f085c0523780362efcb354938fda81225313de","user":{"login":"getlarky","id":8038497,"avatar_url":"https://avatars1.githubusercontent.com/u/8038497?v=4","gravatar_id":"","url":"https://api.github.com/users/getlarky","html_url":"https://github.com/getlarky","followers_url":"https://api.github.com/users/getlarky/followers","following_url":"https://api.github.com/users/getlarky/following{/other_user}","gists_url":"https://api.github.com/users/getlarky/gists{/gist_id}","starred_url":"https://api.github.com/users/getlarky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getlarky/subscriptions","organizations_url":"https://api.github.com/users/getlarky/orgs","repos_url":"https://api.github.com/users/getlarky/repos","events_url":"https://api.github.com/users/getlarky/events{/privacy}","received_events_url":"https://api.github.com/users/getlarky/received_events","type":"Organization","site_admin":false},"repo":{"id":118965652,"name":"nudge-peen","full_name":"getlarky/nudge-peen","owner":{"login":"getlarky","id":8038497,"avatar_url":"https://avatars1.githubusercontent.com/u/8038497?v=4","gravatar_id":"","url":"https://api.github.com/users/getlarky","html_url":"https://github.com/getlarky","followers_url":"https://api.github.com/users/getlarky/followers","following_url":"https://api.github.com/users/getlarky/following{/other_user}","gists_url":"https://api.github.com/users/getlarky/gists{/gist_id}","starred_url":"https://api.github.com/users/getlarky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getlarky/subscriptions","organizations_url":"https://api.github.com/users/getlarky/orgs","repos_url":"https://api.github.com/users/getlarky/repos","events_url":"https://api.github.com/users/getlarky/events{/privacy}","received_events_url":"https://api.github.com/users/getlarky/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/getlarky/nudge-peen","description":"PEEN microservice for nudge!","fork":false,"url":"https://api.github.com/repos/getlarky/nudge-peen","forks_url":"https://api.github.com/repos/getlarky/nudge-peen/forks","keys_url":"https://api.github.com/repos/getlarky/nudge-peen/keys{/key_id}","collaborators_url":"https://api.github.com/repos/getlarky/nudge-peen/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/getlarky/nudge-peen/teams","hooks_url":"https://api.github.com/repos/getlarky/nudge-peen/hooks","issue_events_url":"https://api.github.com/repos/getlarky/nudge-peen/issues/events{/number}","events_url":"https://api.github.com/repos/getlarky/nudge-peen/events","assignees_url":"https://api.github.com/repos/getlarky/nudge-peen/assignees{/user}","branches_url":"https://api.github.com/repos/getlarky/nudge-peen/branches{/branch}","tags_url":"https://api.github.com/repos/getlarky/nudge-peen/tags","blobs_url":"https://api.github.com/repos/getlarky/nudge-peen/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/getlarky/nudge-peen/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/getlarky/nudge-peen/git/refs{/sha}","trees_url":"https://api.github.com/repos/getlarky/nudge-peen/git/trees{/sha}","statuses_url":"https://api.github.com/repos/getlarky/nudge-peen/statuses/{sha}","languages_url":"https://api.github.com/repos/getlarky/nudge-peen/languages","stargazers_url":"https://api.github.com/repos/getlarky/nudge-peen/stargazers","contributors_url":"https://api.github.com/repos/getlarky/nudge-peen/contributors","subscribers_url":"https://api.github.com/repos/getlarky/nudge-peen/subscribers","subscription_url":"https://api.github.com/repos/getlarky/nudge-peen/subscription","commits_url":"https://api.github.com/repos/getlarky/nudge-peen/commits{/sha}","git_commits_url":"https://api.github.com/repos/getlarky/nudge-peen/git/commits{/sha}","comments_url":"https://api.github.com/repos/getlarky/nudge-peen/comments{/number}","issue_comment_url":"https://api.github.com/repos/getlarky/nudge-peen/issues/comments{/number}","contents_url":"https://api.github.com/repos/getlarky/nudge-peen/contents/{+path}","compare_url":"https://api.github.com/repos/getlarky/nudge-peen/compare/{base}...{head}","merges_url":"https://api.github.com/repos/getlarky/nudge-peen/merges","archive_url":"https://api.github.com/repos/getlarky/nudge-peen/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/getlarky/nudge-peen/downloads","issues_url":"https://api.github.com/repos/getlarky/nudge-peen/issues{/number}","pulls_url":"https://api.github.com/repos/getlarky/nudge-peen/pulls{/number}","milestones_url":"https://api.github.com/repos/getlarky/nudge-peen/milestones{/number}","notifications_url":"https://api.github.com/repos/getlarky/nudge-peen/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/getlarky/nudge-peen/labels{/name}","releases_url":"https://api.github.com/repos/getlarky/nudge-peen/releases{/id}","deployments_url":"https://api.github.com/repos/getlarky/nudge-peen/deployments","created_at":"2018-01-25T20:44:19Z","updated_at":"2018-03-14T14:26:19Z","pushed_at":"2018-03-21T14:47:02Z","git_url":"git://github.com/getlarky/nudge-peen.git","ssh_url":"git@github.com:getlarky/nudge-peen.git","clone_url":"https://github.com/getlarky/nudge-peen.git","svn_url":"https://github.com/getlarky/nudge-peen","homepage":null,"size":261,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/getlarky/nudge-peen/pulls/2"},"html":{"href":"https://github.com/getlarky/nudge-peen/pull/2"},"issue":{"href":"https://api.github.com/repos/getlarky/nudge-peen/issues/2"},"comments":{"href":"https://api.github.com/repos/getlarky/nudge-peen/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/getlarky/nudge-peen/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/getlarky/nudge-peen/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/getlarky/nudge-peen/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/getlarky/nudge-peen/statuses/4feab524361a4b24722994a62398263fb4ed6ee8"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"bromeostasis"}}