{"action":"created","comment":{"url":"https://api.github.com/repos/nandarustam/fcm-push/pulls/comments/76513398","id":76513398,"diff_hunk":"@@ -20,89 +21,96 @@ function FCM(serverKey) {\n     };\r\n }\r\n \r\n-module.exports = FCM;\r\n+util.inherits(FCM, emitter);\r\n \r\n FCM.prototype.send = function(payload, CB) {\r\n     var self = this;\r\n     if (CB) this.once('sent', CB);\r\n \r\n-    var operation = retry.operation();\r\n-\r\n-    payload = JSON.stringify(payload);\r\n-\r\n-    operation.attempt(function(currentAttempt) {\r\n-        var headers = {\r\n-            'Host': self.fcmOptions.host,\r\n-            'Authorization': 'key=' + self.serverKey,\r\n-            'Content-Type': 'application/json',\r\n-            'Content-Length': new Buffer(payload).length\r\n-        };\r\n-\r\n-        self.fcmOptions.headers = headers;\r\n-\r\n-        if (self.keepAlive) headers.Connection = 'keep-alive';\r\n-\r\n-        var request = https.request(self.fcmOptions, function(res) {\r\n-            var data = '';\r\n-\r\n-\r\n-            if (res.statusCode == 503) {\r\n-                // If the server is temporary unavailable, the C2DM spec requires that we implement exponential backoff\r\n-                // and respect any Retry-After header\r\n-                if (res.headers['retry-after']) {\r\n-                    var retrySeconds = res.headers['retry-after'] * 1; // force number\r\n-                    if (isNaN(retrySeconds)) {\r\n-                        // The Retry-After header is a HTTP-date, try to parse it\r\n-                        retrySeconds = new Date(res.headers['retry-after']).getTime() - new Date().getTime();\r\n+    return new Promise(function(resolve,reject){\r","path":"lib/fcm.js","position":47,"original_position":47,"commit_id":"13c82b372b2d9edb311ba1f5c837eb8883768110","original_commit_id":"13c82b372b2d9edb311ba1f5c837eb8883768110","user":{"login":"abihf","id":1484485,"avatar_url":"https://avatars.githubusercontent.com/u/1484485?v=3","gravatar_id":"","url":"https://api.github.com/users/abihf","html_url":"https://github.com/abihf","followers_url":"https://api.github.com/users/abihf/followers","following_url":"https://api.github.com/users/abihf/following{/other_user}","gists_url":"https://api.github.com/users/abihf/gists{/gist_id}","starred_url":"https://api.github.com/users/abihf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abihf/subscriptions","organizations_url":"https://api.github.com/users/abihf/orgs","repos_url":"https://api.github.com/users/abihf/repos","events_url":"https://api.github.com/users/abihf/events{/privacy}","received_events_url":"https://api.github.com/users/abihf/received_events","type":"User","site_admin":false},"body":"I think you shuld return promise if only callback is null or undefined.\r\n\r\nalternative code: \r\n```js\r\nif (cb) this.once('sent', cb);\r\nelse if (FCM.Promise) return new FCM.Promise(function (resolve, reject) {\r\n  self.once('sent', function(err, response) {\r\n    if (err) reject(err);\r\n    else resolve(response);\r\n  });\r\n});\r\nelse throw new Error(...)\r\n...\r\n\r\nif (typeof Promise == 'function') FCM.Promise = Promise;\r\n```\r\n\r\nthis will let user select what promise library they wanna use.","created_at":"2016-08-27T09:21:52Z","updated_at":"2016-08-27T09:21:52Z","html_url":"https://github.com/nandarustam/fcm-push/pull/6#discussion_r76513398","pull_request_url":"https://api.github.com/repos/nandarustam/fcm-push/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/nandarustam/fcm-push/pulls/comments/76513398"},"html":{"href":"https://github.com/nandarustam/fcm-push/pull/6#discussion_r76513398"},"pull_request":{"href":"https://api.github.com/repos/nandarustam/fcm-push/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/nandarustam/fcm-push/pulls/6","id":75942264,"html_url":"https://github.com/nandarustam/fcm-push/pull/6","diff_url":"https://github.com/nandarustam/fcm-push/pull/6.diff","patch_url":"https://github.com/nandarustam/fcm-push/pull/6.patch","issue_url":"https://api.github.com/repos/nandarustam/fcm-push/issues/6","number":6,"state":"open","locked":false,"title":"multicast handler, promise style","user":{"login":"ans-4175","id":3961872,"avatar_url":"https://avatars.githubusercontent.com/u/3961872?v=3","gravatar_id":"","url":"https://api.github.com/users/ans-4175","html_url":"https://github.com/ans-4175","followers_url":"https://api.github.com/users/ans-4175/followers","following_url":"https://api.github.com/users/ans-4175/following{/other_user}","gists_url":"https://api.github.com/users/ans-4175/gists{/gist_id}","starred_url":"https://api.github.com/users/ans-4175/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ans-4175/subscriptions","organizations_url":"https://api.github.com/users/ans-4175/orgs","repos_url":"https://api.github.com/users/ans-4175/repos","events_url":"https://api.github.com/users/ans-4175/events{/privacy}","received_events_url":"https://api.github.com/users/ans-4175/received_events","type":"User","site_admin":false},"body":"I have added Promise style for send function, using bluebird module. I also put handler for `multicast_id`. But yet, still figuring out what's issue around send to topic. Kindly check this out.","created_at":"2016-07-01T08:08:54Z","updated_at":"2016-08-27T09:21:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a91a103ab5899bf90dcf467e69a66d3bb33dc8cc","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nandarustam/fcm-push/pulls/6/commits","review_comments_url":"https://api.github.com/repos/nandarustam/fcm-push/pulls/6/comments","review_comment_url":"https://api.github.com/repos/nandarustam/fcm-push/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nandarustam/fcm-push/issues/6/comments","statuses_url":"https://api.github.com/repos/nandarustam/fcm-push/statuses/13c82b372b2d9edb311ba1f5c837eb8883768110","head":{"label":"eFishery:dev/bug","ref":"dev/bug","sha":"13c82b372b2d9edb311ba1f5c837eb8883768110","user":{"login":"eFishery","id":17191662,"avatar_url":"https://avatars.githubusercontent.com/u/17191662?v=3","gravatar_id":"","url":"https://api.github.com/users/eFishery","html_url":"https://github.com/eFishery","followers_url":"https://api.github.com/users/eFishery/followers","following_url":"https://api.github.com/users/eFishery/following{/other_user}","gists_url":"https://api.github.com/users/eFishery/gists{/gist_id}","starred_url":"https://api.github.com/users/eFishery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eFishery/subscriptions","organizations_url":"https://api.github.com/users/eFishery/orgs","repos_url":"https://api.github.com/users/eFishery/repos","events_url":"https://api.github.com/users/eFishery/events{/privacy}","received_events_url":"https://api.github.com/users/eFishery/received_events","type":"Organization","site_admin":false},"repo":{"id":62367982,"name":"fcm-push-notif","full_name":"eFishery/fcm-push-notif","owner":{"login":"eFishery","id":17191662,"avatar_url":"https://avatars.githubusercontent.com/u/17191662?v=3","gravatar_id":"","url":"https://api.github.com/users/eFishery","html_url":"https://github.com/eFishery","followers_url":"https://api.github.com/users/eFishery/followers","following_url":"https://api.github.com/users/eFishery/following{/other_user}","gists_url":"https://api.github.com/users/eFishery/gists{/gist_id}","starred_url":"https://api.github.com/users/eFishery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eFishery/subscriptions","organizations_url":"https://api.github.com/users/eFishery/orgs","repos_url":"https://api.github.com/users/eFishery/repos","events_url":"https://api.github.com/users/eFishery/events{/privacy}","received_events_url":"https://api.github.com/users/eFishery/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eFishery/fcm-push-notif","description":"A Node.JS simple interface to Firebase Cloud Messaging (FCM) for Android & iOS","fork":true,"url":"https://api.github.com/repos/eFishery/fcm-push-notif","forks_url":"https://api.github.com/repos/eFishery/fcm-push-notif/forks","keys_url":"https://api.github.com/repos/eFishery/fcm-push-notif/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eFishery/fcm-push-notif/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eFishery/fcm-push-notif/teams","hooks_url":"https://api.github.com/repos/eFishery/fcm-push-notif/hooks","issue_events_url":"https://api.github.com/repos/eFishery/fcm-push-notif/issues/events{/number}","events_url":"https://api.github.com/repos/eFishery/fcm-push-notif/events","assignees_url":"https://api.github.com/repos/eFishery/fcm-push-notif/assignees{/user}","branches_url":"https://api.github.com/repos/eFishery/fcm-push-notif/branches{/branch}","tags_url":"https://api.github.com/repos/eFishery/fcm-push-notif/tags","blobs_url":"https://api.github.com/repos/eFishery/fcm-push-notif/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eFishery/fcm-push-notif/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eFishery/fcm-push-notif/git/refs{/sha}","trees_url":"https://api.github.com/repos/eFishery/fcm-push-notif/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eFishery/fcm-push-notif/statuses/{sha}","languages_url":"https://api.github.com/repos/eFishery/fcm-push-notif/languages","stargazers_url":"https://api.github.com/repos/eFishery/fcm-push-notif/stargazers","contributors_url":"https://api.github.com/repos/eFishery/fcm-push-notif/contributors","subscribers_url":"https://api.github.com/repos/eFishery/fcm-push-notif/subscribers","subscription_url":"https://api.github.com/repos/eFishery/fcm-push-notif/subscription","commits_url":"https://api.github.com/repos/eFishery/fcm-push-notif/commits{/sha}","git_commits_url":"https://api.github.com/repos/eFishery/fcm-push-notif/git/commits{/sha}","comments_url":"https://api.github.com/repos/eFishery/fcm-push-notif/comments{/number}","issue_comment_url":"https://api.github.com/repos/eFishery/fcm-push-notif/issues/comments{/number}","contents_url":"https://api.github.com/repos/eFishery/fcm-push-notif/contents/{+path}","compare_url":"https://api.github.com/repos/eFishery/fcm-push-notif/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eFishery/fcm-push-notif/merges","archive_url":"https://api.github.com/repos/eFishery/fcm-push-notif/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eFishery/fcm-push-notif/downloads","issues_url":"https://api.github.com/repos/eFishery/fcm-push-notif/issues{/number}","pulls_url":"https://api.github.com/repos/eFishery/fcm-push-notif/pulls{/number}","milestones_url":"https://api.github.com/repos/eFishery/fcm-push-notif/milestones{/number}","notifications_url":"https://api.github.com/repos/eFishery/fcm-push-notif/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eFishery/fcm-push-notif/labels{/name}","releases_url":"https://api.github.com/repos/eFishery/fcm-push-notif/releases{/id}","deployments_url":"https://api.github.com/repos/eFishery/fcm-push-notif/deployments","created_at":"2016-07-01T06:07:29Z","updated_at":"2016-08-22T02:14:20Z","pushed_at":"2016-07-01T09:30:53Z","git_url":"git://github.com/eFishery/fcm-push-notif.git","ssh_url":"git@github.com:eFishery/fcm-push-notif.git","clone_url":"https://github.com/eFishery/fcm-push-notif.git","svn_url":"https://github.com/eFishery/fcm-push-notif","homepage":null,"size":16,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"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":5,"default_branch":"master"}},"base":{"label":"nandarustam:master","ref":"master","sha":"11ff54b87fcf2c036a07ced050ec68c5f5dffe52","user":{"login":"nandarustam","id":4226047,"avatar_url":"https://avatars.githubusercontent.com/u/4226047?v=3","gravatar_id":"","url":"https://api.github.com/users/nandarustam","html_url":"https://github.com/nandarustam","followers_url":"https://api.github.com/users/nandarustam/followers","following_url":"https://api.github.com/users/nandarustam/following{/other_user}","gists_url":"https://api.github.com/users/nandarustam/gists{/gist_id}","starred_url":"https://api.github.com/users/nandarustam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nandarustam/subscriptions","organizations_url":"https://api.github.com/users/nandarustam/orgs","repos_url":"https://api.github.com/users/nandarustam/repos","events_url":"https://api.github.com/users/nandarustam/events{/privacy}","received_events_url":"https://api.github.com/users/nandarustam/received_events","type":"User","site_admin":false},"repo":{"id":59269533,"name":"fcm-push","full_name":"nandarustam/fcm-push","owner":{"login":"nandarustam","id":4226047,"avatar_url":"https://avatars.githubusercontent.com/u/4226047?v=3","gravatar_id":"","url":"https://api.github.com/users/nandarustam","html_url":"https://github.com/nandarustam","followers_url":"https://api.github.com/users/nandarustam/followers","following_url":"https://api.github.com/users/nandarustam/following{/other_user}","gists_url":"https://api.github.com/users/nandarustam/gists{/gist_id}","starred_url":"https://api.github.com/users/nandarustam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nandarustam/subscriptions","organizations_url":"https://api.github.com/users/nandarustam/orgs","repos_url":"https://api.github.com/users/nandarustam/repos","events_url":"https://api.github.com/users/nandarustam/events{/privacy}","received_events_url":"https://api.github.com/users/nandarustam/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nandarustam/fcm-push","description":"A Node.JS simple interface to Firebase Cloud Messaging (FCM) for Android & iOS","fork":false,"url":"https://api.github.com/repos/nandarustam/fcm-push","forks_url":"https://api.github.com/repos/nandarustam/fcm-push/forks","keys_url":"https://api.github.com/repos/nandarustam/fcm-push/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nandarustam/fcm-push/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nandarustam/fcm-push/teams","hooks_url":"https://api.github.com/repos/nandarustam/fcm-push/hooks","issue_events_url":"https://api.github.com/repos/nandarustam/fcm-push/issues/events{/number}","events_url":"https://api.github.com/repos/nandarustam/fcm-push/events","assignees_url":"https://api.github.com/repos/nandarustam/fcm-push/assignees{/user}","branches_url":"https://api.github.com/repos/nandarustam/fcm-push/branches{/branch}","tags_url":"https://api.github.com/repos/nandarustam/fcm-push/tags","blobs_url":"https://api.github.com/repos/nandarustam/fcm-push/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nandarustam/fcm-push/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nandarustam/fcm-push/git/refs{/sha}","trees_url":"https://api.github.com/repos/nandarustam/fcm-push/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nandarustam/fcm-push/statuses/{sha}","languages_url":"https://api.github.com/repos/nandarustam/fcm-push/languages","stargazers_url":"https://api.github.com/repos/nandarustam/fcm-push/stargazers","contributors_url":"https://api.github.com/repos/nandarustam/fcm-push/contributors","subscribers_url":"https://api.github.com/repos/nandarustam/fcm-push/subscribers","subscription_url":"https://api.github.com/repos/nandarustam/fcm-push/subscription","commits_url":"https://api.github.com/repos/nandarustam/fcm-push/commits{/sha}","git_commits_url":"https://api.github.com/repos/nandarustam/fcm-push/git/commits{/sha}","comments_url":"https://api.github.com/repos/nandarustam/fcm-push/comments{/number}","issue_comment_url":"https://api.github.com/repos/nandarustam/fcm-push/issues/comments{/number}","contents_url":"https://api.github.com/repos/nandarustam/fcm-push/contents/{+path}","compare_url":"https://api.github.com/repos/nandarustam/fcm-push/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nandarustam/fcm-push/merges","archive_url":"https://api.github.com/repos/nandarustam/fcm-push/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nandarustam/fcm-push/downloads","issues_url":"https://api.github.com/repos/nandarustam/fcm-push/issues{/number}","pulls_url":"https://api.github.com/repos/nandarustam/fcm-push/pulls{/number}","milestones_url":"https://api.github.com/repos/nandarustam/fcm-push/milestones{/number}","notifications_url":"https://api.github.com/repos/nandarustam/fcm-push/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nandarustam/fcm-push/labels{/name}","releases_url":"https://api.github.com/repos/nandarustam/fcm-push/releases{/id}","deployments_url":"https://api.github.com/repos/nandarustam/fcm-push/deployments","created_at":"2016-05-20T06:10:37Z","updated_at":"2016-08-26T18:55:14Z","pushed_at":"2016-07-01T09:09:48Z","git_url":"git://github.com/nandarustam/fcm-push.git","ssh_url":"git@github.com:nandarustam/fcm-push.git","clone_url":"https://github.com/nandarustam/fcm-push.git","svn_url":"https://github.com/nandarustam/fcm-push","homepage":null,"size":9,"stargazers_count":28,"watchers_count":28,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":4,"forks":12,"open_issues":4,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nandarustam/fcm-push/pulls/6"},"html":{"href":"https://github.com/nandarustam/fcm-push/pull/6"},"issue":{"href":"https://api.github.com/repos/nandarustam/fcm-push/issues/6"},"comments":{"href":"https://api.github.com/repos/nandarustam/fcm-push/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/nandarustam/fcm-push/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/nandarustam/fcm-push/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nandarustam/fcm-push/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/nandarustam/fcm-push/statuses/13c82b372b2d9edb311ba1f5c837eb8883768110"}}}}
{"actor":{"display_login":"abihf"}}