{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/comments/150802900","pull_request_review_id":76404762,"id":150802900,"diff_hunk":"@@ -351,22 +354,29 @@ object AccountManagement extends Controller with ContextLogging with CatalogProv\n     implicit val tpBackend = resolution.backend\n     val eventualMaybeSubscription = SessionSubscription.subscriptionFromRequest\n     val errorCodes = errorCode.toSeq.flatMap(_.split(',').map(_.trim)).filterNot(_.isEmpty).toSet\n+    val futureMaybeMaybeEmail = (for {\n+      authUser <- OptionT(Future.successful(authenticatedUserFor(request)))\n+      idUser <- OptionT(IdentityService.userLookupByCredentials(authUser.credentials))\n+    } yield Option(idUser.primaryEmailAddress)).run.recover{case _ => None}\n+\n \n     val futureMaybeFutureManagePage = for {\n       subscription <- OptionT(eventualMaybeSubscription).filter(!_.isCancelled)\n       account <- OptionT(tpBackend.zuoraService.getAccount(subscription.accountId).map{Some(_)}.recover{case t: Throwable => None})\n       pendingHolidays <- OptionT(tpBackend.suspensionService.getUnfinishedHolidays(subscription.name, now).map(_.toOption))\n       billingSchedule <- OptionT(tpBackend.commonPaymentService.billingSchedule(subscription.id, account, numberOfBills = 13).map(Some(_):Option[Option[BillingSchedule]]))\n+      maybeEmail <- OptionT(futureMaybeMaybeEmail)","path":"app/controllers/AccountManagement.scala","position":75,"original_position":75,"commit_id":"3a99233fbfddca9edacb938855da019a25f7ea50","original_commit_id":"3a99233fbfddca9edacb938855da019a25f7ea50","user":{"login":"johnduffell","id":7304387,"avatar_url":"https://avatars1.githubusercontent.com/u/7304387?v=4","gravatar_id":"","url":"https://api.github.com/users/johnduffell","html_url":"https://github.com/johnduffell","followers_url":"https://api.github.com/users/johnduffell/followers","following_url":"https://api.github.com/users/johnduffell/following{/other_user}","gists_url":"https://api.github.com/users/johnduffell/gists{/gist_id}","starred_url":"https://api.github.com/users/johnduffell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnduffell/subscriptions","organizations_url":"https://api.github.com/users/johnduffell/orgs","repos_url":"https://api.github.com/users/johnduffell/repos","events_url":"https://api.github.com/users/johnduffell/events{/privacy}","received_events_url":"https://api.github.com/users/johnduffell/received_events","type":"User","site_admin":false},"body":"so just to clarify if there's no user in the session or the lookup fails to find anything, you want to quit the for comprehension, however if there a user there but there null returned or an exception is thrown, you want to carry on with None as the email.\r\nI'm wondering vaguely whether there might be a better type to use than Option[Option[...]] just to avoid confusion","created_at":"2017-11-14T11:09:12Z","updated_at":"2017-11-14T11:09:12Z","html_url":"https://github.com/guardian/subscriptions-frontend/pull/992#discussion_r150802900","pull_request_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/992","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/comments/150802900"},"html":{"href":"https://github.com/guardian/subscriptions-frontend/pull/992#discussion_r150802900"},"pull_request":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/992"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/992","id":151131718,"html_url":"https://github.com/guardian/subscriptions-frontend/pull/992","diff_url":"https://github.com/guardian/subscriptions-frontend/pull/992.diff","patch_url":"https://github.com/guardian/subscriptions-frontend/pull/992.patch","issue_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/992","number":992,"state":"open","locked":false,"title":"Update card Weekly, HD, Voucher","user":{"login":"AWare","id":2670496,"avatar_url":"https://avatars3.githubusercontent.com/u/2670496?v=4","gravatar_id":"","url":"https://api.github.com/users/AWare","html_url":"https://github.com/AWare","followers_url":"https://api.github.com/users/AWare/followers","following_url":"https://api.github.com/users/AWare/following{/other_user}","gists_url":"https://api.github.com/users/AWare/gists{/gist_id}","starred_url":"https://api.github.com/users/AWare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AWare/subscriptions","organizations_url":"https://api.github.com/users/AWare/orgs","repos_url":"https://api.github.com/users/AWare/repos","events_url":"https://api.github.com/users/AWare/events{/privacy}","received_events_url":"https://api.github.com/users/AWare/received_events","type":"User","site_admin":false},"body":"Update card functionality for users with Weekly, HomeDelivery or Voucher.\r\nIdentity users updating CC only for now.","created_at":"2017-11-07T14:44:38Z","updated_at":"2017-11-14T11:09:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0766a339052cacada593f9b8e6bc3533024a9bc2","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/992/commits","review_comments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/992/comments","review_comment_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/992/comments","statuses_url":"https://api.github.com/repos/guardian/subscriptions-frontend/statuses/3a99233fbfddca9edacb938855da019a25f7ea50","head":{"label":"guardian:update-card","ref":"update-card","sha":"3a99233fbfddca9edacb938855da019a25f7ea50","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars0.githubusercontent.com/u/164318?v=4","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":34392023,"name":"subscriptions-frontend","full_name":"guardian/subscriptions-frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars0.githubusercontent.com/u/164318?v=4","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/subscriptions-frontend","description":null,"fork":false,"url":"https://api.github.com/repos/guardian/subscriptions-frontend","forks_url":"https://api.github.com/repos/guardian/subscriptions-frontend/forks","keys_url":"https://api.github.com/repos/guardian/subscriptions-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/subscriptions-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/subscriptions-frontend/teams","hooks_url":"https://api.github.com/repos/guardian/subscriptions-frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/subscriptions-frontend/events","assignees_url":"https://api.github.com/repos/guardian/subscriptions-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/subscriptions-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/subscriptions-frontend/tags","blobs_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/subscriptions-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/subscriptions-frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/subscriptions-frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/subscriptions-frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/subscriptions-frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/subscriptions-frontend/subscription","commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/subscriptions-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/subscriptions-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/subscriptions-frontend/merges","archive_url":"https://api.github.com/repos/guardian/subscriptions-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/subscriptions-frontend/downloads","issues_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/subscriptions-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/subscriptions-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/subscriptions-frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/subscriptions-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/deployments","created_at":"2015-04-22T13:30:13Z","updated_at":"2017-08-24T12:59:55Z","pushed_at":"2017-11-13T17:19:42Z","git_url":"git://github.com/guardian/subscriptions-frontend.git","ssh_url":"git@github.com:guardian/subscriptions-frontend.git","clone_url":"https://github.com/guardian/subscriptions-frontend.git","svn_url":"https://github.com/guardian/subscriptions-frontend","homepage":"https://sites.google.com/a/guardian.co.uk/guardian-subscriptions/","size":7512,"stargazers_count":9,"watchers_count":9,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":9,"default_branch":"master"}},"base":{"label":"guardian:master","ref":"master","sha":"1f64baf3ce511881dfc8127a38a16f3148a7ec0b","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars0.githubusercontent.com/u/164318?v=4","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":34392023,"name":"subscriptions-frontend","full_name":"guardian/subscriptions-frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars0.githubusercontent.com/u/164318?v=4","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/subscriptions-frontend","description":null,"fork":false,"url":"https://api.github.com/repos/guardian/subscriptions-frontend","forks_url":"https://api.github.com/repos/guardian/subscriptions-frontend/forks","keys_url":"https://api.github.com/repos/guardian/subscriptions-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/subscriptions-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/subscriptions-frontend/teams","hooks_url":"https://api.github.com/repos/guardian/subscriptions-frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/subscriptions-frontend/events","assignees_url":"https://api.github.com/repos/guardian/subscriptions-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/subscriptions-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/subscriptions-frontend/tags","blobs_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/subscriptions-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/subscriptions-frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/subscriptions-frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/subscriptions-frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/subscriptions-frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/subscriptions-frontend/subscription","commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/subscriptions-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/subscriptions-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/subscriptions-frontend/merges","archive_url":"https://api.github.com/repos/guardian/subscriptions-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/subscriptions-frontend/downloads","issues_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/subscriptions-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/subscriptions-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/subscriptions-frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/subscriptions-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/deployments","created_at":"2015-04-22T13:30:13Z","updated_at":"2017-08-24T12:59:55Z","pushed_at":"2017-11-13T17:19:42Z","git_url":"git://github.com/guardian/subscriptions-frontend.git","ssh_url":"git@github.com:guardian/subscriptions-frontend.git","clone_url":"https://github.com/guardian/subscriptions-frontend.git","svn_url":"https://github.com/guardian/subscriptions-frontend","homepage":"https://sites.google.com/a/guardian.co.uk/guardian-subscriptions/","size":7512,"stargazers_count":9,"watchers_count":9,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/992"},"html":{"href":"https://github.com/guardian/subscriptions-frontend/pull/992"},"issue":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/992"},"comments":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/992/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/992/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/992/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/statuses/3a99233fbfddca9edacb938855da019a25f7ea50"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"johnduffell"}}