{"action":"created","comment":{"url":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls/comments/205038410","pull_request_review_id":140227016,"id":205038410,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTAzODQxMA==","diff_hunk":"@@ -0,0 +1,97 @@\n+const { default: log } = require('@financial-times/n-logger');\n+const operation = 'erasure-search';\n+\n+async function searchUserTableByUuid (db, uuid, requestedBy) {\n+\ttry {\n+\t\tconst userTableResults = await db.run(`SELECT * FROM syndication.users WHERE user_id = '${uuid}';`);\n+\t\tlog.info({ operation, subOp: 'search-user-table-by-uuid', requestedBy, uuid, userTableResults});\n+\t\treturn { uuid, table: 'users', recordsFound: userTableResults.length };\n+\t} catch (error) {\n+\t\tthrow error;\n+\t}\n+}\n+\n+async function searchUserTableByEmail (db, email, requestedBy) {\n+\ttry {\n+\t\tconst userTableResults = await db.run(`SELECT * FROM syndication.users WHERE email = '${email}';`);\n+\t\tlog.info({ operation, subOp: 'search-user-table-by-email', requestedBy, email, userTableResults});\n+\t\treturn { email, table: 'users', recordsFound: userTableResults.length };\n+\t} catch (error) {\n+\t\tthrow error;\n+\t}\n+}\n+\n+async function searchMigratedUsersTableByUuid (db, uuid, requestedBy) {\n+\ttry {\n+\t\tconst migratedUserTableResults = await db.run(`SELECT * FROM syndication.migrated_users WHERE user_id = '${uuid}';`);\n+\t\tlog.info({ operation, subOp: 'search-migrated-user-table-by-uuid', requestedBy, uuid, migratedUserTableResults});\n+\t\treturn { uuid, table: 'migrated_users', recordsFound: migratedUserTableResults.length };\n+\t} catch (error) {\n+\t\tthrow error;\n+\t}\n+}\n+\n+function getInvalidUuids (uuids) {\n+\treturn uuids.filter(uuid => !/[a-f\\d]{8}-[a-f\\d]{4}-[a-f\\d]{4}-[a-f\\d]{4}-[a-f\\d]{12}/.test(uuid));\n+}\n+\n+function getInvalidEmails (emails) {\n+\treturn emails.filter(email => !/[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}/.test(email));\n+}\n+\n+module.exports = async (req, res, next) => {\n+\tconst requestedBy = req.cookies.s3o_username;\n+\tconst db = res.locals.$DB;\n+\tconst { erasureEmails, erasureUuids } = req.body;","path":"server/controllers/erasure-search.js","position":45,"original_position":45,"commit_id":"6d369074d1673a269fa559e115fd5946c1c955a9","original_commit_id":"6d369074d1673a269fa559e115fd5946c1c955a9","user":{"login":"kavanagh","id":684559,"node_id":"MDQ6VXNlcjY4NDU1OQ==","avatar_url":"https://avatars3.githubusercontent.com/u/684559?v=4","gravatar_id":"","url":"https://api.github.com/users/kavanagh","html_url":"https://github.com/kavanagh","followers_url":"https://api.github.com/users/kavanagh/followers","following_url":"https://api.github.com/users/kavanagh/following{/other_user}","gists_url":"https://api.github.com/users/kavanagh/gists{/gist_id}","starred_url":"https://api.github.com/users/kavanagh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kavanagh/subscriptions","organizations_url":"https://api.github.com/users/kavanagh/orgs","repos_url":"https://api.github.com/users/kavanagh/repos","events_url":"https://api.github.com/users/kavanagh/events{/privacy}","received_events_url":"https://api.github.com/users/kavanagh/received_events","type":"User","site_admin":false},"body":"Perhaps validate/sanitise the inputs here and throw when there are bad inputs (and return a 400 error to the client).","created_at":"2018-07-25T09:19:40Z","updated_at":"2018-07-25T09:21:50Z","html_url":"https://github.com/Financial-Times/next-syndication-api/pull/77#discussion_r205038410","pull_request_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls/77","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls/comments/205038410"},"html":{"href":"https://github.com/Financial-Times/next-syndication-api/pull/77#discussion_r205038410"},"pull_request":{"href":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls/77"}}},"pull_request":{"url":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls/77","id":202603378,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAyNjAzMzc4","html_url":"https://github.com/Financial-Times/next-syndication-api/pull/77","diff_url":"https://github.com/Financial-Times/next-syndication-api/pull/77.diff","patch_url":"https://github.com/Financial-Times/next-syndication-api/pull/77.patch","issue_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/issues/77","number":77,"state":"open","locked":false,"title":"GDPR erasure screen","user":{"login":"dapenguin","id":6975428,"node_id":"MDQ6VXNlcjY5NzU0Mjg=","avatar_url":"https://avatars2.githubusercontent.com/u/6975428?v=4","gravatar_id":"","url":"https://api.github.com/users/dapenguin","html_url":"https://github.com/dapenguin","followers_url":"https://api.github.com/users/dapenguin/followers","following_url":"https://api.github.com/users/dapenguin/following{/other_user}","gists_url":"https://api.github.com/users/dapenguin/gists{/gist_id}","starred_url":"https://api.github.com/users/dapenguin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dapenguin/subscriptions","organizations_url":"https://api.github.com/users/dapenguin/orgs","repos_url":"https://api.github.com/users/dapenguin/repos","events_url":"https://api.github.com/users/dapenguin/events{/privacy}","received_events_url":"https://api.github.com/users/dapenguin/received_events","type":"User","site_admin":false},"body":"No tests I'm afraid, but can add these on a hygiene day","created_at":"2018-07-19T15:42:42Z","updated_at":"2018-07-25T09:21:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aa25e4ed91b3e79a0c2cc40e1ddb438f11eb3bc9","assignee":null,"assignees":[],"requested_reviewers":[{"login":"leggsimon","id":11544418,"node_id":"MDQ6VXNlcjExNTQ0NDE4","avatar_url":"https://avatars2.githubusercontent.com/u/11544418?v=4","gravatar_id":"","url":"https://api.github.com/users/leggsimon","html_url":"https://github.com/leggsimon","followers_url":"https://api.github.com/users/leggsimon/followers","following_url":"https://api.github.com/users/leggsimon/following{/other_user}","gists_url":"https://api.github.com/users/leggsimon/gists{/gist_id}","starred_url":"https://api.github.com/users/leggsimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leggsimon/subscriptions","organizations_url":"https://api.github.com/users/leggsimon/orgs","repos_url":"https://api.github.com/users/leggsimon/repos","events_url":"https://api.github.com/users/leggsimon/events{/privacy}","received_events_url":"https://api.github.com/users/leggsimon/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls/77/commits","review_comments_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls/77/comments","review_comment_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/issues/77/comments","statuses_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/statuses/6d369074d1673a269fa559e115fd5946c1c955a9","head":{"label":"Financial-Times:gdpr-erasure","ref":"gdpr-erasure","sha":"6d369074d1673a269fa559e115fd5946c1c955a9","user":{"login":"Financial-Times","id":3502508,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1MDI1MDg=","avatar_url":"https://avatars1.githubusercontent.com/u/3502508?v=4","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"repo":{"id":87204150,"node_id":"MDEwOlJlcG9zaXRvcnk4NzIwNDE1MA==","name":"next-syndication-api","full_name":"Financial-Times/next-syndication-api","owner":{"login":"Financial-Times","id":3502508,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1MDI1MDg=","avatar_url":"https://avatars1.githubusercontent.com/u/3502508?v=4","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Financial-Times/next-syndication-api","description":null,"fork":false,"url":"https://api.github.com/repos/Financial-Times/next-syndication-api","forks_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/forks","keys_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/teams","hooks_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/hooks","issue_events_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/issues/events{/number}","events_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/events","assignees_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/assignees{/user}","branches_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/branches{/branch}","tags_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/tags","blobs_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/statuses/{sha}","languages_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/languages","stargazers_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/stargazers","contributors_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/contributors","subscribers_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/subscribers","subscription_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/subscription","commits_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/contents/{+path}","compare_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/merges","archive_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/downloads","issues_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/issues{/number}","pulls_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls{/number}","milestones_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/milestones{/number}","notifications_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/labels{/name}","releases_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/releases{/id}","deployments_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/deployments","created_at":"2017-04-04T15:33:22Z","updated_at":"2018-06-19T09:52:11Z","pushed_at":"2018-07-19T15:42:43Z","git_url":"git://github.com/Financial-Times/next-syndication-api.git","ssh_url":"git@github.com:Financial-Times/next-syndication-api.git","clone_url":"https://github.com/Financial-Times/next-syndication-api.git","svn_url":"https://github.com/Financial-Times/next-syndication-api","homepage":null,"size":28693,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"Financial-Times:master","ref":"master","sha":"5708e8bdb08a65a5fc784a9eccca5c1f80ebd7bf","user":{"login":"Financial-Times","id":3502508,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1MDI1MDg=","avatar_url":"https://avatars1.githubusercontent.com/u/3502508?v=4","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"repo":{"id":87204150,"node_id":"MDEwOlJlcG9zaXRvcnk4NzIwNDE1MA==","name":"next-syndication-api","full_name":"Financial-Times/next-syndication-api","owner":{"login":"Financial-Times","id":3502508,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1MDI1MDg=","avatar_url":"https://avatars1.githubusercontent.com/u/3502508?v=4","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Financial-Times/next-syndication-api","description":null,"fork":false,"url":"https://api.github.com/repos/Financial-Times/next-syndication-api","forks_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/forks","keys_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/teams","hooks_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/hooks","issue_events_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/issues/events{/number}","events_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/events","assignees_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/assignees{/user}","branches_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/branches{/branch}","tags_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/tags","blobs_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/statuses/{sha}","languages_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/languages","stargazers_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/stargazers","contributors_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/contributors","subscribers_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/subscribers","subscription_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/subscription","commits_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/contents/{+path}","compare_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/merges","archive_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/downloads","issues_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/issues{/number}","pulls_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls{/number}","milestones_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/milestones{/number}","notifications_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/labels{/name}","releases_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/releases{/id}","deployments_url":"https://api.github.com/repos/Financial-Times/next-syndication-api/deployments","created_at":"2017-04-04T15:33:22Z","updated_at":"2018-06-19T09:52:11Z","pushed_at":"2018-07-19T15:42:43Z","git_url":"git://github.com/Financial-Times/next-syndication-api.git","ssh_url":"git@github.com:Financial-Times/next-syndication-api.git","clone_url":"https://github.com/Financial-Times/next-syndication-api.git","svn_url":"https://github.com/Financial-Times/next-syndication-api","homepage":null,"size":28693,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls/77"},"html":{"href":"https://github.com/Financial-Times/next-syndication-api/pull/77"},"issue":{"href":"https://api.github.com/repos/Financial-Times/next-syndication-api/issues/77"},"comments":{"href":"https://api.github.com/repos/Financial-Times/next-syndication-api/issues/77/comments"},"review_comments":{"href":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls/77/comments"},"review_comment":{"href":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Financial-Times/next-syndication-api/pulls/77/commits"},"statuses":{"href":"https://api.github.com/repos/Financial-Times/next-syndication-api/statuses/6d369074d1673a269fa559e115fd5946c1c955a9"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"kavanagh"}}