{"action":"created","comment":{"url":"https://api.github.com/repos/pjf/rickastley/pulls/comments/132867476","pull_request_review_id":55989727,"id":132867476,"diff_hunk":"@@ -153,5 +174,55 @@ def original():\n \n     return str(play_tune(tune))\n \n+@app.route(\"/sms\", methods=[\"POST\"])\n+def sms():\n+    \"\"\"Adds an incoming SMS to a queue, to reply to later.\"\"\"\n+    bucket.put_object(\n+        Key='queue/{to}/{from_}'.format(to=request.form['To'],\n+                                        from_=request.form['From']),\n+        Body='',\n+    )\n+    return \"Hello world!\"\n+\n+def send_sms():\n+    \"\"\"Empties the queue of incoming SMSes, replying to each one.\"\"\"\n+    for queue_entry in bucket.objects.filter(Prefix='queue/'):\n+        _, our_number, their_number = queue_entry.key.split(\"/\")\n+        state_key = \"state/{}/{}\".format(our_number, their_number)\n+\n+        # Find out which message we sent last, if any\n+        # Error handling taken from https://stackoverflow.com/a/33843019\n+        try:\n+            state_obj = s3.Object(\n+                os.environ['data_bucket'],\n+                state_key,\n+            )\n+            state_obj.load()\n+        except botocore.exceptions.ClientError as e:\n+            if e.response['Error']['Code'] == \"404\":\n+                last_msg = -1\n+            else:\n+                raise\n+        else:","path":"rickroll.py","position":77,"original_position":77,"commit_id":"b1d56b40ccf4eee5d5ecd6f094bb94463195798e","original_commit_id":"b1d56b40ccf4eee5d5ecd6f094bb94463195798e","user":{"login":"adambrenecki","id":473960,"avatar_url":"https://avatars1.githubusercontent.com/u/473960?v=4","gravatar_id":"","url":"https://api.github.com/users/adambrenecki","html_url":"https://github.com/adambrenecki","followers_url":"https://api.github.com/users/adambrenecki/followers","following_url":"https://api.github.com/users/adambrenecki/following{/other_user}","gists_url":"https://api.github.com/users/adambrenecki/gists{/gist_id}","starred_url":"https://api.github.com/users/adambrenecki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adambrenecki/subscriptions","organizations_url":"https://api.github.com/users/adambrenecki/orgs","repos_url":"https://api.github.com/users/adambrenecki/repos","events_url":"https://api.github.com/users/adambrenecki/events{/privacy}","received_events_url":"https://api.github.com/users/adambrenecki/received_events","type":"User","site_admin":false},"body":"Yep!\r\n\r\nYou can also attach an `else` block to a `for` or `while` loop, which executes if the loop runs to completion (as opposed to hitting a `break`).","created_at":"2017-08-14T03:13:31Z","updated_at":"2017-08-14T03:13:31Z","html_url":"https://github.com/pjf/rickastley/pull/7#discussion_r132867476","pull_request_url":"https://api.github.com/repos/pjf/rickastley/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/pjf/rickastley/pulls/comments/132867476"},"html":{"href":"https://github.com/pjf/rickastley/pull/7#discussion_r132867476"},"pull_request":{"href":"https://api.github.com/repos/pjf/rickastley/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/pjf/rickastley/pulls/7","id":135485088,"html_url":"https://github.com/pjf/rickastley/pull/7","diff_url":"https://github.com/pjf/rickastley/pull/7.diff","patch_url":"https://github.com/pjf/rickastley/pull/7.patch","issue_url":"https://api.github.com/repos/pjf/rickastley/issues/7","number":7,"state":"open","locked":false,"title":"Add support for SMS conversations","user":{"login":"adambrenecki","id":473960,"avatar_url":"https://avatars1.githubusercontent.com/u/473960?v=4","gravatar_id":"","url":"https://api.github.com/users/adambrenecki","html_url":"https://github.com/adambrenecki","followers_url":"https://api.github.com/users/adambrenecki/followers","following_url":"https://api.github.com/users/adambrenecki/following{/other_user}","gists_url":"https://api.github.com/users/adambrenecki/gists{/gist_id}","starred_url":"https://api.github.com/users/adambrenecki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adambrenecki/subscriptions","organizations_url":"https://api.github.com/users/adambrenecki/orgs","repos_url":"https://api.github.com/users/adambrenecki/repos","events_url":"https://api.github.com/users/adambrenecki/events{/privacy}","received_events_url":"https://api.github.com/users/adambrenecki/received_events","type":"User","site_admin":false},"body":"Closes #4.\r\n\r\nThis does make the deployment process a little more complicated though, and it also wouldn't be safe to publish the endpoint URL publicly (since someone who knew the incoming SMS endpoint could forge requests from Twilio and trick the Hotline into 'replying' to a third party).\r\n\r\nTell me what you think! :)","created_at":"2017-08-13T07:26:24Z","updated_at":"2017-08-14T03:13:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b3477071cdd09949fde6f615f3a335b21ea692c","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/pjf/rickastley/pulls/7/commits","review_comments_url":"https://api.github.com/repos/pjf/rickastley/pulls/7/comments","review_comment_url":"https://api.github.com/repos/pjf/rickastley/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pjf/rickastley/issues/7/comments","statuses_url":"https://api.github.com/repos/pjf/rickastley/statuses/b1d56b40ccf4eee5d5ecd6f094bb94463195798e","head":{"label":"adambrenecki:sms","ref":"sms","sha":"b1d56b40ccf4eee5d5ecd6f094bb94463195798e","user":{"login":"adambrenecki","id":473960,"avatar_url":"https://avatars1.githubusercontent.com/u/473960?v=4","gravatar_id":"","url":"https://api.github.com/users/adambrenecki","html_url":"https://github.com/adambrenecki","followers_url":"https://api.github.com/users/adambrenecki/followers","following_url":"https://api.github.com/users/adambrenecki/following{/other_user}","gists_url":"https://api.github.com/users/adambrenecki/gists{/gist_id}","starred_url":"https://api.github.com/users/adambrenecki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adambrenecki/subscriptions","organizations_url":"https://api.github.com/users/adambrenecki/orgs","repos_url":"https://api.github.com/users/adambrenecki/repos","events_url":"https://api.github.com/users/adambrenecki/events{/privacy}","received_events_url":"https://api.github.com/users/adambrenecki/received_events","type":"User","site_admin":false},"repo":{"id":100160685,"name":"rickastley","full_name":"adambrenecki/rickastley","owner":{"login":"adambrenecki","id":473960,"avatar_url":"https://avatars1.githubusercontent.com/u/473960?v=4","gravatar_id":"","url":"https://api.github.com/users/adambrenecki","html_url":"https://github.com/adambrenecki","followers_url":"https://api.github.com/users/adambrenecki/followers","following_url":"https://api.github.com/users/adambrenecki/following{/other_user}","gists_url":"https://api.github.com/users/adambrenecki/gists{/gist_id}","starred_url":"https://api.github.com/users/adambrenecki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adambrenecki/subscriptions","organizations_url":"https://api.github.com/users/adambrenecki/orgs","repos_url":"https://api.github.com/users/adambrenecki/repos","events_url":"https://api.github.com/users/adambrenecki/events{/privacy}","received_events_url":"https://api.github.com/users/adambrenecki/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adambrenecki/rickastley","description":"National Rick Astley Hotline","fork":true,"url":"https://api.github.com/repos/adambrenecki/rickastley","forks_url":"https://api.github.com/repos/adambrenecki/rickastley/forks","keys_url":"https://api.github.com/repos/adambrenecki/rickastley/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adambrenecki/rickastley/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adambrenecki/rickastley/teams","hooks_url":"https://api.github.com/repos/adambrenecki/rickastley/hooks","issue_events_url":"https://api.github.com/repos/adambrenecki/rickastley/issues/events{/number}","events_url":"https://api.github.com/repos/adambrenecki/rickastley/events","assignees_url":"https://api.github.com/repos/adambrenecki/rickastley/assignees{/user}","branches_url":"https://api.github.com/repos/adambrenecki/rickastley/branches{/branch}","tags_url":"https://api.github.com/repos/adambrenecki/rickastley/tags","blobs_url":"https://api.github.com/repos/adambrenecki/rickastley/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adambrenecki/rickastley/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adambrenecki/rickastley/git/refs{/sha}","trees_url":"https://api.github.com/repos/adambrenecki/rickastley/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adambrenecki/rickastley/statuses/{sha}","languages_url":"https://api.github.com/repos/adambrenecki/rickastley/languages","stargazers_url":"https://api.github.com/repos/adambrenecki/rickastley/stargazers","contributors_url":"https://api.github.com/repos/adambrenecki/rickastley/contributors","subscribers_url":"https://api.github.com/repos/adambrenecki/rickastley/subscribers","subscription_url":"https://api.github.com/repos/adambrenecki/rickastley/subscription","commits_url":"https://api.github.com/repos/adambrenecki/rickastley/commits{/sha}","git_commits_url":"https://api.github.com/repos/adambrenecki/rickastley/git/commits{/sha}","comments_url":"https://api.github.com/repos/adambrenecki/rickastley/comments{/number}","issue_comment_url":"https://api.github.com/repos/adambrenecki/rickastley/issues/comments{/number}","contents_url":"https://api.github.com/repos/adambrenecki/rickastley/contents/{+path}","compare_url":"https://api.github.com/repos/adambrenecki/rickastley/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adambrenecki/rickastley/merges","archive_url":"https://api.github.com/repos/adambrenecki/rickastley/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adambrenecki/rickastley/downloads","issues_url":"https://api.github.com/repos/adambrenecki/rickastley/issues{/number}","pulls_url":"https://api.github.com/repos/adambrenecki/rickastley/pulls{/number}","milestones_url":"https://api.github.com/repos/adambrenecki/rickastley/milestones{/number}","notifications_url":"https://api.github.com/repos/adambrenecki/rickastley/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adambrenecki/rickastley/labels{/name}","releases_url":"https://api.github.com/repos/adambrenecki/rickastley/releases{/id}","deployments_url":"https://api.github.com/repos/adambrenecki/rickastley/deployments","created_at":"2017-08-13T07:21:40Z","updated_at":"2017-08-13T07:21:41Z","pushed_at":"2017-08-13T07:22:55Z","git_url":"git://github.com/adambrenecki/rickastley.git","ssh_url":"git@github.com:adambrenecki/rickastley.git","clone_url":"https://github.com/adambrenecki/rickastley.git","svn_url":"https://github.com/adambrenecki/rickastley","homepage":null,"size":17,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pjf:master","ref":"master","sha":"ee3bb566913a8faf18501acf29239c31e4ba6f80","user":{"login":"pjf","id":12072,"avatar_url":"https://avatars0.githubusercontent.com/u/12072?v=4","gravatar_id":"","url":"https://api.github.com/users/pjf","html_url":"https://github.com/pjf","followers_url":"https://api.github.com/users/pjf/followers","following_url":"https://api.github.com/users/pjf/following{/other_user}","gists_url":"https://api.github.com/users/pjf/gists{/gist_id}","starred_url":"https://api.github.com/users/pjf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjf/subscriptions","organizations_url":"https://api.github.com/users/pjf/orgs","repos_url":"https://api.github.com/users/pjf/repos","events_url":"https://api.github.com/users/pjf/events{/privacy}","received_events_url":"https://api.github.com/users/pjf/received_events","type":"User","site_admin":false},"repo":{"id":55304546,"name":"rickastley","full_name":"pjf/rickastley","owner":{"login":"pjf","id":12072,"avatar_url":"https://avatars0.githubusercontent.com/u/12072?v=4","gravatar_id":"","url":"https://api.github.com/users/pjf","html_url":"https://github.com/pjf","followers_url":"https://api.github.com/users/pjf/followers","following_url":"https://api.github.com/users/pjf/following{/other_user}","gists_url":"https://api.github.com/users/pjf/gists{/gist_id}","starred_url":"https://api.github.com/users/pjf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjf/subscriptions","organizations_url":"https://api.github.com/users/pjf/orgs","repos_url":"https://api.github.com/users/pjf/repos","events_url":"https://api.github.com/users/pjf/events{/privacy}","received_events_url":"https://api.github.com/users/pjf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pjf/rickastley","description":"National Rick Astley Hotline","fork":false,"url":"https://api.github.com/repos/pjf/rickastley","forks_url":"https://api.github.com/repos/pjf/rickastley/forks","keys_url":"https://api.github.com/repos/pjf/rickastley/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pjf/rickastley/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pjf/rickastley/teams","hooks_url":"https://api.github.com/repos/pjf/rickastley/hooks","issue_events_url":"https://api.github.com/repos/pjf/rickastley/issues/events{/number}","events_url":"https://api.github.com/repos/pjf/rickastley/events","assignees_url":"https://api.github.com/repos/pjf/rickastley/assignees{/user}","branches_url":"https://api.github.com/repos/pjf/rickastley/branches{/branch}","tags_url":"https://api.github.com/repos/pjf/rickastley/tags","blobs_url":"https://api.github.com/repos/pjf/rickastley/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pjf/rickastley/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pjf/rickastley/git/refs{/sha}","trees_url":"https://api.github.com/repos/pjf/rickastley/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pjf/rickastley/statuses/{sha}","languages_url":"https://api.github.com/repos/pjf/rickastley/languages","stargazers_url":"https://api.github.com/repos/pjf/rickastley/stargazers","contributors_url":"https://api.github.com/repos/pjf/rickastley/contributors","subscribers_url":"https://api.github.com/repos/pjf/rickastley/subscribers","subscription_url":"https://api.github.com/repos/pjf/rickastley/subscription","commits_url":"https://api.github.com/repos/pjf/rickastley/commits{/sha}","git_commits_url":"https://api.github.com/repos/pjf/rickastley/git/commits{/sha}","comments_url":"https://api.github.com/repos/pjf/rickastley/comments{/number}","issue_comment_url":"https://api.github.com/repos/pjf/rickastley/issues/comments{/number}","contents_url":"https://api.github.com/repos/pjf/rickastley/contents/{+path}","compare_url":"https://api.github.com/repos/pjf/rickastley/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pjf/rickastley/merges","archive_url":"https://api.github.com/repos/pjf/rickastley/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pjf/rickastley/downloads","issues_url":"https://api.github.com/repos/pjf/rickastley/issues{/number}","pulls_url":"https://api.github.com/repos/pjf/rickastley/pulls{/number}","milestones_url":"https://api.github.com/repos/pjf/rickastley/milestones{/number}","notifications_url":"https://api.github.com/repos/pjf/rickastley/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pjf/rickastley/labels{/name}","releases_url":"https://api.github.com/repos/pjf/rickastley/releases{/id}","deployments_url":"https://api.github.com/repos/pjf/rickastley/deployments","created_at":"2016-04-02T16:28:59Z","updated_at":"2017-08-09T21:29:54Z","pushed_at":"2017-08-14T01:50:08Z","git_url":"git://github.com/pjf/rickastley.git","ssh_url":"git@github.com:pjf/rickastley.git","clone_url":"https://github.com/pjf/rickastley.git","svn_url":"https://github.com/pjf/rickastley","homepage":null,"size":14,"stargazers_count":25,"watchers_count":25,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":3,"forks":5,"open_issues":3,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pjf/rickastley/pulls/7"},"html":{"href":"https://github.com/pjf/rickastley/pull/7"},"issue":{"href":"https://api.github.com/repos/pjf/rickastley/issues/7"},"comments":{"href":"https://api.github.com/repos/pjf/rickastley/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/pjf/rickastley/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/pjf/rickastley/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pjf/rickastley/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/pjf/rickastley/statuses/b1d56b40ccf4eee5d5ecd6f094bb94463195798e"}}}}
{"actor":{"display_login":"adambrenecki"}}