{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/facebook-news-bot/pulls/comments/81175852","pull_request_review_id":2175429,"id":81175852,"diff_hunk":"@@ -0,0 +1,72 @@\n+package com.gu.facebook_news_bot.logic\n+\n+import com.gu.facebook_news_bot.models.{FromFacebook, ToFacebook, User}\n+import com.gu.facebook_news_bot.services.{Capi, Facebook}\n+\n+import scala.concurrent.Future\n+\n+class StateHandler(facebook: Facebook, capi: Capi) {\n+\n+  type Result = (User, List[ToFacebook])\n+\n+  /**\n+    * @param userOpt  user from dynamodb\n+    * @param message  message from Facebook messenger\n+    * @return updated user, plus any messages to send to Facebook\n+    */\n+  def process(userOpt: Option[User], message: FromFacebook.Messaging): Future[Result] = {\n+    val user = userOpt.getOrElse(newUser(message.sender.id))\n+\n+    val state = getStateFromString(user.state)","path":"src/main/scala/com/gu/facebook_news_bot/logic/StateHandler.scala","position":20,"original_position":20,"commit_id":"8786274ba9b8dd92db721989e64e7fbcb83ac6b6","original_commit_id":"8786274ba9b8dd92db721989e64e7fbcb83ac6b6","user":{"login":"LATaylor-guardian","id":8861681,"avatar_url":"https://avatars.githubusercontent.com/u/8861681?v=3","gravatar_id":"","url":"https://api.github.com/users/LATaylor-guardian","html_url":"https://github.com/LATaylor-guardian","followers_url":"https://api.github.com/users/LATaylor-guardian/followers","following_url":"https://api.github.com/users/LATaylor-guardian/following{/other_user}","gists_url":"https://api.github.com/users/LATaylor-guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/LATaylor-guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LATaylor-guardian/subscriptions","organizations_url":"https://api.github.com/users/LATaylor-guardian/orgs","repos_url":"https://api.github.com/users/LATaylor-guardian/repos","events_url":"https://api.github.com/users/LATaylor-guardian/events{/privacy}","received_events_url":"https://api.github.com/users/LATaylor-guardian/received_events","type":"User","site_admin":false},"body":"I find this a little confusing - what is `state`?","created_at":"2016-09-29T16:18:20Z","updated_at":"2016-09-29T16:18:20Z","html_url":"https://github.com/guardian/facebook-news-bot/pull/25#discussion_r81175852","pull_request_url":"https://api.github.com/repos/guardian/facebook-news-bot/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/guardian/facebook-news-bot/pulls/comments/81175852"},"html":{"href":"https://github.com/guardian/facebook-news-bot/pull/25#discussion_r81175852"},"pull_request":{"href":"https://api.github.com/repos/guardian/facebook-news-bot/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/facebook-news-bot/pulls/25","id":87303500,"html_url":"https://github.com/guardian/facebook-news-bot/pull/25","diff_url":"https://github.com/guardian/facebook-news-bot/pull/25.diff","patch_url":"https://github.com/guardian/facebook-news-bot/pull/25.patch","issue_url":"https://api.github.com/repos/guardian/facebook-news-bot/issues/25","number":25,"state":"open","locked":false,"title":"Begin rewriting in scala with akka http","user":{"login":"tomrf1","id":1513454,"avatar_url":"https://avatars.githubusercontent.com/u/1513454?v=3","gravatar_id":"","url":"https://api.github.com/users/tomrf1","html_url":"https://github.com/tomrf1","followers_url":"https://api.github.com/users/tomrf1/followers","following_url":"https://api.github.com/users/tomrf1/following{/other_user}","gists_url":"https://api.github.com/users/tomrf1/gists{/gist_id}","starred_url":"https://api.github.com/users/tomrf1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomrf1/subscriptions","organizations_url":"https://api.github.com/users/tomrf1/orgs","repos_url":"https://api.github.com/users/tomrf1/repos","events_url":"https://api.github.com/users/tomrf1/events{/privacy}","received_events_url":"https://api.github.com/users/tomrf1/received_events","type":"User","site_admin":false},"body":"I've created a separate branch, `v2`, from master.\r\nFrom now on I will be merging the scala changes to `v2`. Once it's finished, I'll merge `v2` into master.\r\n\r\nThis is an initial outline of the app - it's very unfinished!\r\n\r\nNotes:\r\n- Messages from facebook may contain a text message or a payload.\r\n- We store user notification time + their state in dynamodb\r\n- On receiving a message from a user, we decide their next state and which messages to send to them based on their current state and the received message.","created_at":"2016-09-29T12:30:20Z","updated_at":"2016-09-29T16:18:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8109dc104c6c3c2da8e5aa9c414436709a185f25","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/guardian/facebook-news-bot/pulls/25/commits","review_comments_url":"https://api.github.com/repos/guardian/facebook-news-bot/pulls/25/comments","review_comment_url":"https://api.github.com/repos/guardian/facebook-news-bot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guardian/facebook-news-bot/issues/25/comments","statuses_url":"https://api.github.com/repos/guardian/facebook-news-bot/statuses/8786274ba9b8dd92db721989e64e7fbcb83ac6b6","head":{"label":"guardian:initial-scala","ref":"initial-scala","sha":"8786274ba9b8dd92db721989e64e7fbcb83ac6b6","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":65891074,"name":"facebook-news-bot","full_name":"guardian/facebook-news-bot","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/facebook-news-bot","description":"Placeholder description: @tomrf1 created this with repo-genesis","fork":false,"url":"https://api.github.com/repos/guardian/facebook-news-bot","forks_url":"https://api.github.com/repos/guardian/facebook-news-bot/forks","keys_url":"https://api.github.com/repos/guardian/facebook-news-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/facebook-news-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/facebook-news-bot/teams","hooks_url":"https://api.github.com/repos/guardian/facebook-news-bot/hooks","issue_events_url":"https://api.github.com/repos/guardian/facebook-news-bot/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/facebook-news-bot/events","assignees_url":"https://api.github.com/repos/guardian/facebook-news-bot/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/facebook-news-bot/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/facebook-news-bot/tags","blobs_url":"https://api.github.com/repos/guardian/facebook-news-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/facebook-news-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/facebook-news-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/facebook-news-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/facebook-news-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/facebook-news-bot/languages","stargazers_url":"https://api.github.com/repos/guardian/facebook-news-bot/stargazers","contributors_url":"https://api.github.com/repos/guardian/facebook-news-bot/contributors","subscribers_url":"https://api.github.com/repos/guardian/facebook-news-bot/subscribers","subscription_url":"https://api.github.com/repos/guardian/facebook-news-bot/subscription","commits_url":"https://api.github.com/repos/guardian/facebook-news-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/facebook-news-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/facebook-news-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/facebook-news-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/facebook-news-bot/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/facebook-news-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/facebook-news-bot/merges","archive_url":"https://api.github.com/repos/guardian/facebook-news-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/facebook-news-bot/downloads","issues_url":"https://api.github.com/repos/guardian/facebook-news-bot/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/facebook-news-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/facebook-news-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/facebook-news-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/facebook-news-bot/labels{/name}","releases_url":"https://api.github.com/repos/guardian/facebook-news-bot/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/facebook-news-bot/deployments","created_at":"2016-08-17T08:41:39Z","updated_at":"2016-08-17T08:59:02Z","pushed_at":"2016-09-29T12:30:43Z","git_url":"git://github.com/guardian/facebook-news-bot.git","ssh_url":"git@github.com:guardian/facebook-news-bot.git","clone_url":"https://github.com/guardian/facebook-news-bot.git","svn_url":"https://github.com/guardian/facebook-news-bot","homepage":null,"size":50,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"guardian:v2","ref":"v2","sha":"9a5577b3f82b63a33852309c059a1e936fcd4b10","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":65891074,"name":"facebook-news-bot","full_name":"guardian/facebook-news-bot","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/facebook-news-bot","description":"Placeholder description: @tomrf1 created this with repo-genesis","fork":false,"url":"https://api.github.com/repos/guardian/facebook-news-bot","forks_url":"https://api.github.com/repos/guardian/facebook-news-bot/forks","keys_url":"https://api.github.com/repos/guardian/facebook-news-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/facebook-news-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/facebook-news-bot/teams","hooks_url":"https://api.github.com/repos/guardian/facebook-news-bot/hooks","issue_events_url":"https://api.github.com/repos/guardian/facebook-news-bot/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/facebook-news-bot/events","assignees_url":"https://api.github.com/repos/guardian/facebook-news-bot/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/facebook-news-bot/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/facebook-news-bot/tags","blobs_url":"https://api.github.com/repos/guardian/facebook-news-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/facebook-news-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/facebook-news-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/facebook-news-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/facebook-news-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/facebook-news-bot/languages","stargazers_url":"https://api.github.com/repos/guardian/facebook-news-bot/stargazers","contributors_url":"https://api.github.com/repos/guardian/facebook-news-bot/contributors","subscribers_url":"https://api.github.com/repos/guardian/facebook-news-bot/subscribers","subscription_url":"https://api.github.com/repos/guardian/facebook-news-bot/subscription","commits_url":"https://api.github.com/repos/guardian/facebook-news-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/facebook-news-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/facebook-news-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/facebook-news-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/facebook-news-bot/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/facebook-news-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/facebook-news-bot/merges","archive_url":"https://api.github.com/repos/guardian/facebook-news-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/facebook-news-bot/downloads","issues_url":"https://api.github.com/repos/guardian/facebook-news-bot/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/facebook-news-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/facebook-news-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/facebook-news-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/facebook-news-bot/labels{/name}","releases_url":"https://api.github.com/repos/guardian/facebook-news-bot/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/facebook-news-bot/deployments","created_at":"2016-08-17T08:41:39Z","updated_at":"2016-08-17T08:59:02Z","pushed_at":"2016-09-29T12:30:43Z","git_url":"git://github.com/guardian/facebook-news-bot.git","ssh_url":"git@github.com:guardian/facebook-news-bot.git","clone_url":"https://github.com/guardian/facebook-news-bot.git","svn_url":"https://github.com/guardian/facebook-news-bot","homepage":null,"size":50,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/facebook-news-bot/pulls/25"},"html":{"href":"https://github.com/guardian/facebook-news-bot/pull/25"},"issue":{"href":"https://api.github.com/repos/guardian/facebook-news-bot/issues/25"},"comments":{"href":"https://api.github.com/repos/guardian/facebook-news-bot/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/facebook-news-bot/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/facebook-news-bot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guardian/facebook-news-bot/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/facebook-news-bot/statuses/8786274ba9b8dd92db721989e64e7fbcb83ac6b6"}}}}
{"actor":{"display_login":"LATaylor-guardian"}}