{"action":"created","comment":{"url":"https://api.github.com/repos/atsid/permissive/pulls/comments/26172604","id":26172604,"diff_hunk":"@@ -8,54 +8,45 @@ module.exports = {\n         console.log('listing repos [' + req.path + ']');\n         console.log('query:' + JSON.stringify(req.query, null, 2));\n \n-        repoService.getRepos().then((repos) => {\n-            req.entity = repos.map((repo) => {\n-                return {\n-                    'id': repo.id,\n-                    'name': repo.name,\n-                    'description': repo.description,\n-                    'public': !repo.private\n-                };\n-            });\n-\n+        repoRepository.getRepos().then(repos => {\n+            req.entity = repos;\n             next();\n-\n-        }).catch((err) => {\n-            next(err);\n-        });\n+        }).catch(err => next(err));\n     },\n \n     listReposPermission (req, res, next) {\n         console.log('looking up user permission for repos');\n \n-        let user = req.query.permission_user,\n+        let username = req.query.permission_user,\n             repos = req.entity;\n \n-        if (user) {\n-            repos.forEach((repo) => {\n-                repo.permission = 'read';\n-            });\n+        if (username) {\n+            repoRepository.getPermissions(username, repos).then(repos => {\n+                req.entity = repos;\n+                next();\n+            }).catch(err => next(err));\n+        } else {\n+            next();\n         }\n-        next();\n     },\n \n     listReposLinks (req, res, next) {\n         console.log('checking for links on repo list');\n \n-        let user = req.query.permission_user,\n-            repos = req.entity;\n-\n-        if (user) {\n-            repos.forEach((repo) => {\n-                repo.links = [{\n-                    rel: 'edit-user-permission',\n-                    href: 'repos/' + repo.id + '/users/' + user + '/permissions/{permission}',\n-                    method: 'PUT'\n-                }, {\n-                    rel: 'remove-user-permission',\n-                    href: 'repos/' + repo.id + '/users/' + user,\n-                    method: 'DELETE'\n-                }];\n+        let repos = req.entity,\n+            username = req.query.permission_user,\n+            permissions; //TODO: get permissions got logged in uer\n+\n+        if (username && permissions) {\n+            repos.forEach(repo => {\n+                let permission = permissions[repo.id];\n+                if (permission.permissive === 'admin' || permission.github === 'admin') {","path":"app/server/middleware/repos.js","position":78,"original_position":78,"commit_id":"28f8a5d4736c2fb0c9bec24de98d6ee86a401634","original_commit_id":"28f8a5d4736c2fb0c9bec24de98d6ee86a401634","user":{"login":"natoverse","id":720083,"avatar_url":"https://avatars.githubusercontent.com/u/720083?v=3","gravatar_id":"","url":"https://api.github.com/users/natoverse","html_url":"https://github.com/natoverse","followers_url":"https://api.github.com/users/natoverse/followers","following_url":"https://api.github.com/users/natoverse/following{/other_user}","gists_url":"https://api.github.com/users/natoverse/gists{/gist_id}","starred_url":"https://api.github.com/users/natoverse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natoverse/subscriptions","organizations_url":"https://api.github.com/users/natoverse/orgs","repos_url":"https://api.github.com/users/natoverse/repos","events_url":"https://api.github.com/users/natoverse/events{/privacy}","received_events_url":"https://api.github.com/users/natoverse/received_events","type":"User","site_admin":false},"body":"Do you still need to get rid of this check?","created_at":"2015-03-10T22:21:50Z","updated_at":"2015-03-10T22:21:50Z","html_url":"https://github.com/atsid/permissive/pull/83#discussion_r26172604","pull_request_url":"https://api.github.com/repos/atsid/permissive/pulls/83","_links":{"self":{"href":"https://api.github.com/repos/atsid/permissive/pulls/comments/26172604"},"html":{"href":"https://github.com/atsid/permissive/pull/83#discussion_r26172604"},"pull_request":{"href":"https://api.github.com/repos/atsid/permissive/pulls/83"}}},"pull_request":{"url":"https://api.github.com/repos/atsid/permissive/pulls/83","id":30883068,"html_url":"https://github.com/atsid/permissive/pull/83","diff_url":"https://github.com/atsid/permissive/pull/83.diff","patch_url":"https://github.com/atsid/permissive/pull/83.patch","issue_url":"https://api.github.com/repos/atsid/permissive/issues/83","number":83,"state":"open","locked":false,"title":"20 read permissions","user":{"login":"joejaworski","id":4183578,"avatar_url":"https://avatars.githubusercontent.com/u/4183578?v=3","gravatar_id":"","url":"https://api.github.com/users/joejaworski","html_url":"https://github.com/joejaworski","followers_url":"https://api.github.com/users/joejaworski/followers","following_url":"https://api.github.com/users/joejaworski/following{/other_user}","gists_url":"https://api.github.com/users/joejaworski/gists{/gist_id}","starred_url":"https://api.github.com/users/joejaworski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joejaworski/subscriptions","organizations_url":"https://api.github.com/users/joejaworski/orgs","repos_url":"https://api.github.com/users/joejaworski/repos","events_url":"https://api.github.com/users/joejaworski/events{/privacy}","received_events_url":"https://api.github.com/users/joejaworski/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-10T19:17:02Z","updated_at":"2015-03-10T22:21:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"61bc2a5ccba597818c1bb04f2fd2c5174b95e886","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/atsid/permissive/pulls/83/commits","review_comments_url":"https://api.github.com/repos/atsid/permissive/pulls/83/comments","review_comment_url":"https://api.github.com/repos/atsid/permissive/pulls/comments{/number}","comments_url":"https://api.github.com/repos/atsid/permissive/issues/83/comments","statuses_url":"https://api.github.com/repos/atsid/permissive/statuses/28f8a5d4736c2fb0c9bec24de98d6ee86a401634","head":{"label":"atsid:20-github-team-permissions","ref":"20-github-team-permissions","sha":"28f8a5d4736c2fb0c9bec24de98d6ee86a401634","user":{"login":"atsid","id":3497915,"avatar_url":"https://avatars.githubusercontent.com/u/3497915?v=3","gravatar_id":"","url":"https://api.github.com/users/atsid","html_url":"https://github.com/atsid","followers_url":"https://api.github.com/users/atsid/followers","following_url":"https://api.github.com/users/atsid/following{/other_user}","gists_url":"https://api.github.com/users/atsid/gists{/gist_id}","starred_url":"https://api.github.com/users/atsid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atsid/subscriptions","organizations_url":"https://api.github.com/users/atsid/orgs","repos_url":"https://api.github.com/users/atsid/repos","events_url":"https://api.github.com/users/atsid/events{/privacy}","received_events_url":"https://api.github.com/users/atsid/received_events","type":"Organization","site_admin":false},"repo":{"id":31401396,"name":"permissive","full_name":"atsid/permissive","owner":{"login":"atsid","id":3497915,"avatar_url":"https://avatars.githubusercontent.com/u/3497915?v=3","gravatar_id":"","url":"https://api.github.com/users/atsid","html_url":"https://github.com/atsid","followers_url":"https://api.github.com/users/atsid/followers","following_url":"https://api.github.com/users/atsid/following{/other_user}","gists_url":"https://api.github.com/users/atsid/gists{/gist_id}","starred_url":"https://api.github.com/users/atsid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atsid/subscriptions","organizations_url":"https://api.github.com/users/atsid/orgs","repos_url":"https://api.github.com/users/atsid/repos","events_url":"https://api.github.com/users/atsid/events{/privacy}","received_events_url":"https://api.github.com/users/atsid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atsid/permissive","description":"Permissions management console and services","fork":false,"url":"https://api.github.com/repos/atsid/permissive","forks_url":"https://api.github.com/repos/atsid/permissive/forks","keys_url":"https://api.github.com/repos/atsid/permissive/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atsid/permissive/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atsid/permissive/teams","hooks_url":"https://api.github.com/repos/atsid/permissive/hooks","issue_events_url":"https://api.github.com/repos/atsid/permissive/issues/events{/number}","events_url":"https://api.github.com/repos/atsid/permissive/events","assignees_url":"https://api.github.com/repos/atsid/permissive/assignees{/user}","branches_url":"https://api.github.com/repos/atsid/permissive/branches{/branch}","tags_url":"https://api.github.com/repos/atsid/permissive/tags","blobs_url":"https://api.github.com/repos/atsid/permissive/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atsid/permissive/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atsid/permissive/git/refs{/sha}","trees_url":"https://api.github.com/repos/atsid/permissive/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atsid/permissive/statuses/{sha}","languages_url":"https://api.github.com/repos/atsid/permissive/languages","stargazers_url":"https://api.github.com/repos/atsid/permissive/stargazers","contributors_url":"https://api.github.com/repos/atsid/permissive/contributors","subscribers_url":"https://api.github.com/repos/atsid/permissive/subscribers","subscription_url":"https://api.github.com/repos/atsid/permissive/subscription","commits_url":"https://api.github.com/repos/atsid/permissive/commits{/sha}","git_commits_url":"https://api.github.com/repos/atsid/permissive/git/commits{/sha}","comments_url":"https://api.github.com/repos/atsid/permissive/comments{/number}","issue_comment_url":"https://api.github.com/repos/atsid/permissive/issues/comments{/number}","contents_url":"https://api.github.com/repos/atsid/permissive/contents/{+path}","compare_url":"https://api.github.com/repos/atsid/permissive/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atsid/permissive/merges","archive_url":"https://api.github.com/repos/atsid/permissive/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atsid/permissive/downloads","issues_url":"https://api.github.com/repos/atsid/permissive/issues{/number}","pulls_url":"https://api.github.com/repos/atsid/permissive/pulls{/number}","milestones_url":"https://api.github.com/repos/atsid/permissive/milestones{/number}","notifications_url":"https://api.github.com/repos/atsid/permissive/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atsid/permissive/labels{/name}","releases_url":"https://api.github.com/repos/atsid/permissive/releases{/id}","created_at":"2015-02-27T03:16:59Z","updated_at":"2015-03-10T20:25:09Z","pushed_at":"2015-03-10T21:58:57Z","git_url":"git://github.com/atsid/permissive.git","ssh_url":"git@github.com:atsid/permissive.git","clone_url":"https://github.com/atsid/permissive.git","svn_url":"https://github.com/atsid/permissive","homepage":null,"size":1073,"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":25,"forks":0,"open_issues":25,"watchers":0,"default_branch":"master"}},"base":{"label":"atsid:master","ref":"master","sha":"d8a77343b60e4b77f1e647b3a4122473f7373c0f","user":{"login":"atsid","id":3497915,"avatar_url":"https://avatars.githubusercontent.com/u/3497915?v=3","gravatar_id":"","url":"https://api.github.com/users/atsid","html_url":"https://github.com/atsid","followers_url":"https://api.github.com/users/atsid/followers","following_url":"https://api.github.com/users/atsid/following{/other_user}","gists_url":"https://api.github.com/users/atsid/gists{/gist_id}","starred_url":"https://api.github.com/users/atsid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atsid/subscriptions","organizations_url":"https://api.github.com/users/atsid/orgs","repos_url":"https://api.github.com/users/atsid/repos","events_url":"https://api.github.com/users/atsid/events{/privacy}","received_events_url":"https://api.github.com/users/atsid/received_events","type":"Organization","site_admin":false},"repo":{"id":31401396,"name":"permissive","full_name":"atsid/permissive","owner":{"login":"atsid","id":3497915,"avatar_url":"https://avatars.githubusercontent.com/u/3497915?v=3","gravatar_id":"","url":"https://api.github.com/users/atsid","html_url":"https://github.com/atsid","followers_url":"https://api.github.com/users/atsid/followers","following_url":"https://api.github.com/users/atsid/following{/other_user}","gists_url":"https://api.github.com/users/atsid/gists{/gist_id}","starred_url":"https://api.github.com/users/atsid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atsid/subscriptions","organizations_url":"https://api.github.com/users/atsid/orgs","repos_url":"https://api.github.com/users/atsid/repos","events_url":"https://api.github.com/users/atsid/events{/privacy}","received_events_url":"https://api.github.com/users/atsid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atsid/permissive","description":"Permissions management console and services","fork":false,"url":"https://api.github.com/repos/atsid/permissive","forks_url":"https://api.github.com/repos/atsid/permissive/forks","keys_url":"https://api.github.com/repos/atsid/permissive/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atsid/permissive/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atsid/permissive/teams","hooks_url":"https://api.github.com/repos/atsid/permissive/hooks","issue_events_url":"https://api.github.com/repos/atsid/permissive/issues/events{/number}","events_url":"https://api.github.com/repos/atsid/permissive/events","assignees_url":"https://api.github.com/repos/atsid/permissive/assignees{/user}","branches_url":"https://api.github.com/repos/atsid/permissive/branches{/branch}","tags_url":"https://api.github.com/repos/atsid/permissive/tags","blobs_url":"https://api.github.com/repos/atsid/permissive/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atsid/permissive/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atsid/permissive/git/refs{/sha}","trees_url":"https://api.github.com/repos/atsid/permissive/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atsid/permissive/statuses/{sha}","languages_url":"https://api.github.com/repos/atsid/permissive/languages","stargazers_url":"https://api.github.com/repos/atsid/permissive/stargazers","contributors_url":"https://api.github.com/repos/atsid/permissive/contributors","subscribers_url":"https://api.github.com/repos/atsid/permissive/subscribers","subscription_url":"https://api.github.com/repos/atsid/permissive/subscription","commits_url":"https://api.github.com/repos/atsid/permissive/commits{/sha}","git_commits_url":"https://api.github.com/repos/atsid/permissive/git/commits{/sha}","comments_url":"https://api.github.com/repos/atsid/permissive/comments{/number}","issue_comment_url":"https://api.github.com/repos/atsid/permissive/issues/comments{/number}","contents_url":"https://api.github.com/repos/atsid/permissive/contents/{+path}","compare_url":"https://api.github.com/repos/atsid/permissive/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atsid/permissive/merges","archive_url":"https://api.github.com/repos/atsid/permissive/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atsid/permissive/downloads","issues_url":"https://api.github.com/repos/atsid/permissive/issues{/number}","pulls_url":"https://api.github.com/repos/atsid/permissive/pulls{/number}","milestones_url":"https://api.github.com/repos/atsid/permissive/milestones{/number}","notifications_url":"https://api.github.com/repos/atsid/permissive/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atsid/permissive/labels{/name}","releases_url":"https://api.github.com/repos/atsid/permissive/releases{/id}","created_at":"2015-02-27T03:16:59Z","updated_at":"2015-03-10T20:25:09Z","pushed_at":"2015-03-10T21:58:57Z","git_url":"git://github.com/atsid/permissive.git","ssh_url":"git@github.com:atsid/permissive.git","clone_url":"https://github.com/atsid/permissive.git","svn_url":"https://github.com/atsid/permissive","homepage":null,"size":1073,"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":25,"forks":0,"open_issues":25,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/atsid/permissive/pulls/83"},"html":{"href":"https://github.com/atsid/permissive/pull/83"},"issue":{"href":"https://api.github.com/repos/atsid/permissive/issues/83"},"comments":{"href":"https://api.github.com/repos/atsid/permissive/issues/83/comments"},"review_comments":{"href":"https://api.github.com/repos/atsid/permissive/pulls/83/comments"},"review_comment":{"href":"https://api.github.com/repos/atsid/permissive/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/atsid/permissive/pulls/83/commits"},"statuses":{"href":"https://api.github.com/repos/atsid/permissive/statuses/28f8a5d4736c2fb0c9bec24de98d6ee86a401634"}}}}