GitHub PullRequestReviewCommentEvent at 2014-07-10 17:41:45
Repository: webmaker-events-service
Actor: gvn
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls/comments/14780912","id":14780912,"diff_hunk":"@@ -1,101 +1,131 @@\n module.exports = function(db, userClient) {\n   return {\n-    rsvp: {\n-      get: {\n-        // /rsvp/event/:id\n-        event: function(req, res) {\n-          var eventID = parseInt(req.params.id, 10);\n-          var eventData;\n-          var coorganizers = [];\n-          var user = req.session.user;\n-\n-          // Grab attendee info if it's public, requesting user is admin/coorg, or user created event\n-\n-          db.event.find({\n-            where: {\n-              id: eventID\n-            },\n-            include: [ db.coorg, db.attendee ]\n-          })\n-          .then(function success (event) {\n-            if (!event) {\n-              res.send(404);\n-            } else {\n-              eventData = event.dataValues;\n-            }\n-\n-            eventData.coorganizers.forEach(function (coorg, index) {\n-              coorganizers.push(coorg.dataValues.userId);\n-            });\n+    get: {\n+      // /attendee/event/:id\n+      event: function(req, res) {\n+        var eventID = parseInt(req.params.id, 10);\n+        var eventData;\n+        var coorganizers = [];\n+        var user = req.session.user;\n+\n+        // Grab attendee info if it's public, requesting user is admin/coorg, or user created event\n+\n+        db.event.find({\n+          where: {\n+            id: eventID\n+          },\n+          include: [ db.coorg, db.attendee ]\n+        })\n+        .then(function success (event) {\n+          if (!event) {\n+            res.send(404);\n+          } else {\n+            eventData = event.dataValues;\n+          }\n+\n+          eventData.coorganizers.forEach(function (coorg, index) {\n+            coorganizers.push(coorg.dataValues.userId);\n+          });\n \n-            if (eventData.areAttendeesPublic ||\n-              (user && (user.isAdmin || user.username === eventData.organizerId || coorganizers.indexOf(user.id) > -1))) {\n+          if (eventData.areAttendeesPublic ||\n+            (user && (user.isAdmin || user.username === eventData.organizerId || coorganizers.indexOf(user.id) > -1))) {\n \n-              var userIDs = [];\n-              var userHash = {};\n+            var userIDs = [];\n+            var userHash = {};\n+            var unregisteredUsers = [];\n \n-              eventData.attendees.forEach(function (attendee) {\n+            eventData.attendees.forEach(function (attendee) {\n+              if (attendee.userID) {\n                 userIDs.push(attendee.userID);\n                 userHash[attendee.userID] = attendee.dataValues;\n-              });\n-\n-              // Get usernames and avatars from user IDs\n+              } else {\n+                unregisteredUsers.push(attendee);\n+              }\n+            });\n \n-              userClient.get.byIds(userIDs, function (err, users) {\n-                if (err) {\n-                  res.send(500, 'Login service is down.');\n-                } else {\n-                  users.users.forEach(function (user) {\n-                    userHash[user.id].username = user.username;\n-                    userHash[user.id].avatar = user.avatar;\n-                  });\n+            // Get usernames and avatars from user IDs\n \n-                  var userArray = [];\n+            userClient.get.byIds(userIDs, function (err, users) {\n+              if (err) {\n+                res.send(500, 'Login service is down.');\n+              } else {\n+                users.users.forEach(function (user) {\n+                  userHash[user.id].username = user.username;\n+                  userHash[user.id].avatar = user.avatar;\n+                });\n \n-                  for (var key in userHash) {\n-                    userArray.push(userHash[key]);\n-                  }\n+                var userArray = [];\n \n-                  res.json(userArray);\n+                for (var key in userHash) {\n+                  userArray.push(userHash[key]);\n                 }\n-              });\n-            } else {\n-              res.send(401);\n-            }\n-          }, function fail() {\n-            res.send(500);\n-          });\n-        },\n-        // /rsvp/user/:id\n-        user: function(req, res) {\n-          var userID = parseInt(req.params.id, 10);\n-\n-          if (req.session.user && req.session.user.id === userID) {\n-            db.attendee\n-              .findAll({\n-                where: {\n-                  userID: userID\n-                }\n-              })\n-              .then(function success(result) {\n-                res.json(result);\n-              }, function failure(err) {\n-                res.send(500);\n-              });\n \n+                userArray = userArray.concat(unregisteredUsers);\n+\n+                res.json(userArray);\n+              }\n+            });\n           } else {\n-            res.send(401, 'Not authorized.');\n+            res.send(401);\n           }\n-        }\n+        }, function fail() {\n+          res.send(500);\n+        });\n       },\n-      // /rsvp/?userid=USERNAME&eventid=EVENTID\n-      post: function(req, res) {\n-        var userID = parseInt(req.query.userid, 10);\n-        var eventID = parseInt(req.query.eventid, 10);\n+      // /attendee/user/:id\n+      user: function(req, res) {\n+        var userID = parseInt(req.params.id, 10);\n+\n+        if (req.session.user && (req.session.user.isAdmin || req.session.user.id === userID)) {\n+          db.attendee\n+            .findAll({\n+              where: {\n+                userID: userID\n+              }\n+            })\n+            .then(function success(result) {\n+              res.json(result);\n+            }, function failure(err) {\n+              res.send(500);\n+            });\n+\n+        } else {\n+          res.send(401, 'Not authorized.');\n+        }\n+      }\n+    },\n+    // /attendee/?userid=USERNAME&eventid=EVENTID&checkin=true&rsvp=false\n+    post: function(req, res) {\n+      // Like parseInt, but...for boolean-like strings\n+      function parseBool(boolean) {\n+        return boolean === 'true' || boolean === '1' ? true : false;\n+      }\n+\n+      var userID = parseInt(req.query.userid, 10);\n+      var eventID = parseInt(req.query.eventid, 10);\n+      var email = req.query.email;\n+      var didAttend = req.query.checkin ? parseBool(req.query.checkin) : undefined;","path":"routes/attendee-controller.js","position":185,"original_position":185,"commit_id":"99f76324f41a92e299cd997bf37dd2bacb3d9350","original_commit_id":"99f76324f41a92e299cd997bf37dd2bacb3d9350","user":{"login":"gvn","id":206379,"avatar_url":"https://avatars.githubusercontent.com/u/206379?","gravatar_id":"66ecb14b59f8fc3b4bf421d69f0a1ea1","url":"https://api.github.com/users/gvn","html_url":"https://github.com/gvn","followers_url":"https://api.github.com/users/gvn/followers","following_url":"https://api.github.com/users/gvn/following{/other_user}","gists_url":"https://api.github.com/users/gvn/gists{/gist_id}","starred_url":"https://api.github.com/users/gvn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvn/subscriptions","organizations_url":"https://api.github.com/users/gvn/orgs","repos_url":"https://api.github.com/users/gvn/repos","events_url":"https://api.github.com/users/gvn/events{/privacy}","received_events_url":"https://api.github.com/users/gvn/received_events","type":"User","site_admin":false},"body":"It doesn't, unless I'm using it wrong. It interprets any string to a true boolean in the db.","created_at":"2014-07-10T17:41:45Z","updated_at":"2014-07-10T17:41:45Z","html_url":"https://github.com/mozilla/webmaker-events-service/pull/52#discussion_r14780912","pull_request_url":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls/52","_links":{"self":{"href":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls/comments/14780912"},"html":{"href":"https://github.com/mozilla/webmaker-events-service/pull/52#discussion_r14780912"},"pull_request":{"href":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls/52"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls/52","id":18074355,"html_url":"https://github.com/mozilla/webmaker-events-service/pull/52","diff_url":"https://github.com/mozilla/webmaker-events-service/pull/52.diff","patch_url":"https://github.com/mozilla/webmaker-events-service/pull/52.patch","issue_url":"https://api.github.com/repos/mozilla/webmaker-events-service/issues/52","number":52,"state":"open","title":"Refactor RSVP route to /attendee (Add checkin support, etc)","user":{"login":"gvn","id":206379,"avatar_url":"https://avatars.githubusercontent.com/u/206379?","gravatar_id":"66ecb14b59f8fc3b4bf421d69f0a1ea1","url":"https://api.github.com/users/gvn","html_url":"https://github.com/gvn","followers_url":"https://api.github.com/users/gvn/followers","following_url":"https://api.github.com/users/gvn/following{/other_user}","gists_url":"https://api.github.com/users/gvn/gists{/gist_id}","starred_url":"https://api.github.com/users/gvn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvn/subscriptions","organizations_url":"https://api.github.com/users/gvn/orgs","repos_url":"https://api.github.com/users/gvn/repos","events_url":"https://api.github.com/users/gvn/events{/privacy}","received_events_url":"https://api.github.com/users/gvn/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-07-07T22:56:45Z","updated_at":"2014-07-10T17:41:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bbf3a23f120d95970281fe509926fb47c3d2c0d4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls/52/commits","review_comments_url":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls/52/comments","review_comment_url":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mozilla/webmaker-events-service/issues/52/comments","statuses_url":"https://api.github.com/repos/mozilla/webmaker-events-service/statuses/99f76324f41a92e299cd997bf37dd2bacb3d9350","head":{"label":"gvn:1003940","ref":"1003940","sha":"99f76324f41a92e299cd997bf37dd2bacb3d9350","user":{"login":"gvn","id":206379,"avatar_url":"https://avatars.githubusercontent.com/u/206379?","gravatar_id":"66ecb14b59f8fc3b4bf421d69f0a1ea1","url":"https://api.github.com/users/gvn","html_url":"https://github.com/gvn","followers_url":"https://api.github.com/users/gvn/followers","following_url":"https://api.github.com/users/gvn/following{/other_user}","gists_url":"https://api.github.com/users/gvn/gists{/gist_id}","starred_url":"https://api.github.com/users/gvn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvn/subscriptions","organizations_url":"https://api.github.com/users/gvn/orgs","repos_url":"https://api.github.com/users/gvn/repos","events_url":"https://api.github.com/users/gvn/events{/privacy}","received_events_url":"https://api.github.com/users/gvn/received_events","type":"User","site_admin":false},"repo":{"id":16705223,"name":"webmaker-events-service","full_name":"gvn/webmaker-events-service","owner":{"login":"gvn","id":206379,"avatar_url":"https://avatars.githubusercontent.com/u/206379?","gravatar_id":"66ecb14b59f8fc3b4bf421d69f0a1ea1","url":"https://api.github.com/users/gvn","html_url":"https://github.com/gvn","followers_url":"https://api.github.com/users/gvn/followers","following_url":"https://api.github.com/users/gvn/following{/other_user}","gists_url":"https://api.github.com/users/gvn/gists{/gist_id}","starred_url":"https://api.github.com/users/gvn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvn/subscriptions","organizations_url":"https://api.github.com/users/gvn/orgs","repos_url":"https://api.github.com/users/gvn/repos","events_url":"https://api.github.com/users/gvn/events{/privacy}","received_events_url":"https://api.github.com/users/gvn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gvn/webmaker-events-service","description":null,"fork":true,"url":"https://api.github.com/repos/gvn/webmaker-events-service","forks_url":"https://api.github.com/repos/gvn/webmaker-events-service/forks","keys_url":"https://api.github.com/repos/gvn/webmaker-events-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gvn/webmaker-events-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gvn/webmaker-events-service/teams","hooks_url":"https://api.github.com/repos/gvn/webmaker-events-service/hooks","issue_events_url":"https://api.github.com/repos/gvn/webmaker-events-service/issues/events{/number}","events_url":"https://api.github.com/repos/gvn/webmaker-events-service/events","assignees_url":"https://api.github.com/repos/gvn/webmaker-events-service/assignees{/user}","branches_url":"https://api.github.com/repos/gvn/webmaker-events-service/branches{/branch}","tags_url":"https://api.github.com/repos/gvn/webmaker-events-service/tags","blobs_url":"https://api.github.com/repos/gvn/webmaker-events-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gvn/webmaker-events-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gvn/webmaker-events-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/gvn/webmaker-events-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gvn/webmaker-events-service/statuses/{sha}","languages_url":"https://api.github.com/repos/gvn/webmaker-events-service/languages","stargazers_url":"https://api.github.com/repos/gvn/webmaker-events-service/stargazers","contributors_url":"https://api.github.com/repos/gvn/webmaker-events-service/contributors","subscribers_url":"https://api.github.com/repos/gvn/webmaker-events-service/subscribers","subscription_url":"https://api.github.com/repos/gvn/webmaker-events-service/subscription","commits_url":"https://api.github.com/repos/gvn/webmaker-events-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/gvn/webmaker-events-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/gvn/webmaker-events-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/gvn/webmaker-events-service/issues/comments/{number}","contents_url":"https://api.github.com/repos/gvn/webmaker-events-service/contents/{+path}","compare_url":"https://api.github.com/repos/gvn/webmaker-events-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gvn/webmaker-events-service/merges","archive_url":"https://api.github.com/repos/gvn/webmaker-events-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gvn/webmaker-events-service/downloads","issues_url":"https://api.github.com/repos/gvn/webmaker-events-service/issues{/number}","pulls_url":"https://api.github.com/repos/gvn/webmaker-events-service/pulls{/number}","milestones_url":"https://api.github.com/repos/gvn/webmaker-events-service/milestones{/number}","notifications_url":"https://api.github.com/repos/gvn/webmaker-events-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gvn/webmaker-events-service/labels{/name}","releases_url":"https://api.github.com/repos/gvn/webmaker-events-service/releases{/id}","created_at":"2014-02-10T18:45:23Z","updated_at":"2014-06-24T22:35:56Z","pushed_at":"2014-07-09T23:19:43Z","git_url":"git://github.com/gvn/webmaker-events-service.git","ssh_url":"git@github.com:gvn/webmaker-events-service.git","clone_url":"https://github.com/gvn/webmaker-events-service.git","svn_url":"https://github.com/gvn/webmaker-events-service","homepage":null,"size":974,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"6ad74662868f22db121201e82142e9574d07a852","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?","gravatar_id":"9ba739c8f3288e256b13553e4d257b5e","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":15916148,"name":"webmaker-events-service","full_name":"mozilla/webmaker-events-service","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?","gravatar_id":"9ba739c8f3288e256b13553e4d257b5e","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/webmaker-events-service","description":"","fork":false,"url":"https://api.github.com/repos/mozilla/webmaker-events-service","forks_url":"https://api.github.com/repos/mozilla/webmaker-events-service/forks","keys_url":"https://api.github.com/repos/mozilla/webmaker-events-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/webmaker-events-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/webmaker-events-service/teams","hooks_url":"https://api.github.com/repos/mozilla/webmaker-events-service/hooks","issue_events_url":"https://api.github.com/repos/mozilla/webmaker-events-service/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/webmaker-events-service/events","assignees_url":"https://api.github.com/repos/mozilla/webmaker-events-service/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/webmaker-events-service/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/webmaker-events-service/tags","blobs_url":"https://api.github.com/repos/mozilla/webmaker-events-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/webmaker-events-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/webmaker-events-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/webmaker-events-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/webmaker-events-service/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/webmaker-events-service/languages","stargazers_url":"https://api.github.com/repos/mozilla/webmaker-events-service/stargazers","contributors_url":"https://api.github.com/repos/mozilla/webmaker-events-service/contributors","subscribers_url":"https://api.github.com/repos/mozilla/webmaker-events-service/subscribers","subscription_url":"https://api.github.com/repos/mozilla/webmaker-events-service/subscription","commits_url":"https://api.github.com/repos/mozilla/webmaker-events-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/webmaker-events-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/webmaker-events-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/webmaker-events-service/issues/comments/{number}","contents_url":"https://api.github.com/repos/mozilla/webmaker-events-service/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/webmaker-events-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/webmaker-events-service/merges","archive_url":"https://api.github.com/repos/mozilla/webmaker-events-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/webmaker-events-service/downloads","issues_url":"https://api.github.com/repos/mozilla/webmaker-events-service/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/webmaker-events-service/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/webmaker-events-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/webmaker-events-service/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/webmaker-events-service/releases{/id}","created_at":"2014-01-14T21:29:04Z","updated_at":"2014-06-25T20:16:33Z","pushed_at":"2014-07-10T16:55:19Z","git_url":"git://github.com/mozilla/webmaker-events-service.git","ssh_url":"git@github.com:mozilla/webmaker-events-service.git","clone_url":"https://github.com/mozilla/webmaker-events-service.git","svn_url":"https://github.com/mozilla/webmaker-events-service","homepage":"https://events-api.webmaker.org","size":2552,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":9,"mirror_url":null,"open_issues_count":7,"forks":9,"open_issues":7,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls/52"},"html":{"href":"https://github.com/mozilla/webmaker-events-service/pull/52"},"issue":{"href":"https://api.github.com/repos/mozilla/webmaker-events-service/issues/52"},"comments":{"href":"https://api.github.com/repos/mozilla/webmaker-events-service/issues/52/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls/52/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mozilla/webmaker-events-service/pulls/52/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/webmaker-events-service/statuses/99f76324f41a92e299cd997bf37dd2bacb3d9350"}}}}