{"action":"created","comment":{"url":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls/comments/77110170","id":77110170,"diff_hunk":"@@ -84,28 +86,37 @@ function sendToFeedbackChannel(body, response) {\n //   \"endTimeToken\": \"00000\"}\n \n Parse.Cloud.define(\"replayEvents\", function(request, response) {\n-    var requiredParams = [\"aliasId\", \"subkey\"];\n+    var requiredParams = [\"aliasId\"];\n     var params = request.params;\n     checkMissingParams(params, requiredParams, response);\n \n-    var count = params.count ? params.count : 9999;\n-    var aliasId = params.aliasId;\n+    var count = params.count || 20;\n     var subkey = params.subkey;\n+    var startTimeToken = params.startTimeToken ?\n+        new Moment(params.startTimeToken).toDate() : new Moment().toDate();\n+    var endTimeToken = params.endTimeToken ? new Moment(params.endTimeToken).toDate() : undefined;\n+    var aliasId = params.aliasId;\n \n-    Alias.get(params.aliasId).then(function(alias) {\n-        var chatRoomId = alias.get(\"chatRoomId\");\n-        var startTimeToken = params.startTimeToken\n-            ? params.startTimeToken\n-            : new Date().getTime() * 10000;\n-        var endTimeToken = params.endTimeToken;\n-\n-        Pubnub.replayChannel({subkey: subkey,\n-                              channel: chatRoomId,\n-                              startTimeToken: startTimeToken,\n-                              endTimeToken: endTimeToken,\n-                              count: count\n-                             }).then(response.success, response.error);\n-    }, response.error);\n+    ChatEvent.getChatEvents(aliasId, startTimeToken, count, endTimeToken).then(function(chatEvents) {\n+        var startTimeToken = chatEvents.length > 0 ?\n+            new Moment(chatEvents[0].get(\"createdAt\")).toISOString() : undefined;\n+        var endTimeToken = chatEvents.length > 0 ?","path":"cloud/main.js","position":44,"original_position":44,"commit_id":"d8b8c4118483918b592f3b07ba2d55861e365a0a","original_commit_id":"d8b8c4118483918b592f3b07ba2d55861e365a0a","user":{"login":"tonyjhuang","id":1237337,"avatar_url":"https://avatars.githubusercontent.com/u/1237337?v=3","gravatar_id":"","url":"https://api.github.com/users/tonyjhuang","html_url":"https://github.com/tonyjhuang","followers_url":"https://api.github.com/users/tonyjhuang/followers","following_url":"https://api.github.com/users/tonyjhuang/following{/other_user}","gists_url":"https://api.github.com/users/tonyjhuang/gists{/gist_id}","starred_url":"https://api.github.com/users/tonyjhuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonyjhuang/subscriptions","organizations_url":"https://api.github.com/users/tonyjhuang/orgs","repos_url":"https://api.github.com/users/tonyjhuang/repos","events_url":"https://api.github.com/users/tonyjhuang/events{/privacy}","received_events_url":"https://api.github.com/users/tonyjhuang/received_events","type":"User","site_admin":false},"body":"how would you do this then?\r\n","created_at":"2016-09-01T03:41:35Z","updated_at":"2016-09-01T03:41:35Z","html_url":"https://github.com/tonyjhuang/CheddarParse/pull/44#discussion_r77110170","pull_request_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls/44","_links":{"self":{"href":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls/comments/77110170"},"html":{"href":"https://github.com/tonyjhuang/CheddarParse/pull/44#discussion_r77110170"},"pull_request":{"href":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls/44"}}},"pull_request":{"url":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls/44","id":83564620,"html_url":"https://github.com/tonyjhuang/CheddarParse/pull/44","diff_url":"https://github.com/tonyjhuang/CheddarParse/pull/44.diff","patch_url":"https://github.com/tonyjhuang/CheddarParse/pull/44.patch","issue_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/issues/44","number":44,"state":"open","locked":false,"title":"use parse to replay chatevents instead of pubnub","user":{"login":"tonyjhuang","id":1237337,"avatar_url":"https://avatars.githubusercontent.com/u/1237337?v=3","gravatar_id":"","url":"https://api.github.com/users/tonyjhuang","html_url":"https://github.com/tonyjhuang","followers_url":"https://api.github.com/users/tonyjhuang/followers","following_url":"https://api.github.com/users/tonyjhuang/following{/other_user}","gists_url":"https://api.github.com/users/tonyjhuang/gists{/gist_id}","starred_url":"https://api.github.com/users/tonyjhuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonyjhuang/subscriptions","organizations_url":"https://api.github.com/users/tonyjhuang/orgs","repos_url":"https://api.github.com/users/tonyjhuang/repos","events_url":"https://api.github.com/users/tonyjhuang/events{/privacy}","received_events_url":"https://api.github.com/users/tonyjhuang/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-01T03:23:21Z","updated_at":"2016-09-01T03:41:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bf02a6c6c8ddd0635e52390151065aa9d1aad4de","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls/44/commits","review_comments_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls/44/comments","review_comment_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/issues/44/comments","statuses_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/statuses/d8b8c4118483918b592f3b07ba2d55861e365a0a","head":{"label":"tonyjhuang:dev","ref":"dev","sha":"d8b8c4118483918b592f3b07ba2d55861e365a0a","user":{"login":"tonyjhuang","id":1237337,"avatar_url":"https://avatars.githubusercontent.com/u/1237337?v=3","gravatar_id":"","url":"https://api.github.com/users/tonyjhuang","html_url":"https://github.com/tonyjhuang","followers_url":"https://api.github.com/users/tonyjhuang/followers","following_url":"https://api.github.com/users/tonyjhuang/following{/other_user}","gists_url":"https://api.github.com/users/tonyjhuang/gists{/gist_id}","starred_url":"https://api.github.com/users/tonyjhuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonyjhuang/subscriptions","organizations_url":"https://api.github.com/users/tonyjhuang/orgs","repos_url":"https://api.github.com/users/tonyjhuang/repos","events_url":"https://api.github.com/users/tonyjhuang/events{/privacy}","received_events_url":"https://api.github.com/users/tonyjhuang/received_events","type":"User","site_admin":false},"repo":{"id":51718369,"name":"CheddarParse","full_name":"tonyjhuang/CheddarParse","owner":{"login":"tonyjhuang","id":1237337,"avatar_url":"https://avatars.githubusercontent.com/u/1237337?v=3","gravatar_id":"","url":"https://api.github.com/users/tonyjhuang","html_url":"https://github.com/tonyjhuang","followers_url":"https://api.github.com/users/tonyjhuang/followers","following_url":"https://api.github.com/users/tonyjhuang/following{/other_user}","gists_url":"https://api.github.com/users/tonyjhuang/gists{/gist_id}","starred_url":"https://api.github.com/users/tonyjhuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonyjhuang/subscriptions","organizations_url":"https://api.github.com/users/tonyjhuang/orgs","repos_url":"https://api.github.com/users/tonyjhuang/repos","events_url":"https://api.github.com/users/tonyjhuang/events{/privacy}","received_events_url":"https://api.github.com/users/tonyjhuang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tonyjhuang/CheddarParse","description":"","fork":false,"url":"https://api.github.com/repos/tonyjhuang/CheddarParse","forks_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/forks","keys_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/teams","hooks_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/hooks","issue_events_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/issues/events{/number}","events_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/events","assignees_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/assignees{/user}","branches_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/branches{/branch}","tags_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/tags","blobs_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/git/refs{/sha}","trees_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/statuses/{sha}","languages_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/languages","stargazers_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/stargazers","contributors_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/contributors","subscribers_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/subscribers","subscription_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/subscription","commits_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/commits{/sha}","git_commits_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/git/commits{/sha}","comments_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/comments{/number}","issue_comment_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/issues/comments{/number}","contents_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/contents/{+path}","compare_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/merges","archive_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/downloads","issues_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/issues{/number}","pulls_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls{/number}","milestones_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/milestones{/number}","notifications_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/labels{/name}","releases_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/releases{/id}","deployments_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/deployments","created_at":"2016-02-14T23:00:30Z","updated_at":"2016-02-14T23:00:54Z","pushed_at":"2016-09-01T03:23:21Z","git_url":"git://github.com/tonyjhuang/CheddarParse.git","ssh_url":"git@github.com:tonyjhuang/CheddarParse.git","clone_url":"https://github.com/tonyjhuang/CheddarParse.git","svn_url":"https://github.com/tonyjhuang/CheddarParse","homepage":null,"size":220,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"tonyjhuang:master","ref":"master","sha":"bf6f6f521f3881d93c507b4bb0907e4ee5bbf49d","user":{"login":"tonyjhuang","id":1237337,"avatar_url":"https://avatars.githubusercontent.com/u/1237337?v=3","gravatar_id":"","url":"https://api.github.com/users/tonyjhuang","html_url":"https://github.com/tonyjhuang","followers_url":"https://api.github.com/users/tonyjhuang/followers","following_url":"https://api.github.com/users/tonyjhuang/following{/other_user}","gists_url":"https://api.github.com/users/tonyjhuang/gists{/gist_id}","starred_url":"https://api.github.com/users/tonyjhuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonyjhuang/subscriptions","organizations_url":"https://api.github.com/users/tonyjhuang/orgs","repos_url":"https://api.github.com/users/tonyjhuang/repos","events_url":"https://api.github.com/users/tonyjhuang/events{/privacy}","received_events_url":"https://api.github.com/users/tonyjhuang/received_events","type":"User","site_admin":false},"repo":{"id":51718369,"name":"CheddarParse","full_name":"tonyjhuang/CheddarParse","owner":{"login":"tonyjhuang","id":1237337,"avatar_url":"https://avatars.githubusercontent.com/u/1237337?v=3","gravatar_id":"","url":"https://api.github.com/users/tonyjhuang","html_url":"https://github.com/tonyjhuang","followers_url":"https://api.github.com/users/tonyjhuang/followers","following_url":"https://api.github.com/users/tonyjhuang/following{/other_user}","gists_url":"https://api.github.com/users/tonyjhuang/gists{/gist_id}","starred_url":"https://api.github.com/users/tonyjhuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonyjhuang/subscriptions","organizations_url":"https://api.github.com/users/tonyjhuang/orgs","repos_url":"https://api.github.com/users/tonyjhuang/repos","events_url":"https://api.github.com/users/tonyjhuang/events{/privacy}","received_events_url":"https://api.github.com/users/tonyjhuang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tonyjhuang/CheddarParse","description":"","fork":false,"url":"https://api.github.com/repos/tonyjhuang/CheddarParse","forks_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/forks","keys_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/teams","hooks_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/hooks","issue_events_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/issues/events{/number}","events_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/events","assignees_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/assignees{/user}","branches_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/branches{/branch}","tags_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/tags","blobs_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/git/refs{/sha}","trees_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/statuses/{sha}","languages_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/languages","stargazers_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/stargazers","contributors_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/contributors","subscribers_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/subscribers","subscription_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/subscription","commits_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/commits{/sha}","git_commits_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/git/commits{/sha}","comments_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/comments{/number}","issue_comment_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/issues/comments{/number}","contents_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/contents/{+path}","compare_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/merges","archive_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/downloads","issues_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/issues{/number}","pulls_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls{/number}","milestones_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/milestones{/number}","notifications_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/labels{/name}","releases_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/releases{/id}","deployments_url":"https://api.github.com/repos/tonyjhuang/CheddarParse/deployments","created_at":"2016-02-14T23:00:30Z","updated_at":"2016-02-14T23:00:54Z","pushed_at":"2016-09-01T03:23:21Z","git_url":"git://github.com/tonyjhuang/CheddarParse.git","ssh_url":"git@github.com:tonyjhuang/CheddarParse.git","clone_url":"https://github.com/tonyjhuang/CheddarParse.git","svn_url":"https://github.com/tonyjhuang/CheddarParse","homepage":null,"size":220,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls/44"},"html":{"href":"https://github.com/tonyjhuang/CheddarParse/pull/44"},"issue":{"href":"https://api.github.com/repos/tonyjhuang/CheddarParse/issues/44"},"comments":{"href":"https://api.github.com/repos/tonyjhuang/CheddarParse/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tonyjhuang/CheddarParse/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/tonyjhuang/CheddarParse/statuses/d8b8c4118483918b592f3b07ba2d55861e365a0a"}}}}
{"actor":{"display_login":"tonyjhuang"}}