{"action":"created","comment":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments/40948683","id":40948683,"diff_hunk":"@@ -5,36 +5,51 @@ class ReportAbuseController < ApplicationController\n   AGE_CUSTOM_FIELD_ID = 24024923\n \n   def report_abuse\n-    HTTParty.post('https://codeorg.zendesk.com/api/v2/tickets.json',\n-      headers: {\"Content-Type\" => \"application/json\", \"Accept\" => \"application/json\"},\n-      body: {\n-        ticket: {\n-          requester: {\n-            name: (params[:name] == '' ? params[:email] : params[:name]),\n-            email: params[:email]\n-          },\n-          subject: 'Abuse Reported',\n-          comment: {\n-            body: [\"URL: #{params[:abuse_url]}\",\n-              \"abuse type: #{params[:abuse_type]}\",\n-              \"user detail:\",\n-              \"#{params[:abuse_detail]}\"].join(\"\\n\")\n-          },\n-          custom_fields: [ { id: AGE_CUSTOM_FIELD_ID, value: params[:age] }],\n-          tags: (params[:abuse_type] == 'infringement' ? ['report_abuse', 'infringement'] : ['report_abuse'])\n-        }\n-      }.to_json,\n-      basic_auth: { username: 'dev@code.org/token', password: Dashboard::Application.config.zendesk_dev_token})\n+    unless Rails.env.development?\n+      HTTParty.post('https://codeorg.zendesk.com/api/v2/tickets.json',\n+        headers: {\"Content-Type\" => \"application/json\", \"Accept\" => \"application/json\"},\n+        body: {\n+          ticket: {\n+            requester: {\n+              name: (params[:name] == '' ? params[:email] : params[:name]),\n+              email: params[:email]\n+            },\n+            subject: 'Abuse Reported',\n+            comment: {\n+              body: [\"URL: #{params[:abuse_url]}\",\n+                \"abuse type: #{params[:abuse_type]}\",\n+                \"user detail:\",\n+                \"#{params[:abuse_detail]}\"].join(\"\\n\")\n+            },\n+            custom_fields: [ { id: AGE_CUSTOM_FIELD_ID, value: params[:age] }],\n+            tags: (params[:abuse_type] == 'infringement' ? ['report_abuse', 'infringement'] : ['report_abuse'])\n+          }\n+        }.to_json,\n+        basic_auth: { username: 'dev@code.org/token', password: Dashboard::Application.config.zendesk_dev_token})\n+    end\n \n     unless params[:channel_id].blank?\n       channels_path = \"/v3/channels/#{params[:channel_id]}/abuse\"\n+      assets_path = \"/v3/assets/#{params[:channel_id]}\"\n \n-      ChannelsApi.call(\n+      _, _, body = ChannelsApi.call(\n         'REQUEST_METHOD' => 'POST',\n         'PATH_INFO' => channels_path,\n         'REQUEST_PATH' => channels_path,\n+        'HTTP_COOKIE' => request.env['HTTP_COOKIE'],\n         'rack.input' => StringIO.new()\n         )\n+\n+      abuse_score = JSON.parse(body[0])[\"abuse_score\"]\n+\n+      FilesApi.call(","path":"dashboard/app/controllers/report_abuse_controller.rb","position":62,"original_position":62,"commit_id":"fac3ccf7b308a6d7527326ca9ecf3205409883c0","original_commit_id":"fac3ccf7b308a6d7527326ca9ecf3205409883c0","user":{"login":"davidsbailey","id":8001765,"avatar_url":"https://avatars.githubusercontent.com/u/8001765?v=3","gravatar_id":"","url":"https://api.github.com/users/davidsbailey","html_url":"https://github.com/davidsbailey","followers_url":"https://api.github.com/users/davidsbailey/followers","following_url":"https://api.github.com/users/davidsbailey/following{/other_user}","gists_url":"https://api.github.com/users/davidsbailey/gists{/gist_id}","starred_url":"https://api.github.com/users/davidsbailey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidsbailey/subscriptions","organizations_url":"https://api.github.com/users/davidsbailey/orgs","repos_url":"https://api.github.com/users/davidsbailey/repos","events_url":"https://api.github.com/users/davidsbailey/events{/privacy}","received_events_url":"https://api.github.com/users/davidsbailey/received_events","type":"User","site_admin":false},"body":"oops, I mean `AssetBucket.new. replace_abuse_score(...)`","created_at":"2015-10-01T18:28:06Z","updated_at":"2015-10-01T18:28:06Z","html_url":"https://github.com/code-dot-org/code-dot-org/pull/4278#discussion_r40948683","pull_request_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/4278","_links":{"self":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments/40948683"},"html":{"href":"https://github.com/code-dot-org/code-dot-org/pull/4278#discussion_r40948683"},"pull_request":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/4278"}}},"pull_request":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/4278","id":46469137,"html_url":"https://github.com/code-dot-org/code-dot-org/pull/4278","diff_url":"https://github.com/code-dot-org/code-dot-org/pull/4278.diff","patch_url":"https://github.com/code-dot-org/code-dot-org/pull/4278.patch","issue_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/4278","number":4278,"state":"open","locked":false,"title":"[Finishes #103047632] Block assets in abusive projects","user":{"login":"Bjvanminnen","id":1767466,"avatar_url":"https://avatars.githubusercontent.com/u/1767466?v=3","gravatar_id":"","url":"https://api.github.com/users/Bjvanminnen","html_url":"https://github.com/Bjvanminnen","followers_url":"https://api.github.com/users/Bjvanminnen/followers","following_url":"https://api.github.com/users/Bjvanminnen/following{/other_user}","gists_url":"https://api.github.com/users/Bjvanminnen/gists{/gist_id}","starred_url":"https://api.github.com/users/Bjvanminnen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bjvanminnen/subscriptions","organizations_url":"https://api.github.com/users/Bjvanminnen/orgs","repos_url":"https://api.github.com/users/Bjvanminnen/repos","events_url":"https://api.github.com/users/Bjvanminnen/events{/privacy}","received_events_url":"https://api.github.com/users/Bjvanminnen/received_events","type":"User","site_admin":false},"body":"We want to make it so that when a project is marked as abusive, in addition to the project being blocked, any assets associated with that project are blocked (unless you are the owner, an admin, or a teacher of the owner). Furthermore, we want to do this without non-abusive projects needing to incur any additional cost.\r\n\r\nWe accomplish this by storing abuse_score as metadata on the asset. When a project is marked as abusive, we go through and mark all associated assets. Same thing when abuse is cleared by an admin. In addition, we block the user from adding assets to an abusive project. This is only enforced at the UI level rather than the API level\r\n![image](https://cloud.githubusercontent.com/assets/1767466/10209272/8fd2ebca-678e-11e5-9f87-a914c68a2f6a.png)\r\n\r\nTesting\r\n---------\r\n1) Student creates a project with assets in it\r\n2) Anonymous user goes to share link and reports abuse.\r\nValidate:\r\n- Anonymous user cannot view /view page or share page\r\n- Anonymous user gets 404 if they try to access asset directly\r\n- Teacher/admin/owner are all still able to access asset directly\r\n\r\n3) Admin reset abuse\r\nValidate:\r\n- Anonymous user can now see the project, and the asset if the navigate directly to it","created_at":"2015-09-30T23:16:49Z","updated_at":"2015-10-01T18:28:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2c3912822aa147d59da0c203742cf00929074790","assignee":{"login":"davidsbailey","id":8001765,"avatar_url":"https://avatars.githubusercontent.com/u/8001765?v=3","gravatar_id":"","url":"https://api.github.com/users/davidsbailey","html_url":"https://github.com/davidsbailey","followers_url":"https://api.github.com/users/davidsbailey/followers","following_url":"https://api.github.com/users/davidsbailey/following{/other_user}","gists_url":"https://api.github.com/users/davidsbailey/gists{/gist_id}","starred_url":"https://api.github.com/users/davidsbailey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidsbailey/subscriptions","organizations_url":"https://api.github.com/users/davidsbailey/orgs","repos_url":"https://api.github.com/users/davidsbailey/repos","events_url":"https://api.github.com/users/davidsbailey/events{/privacy}","received_events_url":"https://api.github.com/users/davidsbailey/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/4278/commits","review_comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/4278/comments","review_comment_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments{/number}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/4278/comments","statuses_url":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/fac3ccf7b308a6d7527326ca9ecf3205409883c0","head":{"label":"code-dot-org:abusedAssets","ref":"abusedAssets","sha":"fac3ccf7b308a6d7527326ca9ecf3205409883c0","user":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"repo":{"id":24250009,"name":"code-dot-org","full_name":"code-dot-org/code-dot-org","owner":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/code-dot-org/code-dot-org","description":"The code powering code.org and studio.code.org","fork":false,"url":"https://api.github.com/repos/code-dot-org/code-dot-org","forks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/forks","keys_url":"https://api.github.com/repos/code-dot-org/code-dot-org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/code-dot-org/code-dot-org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/code-dot-org/code-dot-org/teams","hooks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/hooks","issue_events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/events{/number}","events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/events","assignees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/assignees{/user}","branches_url":"https://api.github.com/repos/code-dot-org/code-dot-org/branches{/branch}","tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/tags","blobs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/refs{/sha}","trees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/{sha}","languages_url":"https://api.github.com/repos/code-dot-org/code-dot-org/languages","stargazers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/stargazers","contributors_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contributors","subscribers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscribers","subscription_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscription","commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/commits{/sha}","git_commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/commits{/sha}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/comments{/number}","issue_comment_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/comments{/number}","contents_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contents/{+path}","compare_url":"https://api.github.com/repos/code-dot-org/code-dot-org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/code-dot-org/code-dot-org/merges","archive_url":"https://api.github.com/repos/code-dot-org/code-dot-org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/code-dot-org/code-dot-org/downloads","issues_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues{/number}","pulls_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls{/number}","milestones_url":"https://api.github.com/repos/code-dot-org/code-dot-org/milestones{/number}","notifications_url":"https://api.github.com/repos/code-dot-org/code-dot-org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/code-dot-org/code-dot-org/labels{/name}","releases_url":"https://api.github.com/repos/code-dot-org/code-dot-org/releases{/id}","created_at":"2014-09-20T00:46:11Z","updated_at":"2015-09-16T14:46:10Z","pushed_at":"2015-10-01T18:23:39Z","git_url":"git://github.com/code-dot-org/code-dot-org.git","ssh_url":"git@github.com:code-dot-org/code-dot-org.git","clone_url":"https://github.com/code-dot-org/code-dot-org.git","svn_url":"https://github.com/code-dot-org/code-dot-org","homepage":"http://code.org","size":2799787,"stargazers_count":58,"watchers_count":58,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":43,"forks":38,"open_issues":43,"watchers":58,"default_branch":"staging"}},"base":{"label":"code-dot-org:staging","ref":"staging","sha":"f305061d0a423755fd6100fa8e60acd9f022e9b2","user":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"repo":{"id":24250009,"name":"code-dot-org","full_name":"code-dot-org/code-dot-org","owner":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/code-dot-org/code-dot-org","description":"The code powering code.org and studio.code.org","fork":false,"url":"https://api.github.com/repos/code-dot-org/code-dot-org","forks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/forks","keys_url":"https://api.github.com/repos/code-dot-org/code-dot-org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/code-dot-org/code-dot-org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/code-dot-org/code-dot-org/teams","hooks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/hooks","issue_events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/events{/number}","events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/events","assignees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/assignees{/user}","branches_url":"https://api.github.com/repos/code-dot-org/code-dot-org/branches{/branch}","tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/tags","blobs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/refs{/sha}","trees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/{sha}","languages_url":"https://api.github.com/repos/code-dot-org/code-dot-org/languages","stargazers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/stargazers","contributors_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contributors","subscribers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscribers","subscription_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscription","commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/commits{/sha}","git_commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/commits{/sha}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/comments{/number}","issue_comment_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/comments{/number}","contents_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contents/{+path}","compare_url":"https://api.github.com/repos/code-dot-org/code-dot-org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/code-dot-org/code-dot-org/merges","archive_url":"https://api.github.com/repos/code-dot-org/code-dot-org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/code-dot-org/code-dot-org/downloads","issues_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues{/number}","pulls_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls{/number}","milestones_url":"https://api.github.com/repos/code-dot-org/code-dot-org/milestones{/number}","notifications_url":"https://api.github.com/repos/code-dot-org/code-dot-org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/code-dot-org/code-dot-org/labels{/name}","releases_url":"https://api.github.com/repos/code-dot-org/code-dot-org/releases{/id}","created_at":"2014-09-20T00:46:11Z","updated_at":"2015-09-16T14:46:10Z","pushed_at":"2015-10-01T18:23:39Z","git_url":"git://github.com/code-dot-org/code-dot-org.git","ssh_url":"git@github.com:code-dot-org/code-dot-org.git","clone_url":"https://github.com/code-dot-org/code-dot-org.git","svn_url":"https://github.com/code-dot-org/code-dot-org","homepage":"http://code.org","size":2799787,"stargazers_count":58,"watchers_count":58,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":43,"forks":38,"open_issues":43,"watchers":58,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/4278"},"html":{"href":"https://github.com/code-dot-org/code-dot-org/pull/4278"},"issue":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/4278"},"comments":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/4278/comments"},"review_comments":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/4278/comments"},"review_comment":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/4278/commits"},"statuses":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/fac3ccf7b308a6d7527326ca9ecf3205409883c0"}}}}