{"action":"created","comment":{"url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls/comments/172130896","pull_request_review_id":101095004,"id":172130896,"diff_hunk":"@@ -343,15 +357,25 @@ export function CreateMessageHandler(\n       return ResponseErrorForbiddenNotAuthorizedForDefaultAddresses;\n     }\n \n+    const timeToLive = TimeToLive.decode(messagePayload.time_to_live);","path":"lib/controllers/messages.ts","position":94,"original_position":94,"commit_id":"ae38da76c73362c082e799ca6d78b3d2ed3bad19","original_commit_id":"ae38da76c73362c082e799ca6d78b3d2ed3bad19","user":{"login":"cloudify","id":48206,"avatar_url":"https://avatars2.githubusercontent.com/u/48206?v=4","gravatar_id":"","url":"https://api.github.com/users/cloudify","html_url":"https://github.com/cloudify","followers_url":"https://api.github.com/users/cloudify/followers","following_url":"https://api.github.com/users/cloudify/following{/other_user}","gists_url":"https://api.github.com/users/cloudify/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify/subscriptions","organizations_url":"https://api.github.com/users/cloudify/orgs","repos_url":"https://api.github.com/users/cloudify/repos","events_url":"https://api.github.com/users/cloudify/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify/received_events","type":"User","site_admin":false},"body":"Just keep this in mind: decoding and validation must happen only at the system boundary (e.g. with network or disk) - the responsibility of a middleware is to do this validation (decode `any` to a well defined type), ensuring that their output doesn't ever need to be validated again (indeed this is possible only when a type system can carry this information, like in Typescript).\r\n\r\nSo when you find yourself to have to do a validation inside the system, that is a smell of incorrect design of types.","created_at":"2018-03-05T09:38:47Z","updated_at":"2018-03-05T09:38:47Z","html_url":"https://github.com/teamdigitale/digital-citizenship-functions/pull/158#discussion_r172130896","pull_request_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls/158","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls/comments/172130896"},"html":{"href":"https://github.com/teamdigitale/digital-citizenship-functions/pull/158#discussion_r172130896"},"pull_request":{"href":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls/158"}},"in_reply_to_id":172068903},"pull_request":{"url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls/158","id":172670937,"html_url":"https://github.com/teamdigitale/digital-citizenship-functions/pull/158","diff_url":"https://github.com/teamdigitale/digital-citizenship-functions/pull/158.diff","patch_url":"https://github.com/teamdigitale/digital-citizenship-functions/pull/158.patch","issue_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/issues/158","number":158,"state":"open","locked":false,"title":"[#150588117] WIP added time to live check to email notification handler","user":{"login":"gunzip","id":148224,"avatar_url":"https://avatars2.githubusercontent.com/u/148224?v=4","gravatar_id":"","url":"https://api.github.com/users/gunzip","html_url":"https://github.com/gunzip","followers_url":"https://api.github.com/users/gunzip/followers","following_url":"https://api.github.com/users/gunzip/following{/other_user}","gists_url":"https://api.github.com/users/gunzip/gists{/gist_id}","starred_url":"https://api.github.com/users/gunzip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gunzip/subscriptions","organizations_url":"https://api.github.com/users/gunzip/orgs","repos_url":"https://api.github.com/users/gunzip/repos","events_url":"https://api.github.com/users/gunzip/events{/privacy}","received_events_url":"https://api.github.com/users/gunzip/received_events","type":"User","site_admin":false},"body":"Between the main changes, note that with this PR [the whole Message is passed in the NotificationEvent](https://github.com/teamdigitale/digital-citizenship-functions/pull/158/files#diff-369872c88999ee654209f0771aaa8f25R129) (queue) while actually we pass only some fields:\r\n\r\n- added two fields (createAt, timeToLive) to the MessageModel\r\n- added a type (NotExpiredMessage) that checks that Date.now() < createdAt + timeToLive\r\n- update notification status in case of error / expire\r\n- refactor queue handlers to simplify error handling (ie. avoid try / catch blocks in index, pushed error logging at the end of the index method)\r\n","created_at":"2018-03-03T15:02:02Z","updated_at":"2018-03-05T09:38:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"120dc27d130f14a3d0e549a867a71e39e44dfb3f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls/158/commits","review_comments_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls/158/comments","review_comment_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls/comments{/number}","comments_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/issues/158/comments","statuses_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/statuses/ae38da76c73362c082e799ca6d78b3d2ed3bad19","head":{"label":"teamdigitale:150588117-timetolive","ref":"150588117-timetolive","sha":"ae38da76c73362c082e799ca6d78b3d2ed3bad19","user":{"login":"teamdigitale","id":25081492,"avatar_url":"https://avatars0.githubusercontent.com/u/25081492?v=4","gravatar_id":"","url":"https://api.github.com/users/teamdigitale","html_url":"https://github.com/teamdigitale","followers_url":"https://api.github.com/users/teamdigitale/followers","following_url":"https://api.github.com/users/teamdigitale/following{/other_user}","gists_url":"https://api.github.com/users/teamdigitale/gists{/gist_id}","starred_url":"https://api.github.com/users/teamdigitale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teamdigitale/subscriptions","organizations_url":"https://api.github.com/users/teamdigitale/orgs","repos_url":"https://api.github.com/users/teamdigitale/repos","events_url":"https://api.github.com/users/teamdigitale/events{/privacy}","received_events_url":"https://api.github.com/users/teamdigitale/received_events","type":"Organization","site_admin":false},"repo":{"id":98789853,"name":"digital-citizenship-functions","full_name":"teamdigitale/digital-citizenship-functions","owner":{"login":"teamdigitale","id":25081492,"avatar_url":"https://avatars0.githubusercontent.com/u/25081492?v=4","gravatar_id":"","url":"https://api.github.com/users/teamdigitale","html_url":"https://github.com/teamdigitale","followers_url":"https://api.github.com/users/teamdigitale/followers","following_url":"https://api.github.com/users/teamdigitale/following{/other_user}","gists_url":"https://api.github.com/users/teamdigitale/gists{/gist_id}","starred_url":"https://api.github.com/users/teamdigitale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teamdigitale/subscriptions","organizations_url":"https://api.github.com/users/teamdigitale/orgs","repos_url":"https://api.github.com/users/teamdigitale/repos","events_url":"https://api.github.com/users/teamdigitale/events{/privacy}","received_events_url":"https://api.github.com/users/teamdigitale/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/teamdigitale/digital-citizenship-functions","description":"Digital Citizenship APIs","fork":false,"url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions","forks_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/forks","keys_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/teams","hooks_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/hooks","issue_events_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/issues/events{/number}","events_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/events","assignees_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/assignees{/user}","branches_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/branches{/branch}","tags_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/tags","blobs_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/git/refs{/sha}","trees_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/statuses/{sha}","languages_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/languages","stargazers_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/stargazers","contributors_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/contributors","subscribers_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/subscribers","subscription_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/subscription","commits_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/commits{/sha}","git_commits_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/git/commits{/sha}","comments_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/comments{/number}","issue_comment_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/issues/comments{/number}","contents_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/contents/{+path}","compare_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/merges","archive_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/downloads","issues_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/issues{/number}","pulls_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls{/number}","milestones_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/milestones{/number}","notifications_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/labels{/name}","releases_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/releases{/id}","deployments_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/deployments","created_at":"2017-07-30T10:19:53Z","updated_at":"2018-02-02T21:40:48Z","pushed_at":"2018-03-04T15:12:13Z","git_url":"git://github.com/teamdigitale/digital-citizenship-functions.git","ssh_url":"git@github.com:teamdigitale/digital-citizenship-functions.git","clone_url":"https://github.com/teamdigitale/digital-citizenship-functions.git","svn_url":"https://github.com/teamdigitale/digital-citizenship-functions","homepage":"","size":4292,"stargazers_count":3,"watchers_count":3,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":5,"open_issues":2,"watchers":3,"default_branch":"master"}},"base":{"label":"teamdigitale:master","ref":"master","sha":"769a6905819ec8036c80d2238ba1b402abd527d3","user":{"login":"teamdigitale","id":25081492,"avatar_url":"https://avatars0.githubusercontent.com/u/25081492?v=4","gravatar_id":"","url":"https://api.github.com/users/teamdigitale","html_url":"https://github.com/teamdigitale","followers_url":"https://api.github.com/users/teamdigitale/followers","following_url":"https://api.github.com/users/teamdigitale/following{/other_user}","gists_url":"https://api.github.com/users/teamdigitale/gists{/gist_id}","starred_url":"https://api.github.com/users/teamdigitale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teamdigitale/subscriptions","organizations_url":"https://api.github.com/users/teamdigitale/orgs","repos_url":"https://api.github.com/users/teamdigitale/repos","events_url":"https://api.github.com/users/teamdigitale/events{/privacy}","received_events_url":"https://api.github.com/users/teamdigitale/received_events","type":"Organization","site_admin":false},"repo":{"id":98789853,"name":"digital-citizenship-functions","full_name":"teamdigitale/digital-citizenship-functions","owner":{"login":"teamdigitale","id":25081492,"avatar_url":"https://avatars0.githubusercontent.com/u/25081492?v=4","gravatar_id":"","url":"https://api.github.com/users/teamdigitale","html_url":"https://github.com/teamdigitale","followers_url":"https://api.github.com/users/teamdigitale/followers","following_url":"https://api.github.com/users/teamdigitale/following{/other_user}","gists_url":"https://api.github.com/users/teamdigitale/gists{/gist_id}","starred_url":"https://api.github.com/users/teamdigitale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teamdigitale/subscriptions","organizations_url":"https://api.github.com/users/teamdigitale/orgs","repos_url":"https://api.github.com/users/teamdigitale/repos","events_url":"https://api.github.com/users/teamdigitale/events{/privacy}","received_events_url":"https://api.github.com/users/teamdigitale/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/teamdigitale/digital-citizenship-functions","description":"Digital Citizenship APIs","fork":false,"url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions","forks_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/forks","keys_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/teams","hooks_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/hooks","issue_events_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/issues/events{/number}","events_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/events","assignees_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/assignees{/user}","branches_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/branches{/branch}","tags_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/tags","blobs_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/git/refs{/sha}","trees_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/statuses/{sha}","languages_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/languages","stargazers_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/stargazers","contributors_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/contributors","subscribers_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/subscribers","subscription_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/subscription","commits_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/commits{/sha}","git_commits_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/git/commits{/sha}","comments_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/comments{/number}","issue_comment_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/issues/comments{/number}","contents_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/contents/{+path}","compare_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/merges","archive_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/downloads","issues_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/issues{/number}","pulls_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls{/number}","milestones_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/milestones{/number}","notifications_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/labels{/name}","releases_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/releases{/id}","deployments_url":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/deployments","created_at":"2017-07-30T10:19:53Z","updated_at":"2018-02-02T21:40:48Z","pushed_at":"2018-03-04T15:12:13Z","git_url":"git://github.com/teamdigitale/digital-citizenship-functions.git","ssh_url":"git@github.com:teamdigitale/digital-citizenship-functions.git","clone_url":"https://github.com/teamdigitale/digital-citizenship-functions.git","svn_url":"https://github.com/teamdigitale/digital-citizenship-functions","homepage":"","size":4292,"stargazers_count":3,"watchers_count":3,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":5,"open_issues":2,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls/158"},"html":{"href":"https://github.com/teamdigitale/digital-citizenship-functions/pull/158"},"issue":{"href":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/issues/158"},"comments":{"href":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/issues/158/comments"},"review_comments":{"href":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls/158/comments"},"review_comment":{"href":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/pulls/158/commits"},"statuses":{"href":"https://api.github.com/repos/teamdigitale/digital-citizenship-functions/statuses/ae38da76c73362c082e799ca6d78b3d2ed3bad19"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"cloudify"}}