{"action":"created","comment":{"url":"https://api.github.com/repos/webcompat/webcompat.com/pulls/comments/218982107","pull_request_review_id":157011030,"id":218982107,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxODk4MjEwNw==","diff_hunk":"@@ -169,77 +171,93 @@ def show_issues():\n \n @app.route('/issues/new', methods=['GET', 'POST'])\n def create_issue():\n-    \"\"\"Create a new issue.\n-\n-    GET will return an HTML response for reporting issues.\n-    POST will create a new issue.\n+    \"\"\"Create a new issue or prefill a form for submission.\n+\n+    * HTTP GET with (optional) parameters\n+      * create a form with prefiled data.\n+      * parameters:\n+        * url: URL of the Web site\n+        * src: source of the request (web, addon, etc.)\n+        * label: controled list of labels\n+    * HTTP POST with a JSON payload\n+      * create a form with prefiled data\n+      * content-type is application/json\n+      * json may include:\n+        * title\n+        * User agent string\n+        * OS identification\n+        * labels list\n+        * type of bugs\n+        * short summary\n+        * full description\n+        * tested in another browser\n+        * body\n+    * HTTP POST with an attached form\n+      * submit a form to GitHub to create a new issue\n+      * form submit type:\n+        * authenticated: Github authentification\n+        * anonymous: handled by webcompat-bot\n \n     Any deceptive requests will be ended as a 400.\n     See https://tools.ietf.org/html/rfc7231#section-6.5.1\n     \"\"\"\n     # Starting a logger\n     log = app.logger\n     log.setLevel(logging.INFO)\n-    # Get the User-Agent\n-    user_agent = request.headers.get('User-Agent')\n-    # GET Requests\n-    if request.method == 'GET':\n-        bug_form = get_form(user_agent)\n-        if g.user:\n-            get_user_info()\n-        # Note: `src` and `label` are special GET params that can pass\n-        # in extra information about a bug report. They're not part of the\n-        # HTML <form>, so we stick them in the session cookie so they survive\n-        # the scenario where the user decides to do authentication, and they\n-        # can then be passed on to form.py\n-        if request.args.get('src'):\n-            session['src'] = request.args.get('src')\n-        if request.args.get('label'):\n-            session['label'] = request.args.getlist('label')\n+    if g.user:\n+        get_user_info()\n+    # We define which type of requests we are dealing with.\n+    request_type = form_type(request)\n+    # Form Prefill section\n+    if request_type == 'prefill':\n+        form_data = prepare_form(request)\n+        bug_form = get_form(form_data)\n+        session['form_data'] = form_data","path":"webcompat/views.py","position":116,"original_position":116,"commit_id":"d73db92fc435bf5536c830a32ce718b14fdf8204","original_commit_id":"d73db92fc435bf5536c830a32ce718b14fdf8204","user":{"login":"miketaylr","id":67283,"node_id":"MDQ6VXNlcjY3Mjgz","avatar_url":"https://avatars1.githubusercontent.com/u/67283?v=4","gravatar_id":"","url":"https://api.github.com/users/miketaylr","html_url":"https://github.com/miketaylr","followers_url":"https://api.github.com/users/miketaylr/followers","following_url":"https://api.github.com/users/miketaylr/following{/other_user}","gists_url":"https://api.github.com/users/miketaylr/gists{/gist_id}","starred_url":"https://api.github.com/users/miketaylr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miketaylr/subscriptions","organizations_url":"https://api.github.com/users/miketaylr/orgs","repos_url":"https://api.github.com/users/miketaylr/repos","events_url":"https://api.github.com/users/miketaylr/events{/privacy}","received_events_url":"https://api.github.com/users/miketaylr/received_events","type":"User","site_admin":false},"body":"...ok, understanding some things a little bit more. I think 😄 \r\n\r\n `session.form_data` is only used to pass along the `extra_labels` inside the `request_type == 'create'` block. So do we really need this copy of `form_data` in the session at all? We could either pass `extra_labels` in the `request.form` itself, via a `HiddenInput`, or just toss it in a session key without the rest of the form. ","created_at":"2018-09-19T22:17:01Z","updated_at":"2018-09-19T22:17:41Z","html_url":"https://github.com/webcompat/webcompat.com/pull/2582#discussion_r218982107","pull_request_url":"https://api.github.com/repos/webcompat/webcompat.com/pulls/2582","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/webcompat/webcompat.com/pulls/comments/218982107"},"html":{"href":"https://github.com/webcompat/webcompat.com/pull/2582#discussion_r218982107"},"pull_request":{"href":"https://api.github.com/repos/webcompat/webcompat.com/pulls/2582"}},"in_reply_to_id":218969763},"pull_request":{"url":"https://api.github.com/repos/webcompat/webcompat.com/pulls/2582","id":216516919,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2NTE2OTE5","html_url":"https://github.com/webcompat/webcompat.com/pull/2582","diff_url":"https://github.com/webcompat/webcompat.com/pull/2582.diff","patch_url":"https://github.com/webcompat/webcompat.com/pull/2582.patch","issue_url":"https://api.github.com/repos/webcompat/webcompat.com/issues/2582","number":2582,"state":"open","locked":false,"title":"Fixes #2024 - Adds the ability to receive POST data with a JSON Payload","user":{"login":"karlcow","id":505230,"node_id":"MDQ6VXNlcjUwNTIzMA==","avatar_url":"https://avatars0.githubusercontent.com/u/505230?v=4","gravatar_id":"","url":"https://api.github.com/users/karlcow","html_url":"https://github.com/karlcow","followers_url":"https://api.github.com/users/karlcow/followers","following_url":"https://api.github.com/users/karlcow/following{/other_user}","gists_url":"https://api.github.com/users/karlcow/gists{/gist_id}","starred_url":"https://api.github.com/users/karlcow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karlcow/subscriptions","organizations_url":"https://api.github.com/users/karlcow/orgs","repos_url":"https://api.github.com/users/karlcow/repos","events_url":"https://api.github.com/users/karlcow/events{/privacy}","received_events_url":"https://api.github.com/users/karlcow/received_events","type":"User","site_admin":false},"body":"This PR fixes issue #2024\r\n\r\n## Proposed PR background\r\n\r\nThis should be able to receive POST data with a JSON body for pre-populating the form.\r\n\r\n* Works as before and accept URL parameters both from GET and POST\r\n* Adds a POST JSON data for the form\r\n* Submit the data as before with multiform/part\r\n\r\nPossible Follow up issues to fill. \r\n* Be stricter in what is possible to do in the POST data (JSON validation)\r\n* Be stricter on the form validation.\r\n\r\nThe next step will be to push this to staging so we can test it deeply and thoroughly.\r\n\r\n\r\n```\r\n→ nosetests \r\n..................................................................................................\r\n----------------------------------------------------------------------\r\nRan 98 tests in 1.133s\r\n\r\nOK\r\n```\r\n\r\nr? @miketaylr ","created_at":"2018-09-19T05:19:53Z","updated_at":"2018-09-19T22:17:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"baaae555ec3f66877986495efec470838b5aa14f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/webcompat/webcompat.com/pulls/2582/commits","review_comments_url":"https://api.github.com/repos/webcompat/webcompat.com/pulls/2582/comments","review_comment_url":"https://api.github.com/repos/webcompat/webcompat.com/pulls/comments{/number}","comments_url":"https://api.github.com/repos/webcompat/webcompat.com/issues/2582/comments","statuses_url":"https://api.github.com/repos/webcompat/webcompat.com/statuses/d73db92fc435bf5536c830a32ce718b14fdf8204","head":{"label":"karlcow:2024/1","ref":"2024/1","sha":"d73db92fc435bf5536c830a32ce718b14fdf8204","user":{"login":"karlcow","id":505230,"node_id":"MDQ6VXNlcjUwNTIzMA==","avatar_url":"https://avatars0.githubusercontent.com/u/505230?v=4","gravatar_id":"","url":"https://api.github.com/users/karlcow","html_url":"https://github.com/karlcow","followers_url":"https://api.github.com/users/karlcow/followers","following_url":"https://api.github.com/users/karlcow/following{/other_user}","gists_url":"https://api.github.com/users/karlcow/gists{/gist_id}","starred_url":"https://api.github.com/users/karlcow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karlcow/subscriptions","organizations_url":"https://api.github.com/users/karlcow/orgs","repos_url":"https://api.github.com/users/karlcow/repos","events_url":"https://api.github.com/users/karlcow/events{/privacy}","received_events_url":"https://api.github.com/users/karlcow/received_events","type":"User","site_admin":false},"repo":{"id":20514633,"node_id":"MDEwOlJlcG9zaXRvcnkyMDUxNDYzMw==","name":"webcompat.com","full_name":"karlcow/webcompat.com","private":false,"owner":{"login":"karlcow","id":505230,"node_id":"MDQ6VXNlcjUwNTIzMA==","avatar_url":"https://avatars0.githubusercontent.com/u/505230?v=4","gravatar_id":"","url":"https://api.github.com/users/karlcow","html_url":"https://github.com/karlcow","followers_url":"https://api.github.com/users/karlcow/followers","following_url":"https://api.github.com/users/karlcow/following{/other_user}","gists_url":"https://api.github.com/users/karlcow/gists{/gist_id}","starred_url":"https://api.github.com/users/karlcow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karlcow/subscriptions","organizations_url":"https://api.github.com/users/karlcow/orgs","repos_url":"https://api.github.com/users/karlcow/repos","events_url":"https://api.github.com/users/karlcow/events{/privacy}","received_events_url":"https://api.github.com/users/karlcow/received_events","type":"User","site_admin":false},"html_url":"https://github.com/karlcow/webcompat.com","description":"Source code for webcompat.com","fork":true,"url":"https://api.github.com/repos/karlcow/webcompat.com","forks_url":"https://api.github.com/repos/karlcow/webcompat.com/forks","keys_url":"https://api.github.com/repos/karlcow/webcompat.com/keys{/key_id}","collaborators_url":"https://api.github.com/repos/karlcow/webcompat.com/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/karlcow/webcompat.com/teams","hooks_url":"https://api.github.com/repos/karlcow/webcompat.com/hooks","issue_events_url":"https://api.github.com/repos/karlcow/webcompat.com/issues/events{/number}","events_url":"https://api.github.com/repos/karlcow/webcompat.com/events","assignees_url":"https://api.github.com/repos/karlcow/webcompat.com/assignees{/user}","branches_url":"https://api.github.com/repos/karlcow/webcompat.com/branches{/branch}","tags_url":"https://api.github.com/repos/karlcow/webcompat.com/tags","blobs_url":"https://api.github.com/repos/karlcow/webcompat.com/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/karlcow/webcompat.com/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/karlcow/webcompat.com/git/refs{/sha}","trees_url":"https://api.github.com/repos/karlcow/webcompat.com/git/trees{/sha}","statuses_url":"https://api.github.com/repos/karlcow/webcompat.com/statuses/{sha}","languages_url":"https://api.github.com/repos/karlcow/webcompat.com/languages","stargazers_url":"https://api.github.com/repos/karlcow/webcompat.com/stargazers","contributors_url":"https://api.github.com/repos/karlcow/webcompat.com/contributors","subscribers_url":"https://api.github.com/repos/karlcow/webcompat.com/subscribers","subscription_url":"https://api.github.com/repos/karlcow/webcompat.com/subscription","commits_url":"https://api.github.com/repos/karlcow/webcompat.com/commits{/sha}","git_commits_url":"https://api.github.com/repos/karlcow/webcompat.com/git/commits{/sha}","comments_url":"https://api.github.com/repos/karlcow/webcompat.com/comments{/number}","issue_comment_url":"https://api.github.com/repos/karlcow/webcompat.com/issues/comments{/number}","contents_url":"https://api.github.com/repos/karlcow/webcompat.com/contents/{+path}","compare_url":"https://api.github.com/repos/karlcow/webcompat.com/compare/{base}...{head}","merges_url":"https://api.github.com/repos/karlcow/webcompat.com/merges","archive_url":"https://api.github.com/repos/karlcow/webcompat.com/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/karlcow/webcompat.com/downloads","issues_url":"https://api.github.com/repos/karlcow/webcompat.com/issues{/number}","pulls_url":"https://api.github.com/repos/karlcow/webcompat.com/pulls{/number}","milestones_url":"https://api.github.com/repos/karlcow/webcompat.com/milestones{/number}","notifications_url":"https://api.github.com/repos/karlcow/webcompat.com/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/karlcow/webcompat.com/labels{/name}","releases_url":"https://api.github.com/repos/karlcow/webcompat.com/releases{/id}","deployments_url":"https://api.github.com/repos/karlcow/webcompat.com/deployments","created_at":"2014-06-05T06:41:38Z","updated_at":"2018-08-30T20:46:42Z","pushed_at":"2018-09-19T05:14:41Z","git_url":"git://github.com/karlcow/webcompat.com.git","ssh_url":"git@github.com:karlcow/webcompat.com.git","clone_url":"https://github.com/karlcow/webcompat.com.git","svn_url":"https://github.com/karlcow/webcompat.com","homepage":null,"size":11804,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"webcompat:master","ref":"master","sha":"4bf7a79eb93985566a9f8f49b51835f42f4a168d","user":{"login":"webcompat","id":6175168,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNzUxNjg=","avatar_url":"https://avatars3.githubusercontent.com/u/6175168?v=4","gravatar_id":"","url":"https://api.github.com/users/webcompat","html_url":"https://github.com/webcompat","followers_url":"https://api.github.com/users/webcompat/followers","following_url":"https://api.github.com/users/webcompat/following{/other_user}","gists_url":"https://api.github.com/users/webcompat/gists{/gist_id}","starred_url":"https://api.github.com/users/webcompat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webcompat/subscriptions","organizations_url":"https://api.github.com/users/webcompat/orgs","repos_url":"https://api.github.com/users/webcompat/repos","events_url":"https://api.github.com/users/webcompat/events{/privacy}","received_events_url":"https://api.github.com/users/webcompat/received_events","type":"Organization","site_admin":false},"repo":{"id":15174830,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE3NDgzMA==","name":"webcompat.com","full_name":"webcompat/webcompat.com","private":false,"owner":{"login":"webcompat","id":6175168,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNzUxNjg=","avatar_url":"https://avatars3.githubusercontent.com/u/6175168?v=4","gravatar_id":"","url":"https://api.github.com/users/webcompat","html_url":"https://github.com/webcompat","followers_url":"https://api.github.com/users/webcompat/followers","following_url":"https://api.github.com/users/webcompat/following{/other_user}","gists_url":"https://api.github.com/users/webcompat/gists{/gist_id}","starred_url":"https://api.github.com/users/webcompat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webcompat/subscriptions","organizations_url":"https://api.github.com/users/webcompat/orgs","repos_url":"https://api.github.com/users/webcompat/repos","events_url":"https://api.github.com/users/webcompat/events{/privacy}","received_events_url":"https://api.github.com/users/webcompat/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/webcompat/webcompat.com","description":"Source code for","fork":false,"url":"https://api.github.com/repos/webcompat/webcompat.com","forks_url":"https://api.github.com/repos/webcompat/webcompat.com/forks","keys_url":"https://api.github.com/repos/webcompat/webcompat.com/keys{/key_id}","collaborators_url":"https://api.github.com/repos/webcompat/webcompat.com/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/webcompat/webcompat.com/teams","hooks_url":"https://api.github.com/repos/webcompat/webcompat.com/hooks","issue_events_url":"https://api.github.com/repos/webcompat/webcompat.com/issues/events{/number}","events_url":"https://api.github.com/repos/webcompat/webcompat.com/events","assignees_url":"https://api.github.com/repos/webcompat/webcompat.com/assignees{/user}","branches_url":"https://api.github.com/repos/webcompat/webcompat.com/branches{/branch}","tags_url":"https://api.github.com/repos/webcompat/webcompat.com/tags","blobs_url":"https://api.github.com/repos/webcompat/webcompat.com/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/webcompat/webcompat.com/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/webcompat/webcompat.com/git/refs{/sha}","trees_url":"https://api.github.com/repos/webcompat/webcompat.com/git/trees{/sha}","statuses_url":"https://api.github.com/repos/webcompat/webcompat.com/statuses/{sha}","languages_url":"https://api.github.com/repos/webcompat/webcompat.com/languages","stargazers_url":"https://api.github.com/repos/webcompat/webcompat.com/stargazers","contributors_url":"https://api.github.com/repos/webcompat/webcompat.com/contributors","subscribers_url":"https://api.github.com/repos/webcompat/webcompat.com/subscribers","subscription_url":"https://api.github.com/repos/webcompat/webcompat.com/subscription","commits_url":"https://api.github.com/repos/webcompat/webcompat.com/commits{/sha}","git_commits_url":"https://api.github.com/repos/webcompat/webcompat.com/git/commits{/sha}","comments_url":"https://api.github.com/repos/webcompat/webcompat.com/comments{/number}","issue_comment_url":"https://api.github.com/repos/webcompat/webcompat.com/issues/comments{/number}","contents_url":"https://api.github.com/repos/webcompat/webcompat.com/contents/{+path}","compare_url":"https://api.github.com/repos/webcompat/webcompat.com/compare/{base}...{head}","merges_url":"https://api.github.com/repos/webcompat/webcompat.com/merges","archive_url":"https://api.github.com/repos/webcompat/webcompat.com/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/webcompat/webcompat.com/downloads","issues_url":"https://api.github.com/repos/webcompat/webcompat.com/issues{/number}","pulls_url":"https://api.github.com/repos/webcompat/webcompat.com/pulls{/number}","milestones_url":"https://api.github.com/repos/webcompat/webcompat.com/milestones{/number}","notifications_url":"https://api.github.com/repos/webcompat/webcompat.com/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/webcompat/webcompat.com/labels{/name}","releases_url":"https://api.github.com/repos/webcompat/webcompat.com/releases{/id}","deployments_url":"https://api.github.com/repos/webcompat/webcompat.com/deployments","created_at":"2013-12-13T21:44:40Z","updated_at":"2018-09-19T17:56:25Z","pushed_at":"2018-09-19T17:56:22Z","git_url":"git://github.com/webcompat/webcompat.com.git","ssh_url":"git@github.com:webcompat/webcompat.com.git","clone_url":"https://github.com/webcompat/webcompat.com.git","svn_url":"https://github.com/webcompat/webcompat.com","homepage":"https://webcompat.com","size":12422,"stargazers_count":140,"watchers_count":140,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":93,"mirror_url":null,"archived":false,"open_issues_count":188,"license":null,"forks":93,"open_issues":188,"watchers":140,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/webcompat/webcompat.com/pulls/2582"},"html":{"href":"https://github.com/webcompat/webcompat.com/pull/2582"},"issue":{"href":"https://api.github.com/repos/webcompat/webcompat.com/issues/2582"},"comments":{"href":"https://api.github.com/repos/webcompat/webcompat.com/issues/2582/comments"},"review_comments":{"href":"https://api.github.com/repos/webcompat/webcompat.com/pulls/2582/comments"},"review_comment":{"href":"https://api.github.com/repos/webcompat/webcompat.com/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/webcompat/webcompat.com/pulls/2582/commits"},"statuses":{"href":"https://api.github.com/repos/webcompat/webcompat.com/statuses/d73db92fc435bf5536c830a32ce718b14fdf8204"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"miketaylr"}}