{"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/email-alert-service/pulls/comments/42853093","id":42853093,"diff_hunk":"@@ -49,12 +49,12 @@ def trigger_email_alert(document)\n     EmailAlert.new(document, @logger).trigger\n   end\n \n-  def tagged_to_topics?(document)\n-    details = document.fetch(\"details\", {})\n-    if details.has_key?(\"tags\") && details.fetch(\"tags\").has_key?(\"topics\")\n-      details.fetch(\"tags\").fetch(\"topics\").any?\n-    else\n-      false\n+  def email_alerts_supported?(document)\n+    document_tags = document.fetch(\"details\", {}).fetch(\"tags\", {})\n+    supported_tag_names = [\"topics\", \"policy\"]\n+\n+    supported_tag_names.any? do |tag_name|\n+      !(document_tags[tag_name].nil? || document_tags[tag_name].empty?)","path":"email_alert_service/models/message_processor.rb","position":24,"original_position":24,"commit_id":"1c9b340d2c3ccd4ce96ca613d51d27e3ec24b153","original_commit_id":"1c9b340d2c3ccd4ce96ca613d51d27e3ec24b153","user":{"login":"tijmenb","id":233676,"avatar_url":"https://avatars.githubusercontent.com/u/233676?v=3","gravatar_id":"","url":"https://api.github.com/users/tijmenb","html_url":"https://github.com/tijmenb","followers_url":"https://api.github.com/users/tijmenb/followers","following_url":"https://api.github.com/users/tijmenb/following{/other_user}","gists_url":"https://api.github.com/users/tijmenb/gists{/gist_id}","starred_url":"https://api.github.com/users/tijmenb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tijmenb/subscriptions","organizations_url":"https://api.github.com/users/tijmenb/orgs","repos_url":"https://api.github.com/users/tijmenb/repos","events_url":"https://api.github.com/users/tijmenb/events{/privacy}","received_events_url":"https://api.github.com/users/tijmenb/received_events","type":"User","site_admin":false},"body":"Would something like this work too? \r\n\r\n```ruby\r\nsupported_tag_names.any? do |tag_name|\r\n  document_tags[tag_name] && document_tags[tag_name].any?\r\nend\r\n```","created_at":"2015-10-23T10:51:25Z","updated_at":"2015-10-23T10:51:25Z","html_url":"https://github.com/alphagov/email-alert-service/pull/41#discussion_r42853093","pull_request_url":"https://api.github.com/repos/alphagov/email-alert-service/pulls/41","_links":{"self":{"href":"https://api.github.com/repos/alphagov/email-alert-service/pulls/comments/42853093"},"html":{"href":"https://github.com/alphagov/email-alert-service/pull/41#discussion_r42853093"},"pull_request":{"href":"https://api.github.com/repos/alphagov/email-alert-service/pulls/41"}}},"pull_request":{"url":"https://api.github.com/repos/alphagov/email-alert-service/pulls/41","id":48564340,"html_url":"https://github.com/alphagov/email-alert-service/pull/41","diff_url":"https://github.com/alphagov/email-alert-service/pull/41.diff","patch_url":"https://github.com/alphagov/email-alert-service/pull/41.patch","issue_url":"https://api.github.com/repos/alphagov/email-alert-service/issues/41","number":41,"state":"closed","locked":false,"title":"Add support for policy email alerts","user":{"login":"mobaig","id":519250,"avatar_url":"https://avatars.githubusercontent.com/u/519250?v=3","gravatar_id":"","url":"https://api.github.com/users/mobaig","html_url":"https://github.com/mobaig","followers_url":"https://api.github.com/users/mobaig/followers","following_url":"https://api.github.com/users/mobaig/following{/other_user}","gists_url":"https://api.github.com/users/mobaig/gists{/gist_id}","starred_url":"https://api.github.com/users/mobaig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mobaig/subscriptions","organizations_url":"https://api.github.com/users/mobaig/orgs","repos_url":"https://api.github.com/users/mobaig/repos","events_url":"https://api.github.com/users/mobaig/events{/privacy}","received_events_url":"https://api.github.com/users/mobaig/received_events","type":"User","site_admin":false},"body":"Currently the email alert service explicitly checks for the presence of\r\ntopic tags as a pre-requisite for sending email alerts. This prevents\r\npolicy alerts from being sent. This commit adds support for policies.\r\n\r\nTrello: https://trello.com/c/SbzetTvB/388-fix-policy-email-alerts","created_at":"2015-10-23T10:29:29Z","updated_at":"2015-10-23T10:51:25Z","closed_at":"2015-10-23T10:32:56Z","merged_at":"2015-10-23T10:32:56Z","merge_commit_sha":"55d386c7f250b231ae3abee94e1e1daa8c5dc4be","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/email-alert-service/pulls/41/commits","review_comments_url":"https://api.github.com/repos/alphagov/email-alert-service/pulls/41/comments","review_comment_url":"https://api.github.com/repos/alphagov/email-alert-service/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/email-alert-service/issues/41/comments","statuses_url":"https://api.github.com/repos/alphagov/email-alert-service/statuses/1c9b340d2c3ccd4ce96ca613d51d27e3ec24b153","head":{"label":"alphagov:mb_support_policy_alert","ref":"mb_support_policy_alert","sha":"1c9b340d2c3ccd4ce96ca613d51d27e3ec24b153","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":24410344,"name":"email-alert-service","full_name":"alphagov/email-alert-service","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/email-alert-service","description":"Message queue consumer that triggers email alerts","fork":false,"url":"https://api.github.com/repos/alphagov/email-alert-service","forks_url":"https://api.github.com/repos/alphagov/email-alert-service/forks","keys_url":"https://api.github.com/repos/alphagov/email-alert-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/email-alert-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/email-alert-service/teams","hooks_url":"https://api.github.com/repos/alphagov/email-alert-service/hooks","issue_events_url":"https://api.github.com/repos/alphagov/email-alert-service/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/email-alert-service/events","assignees_url":"https://api.github.com/repos/alphagov/email-alert-service/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/email-alert-service/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/email-alert-service/tags","blobs_url":"https://api.github.com/repos/alphagov/email-alert-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/email-alert-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/email-alert-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/email-alert-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/email-alert-service/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/email-alert-service/languages","stargazers_url":"https://api.github.com/repos/alphagov/email-alert-service/stargazers","contributors_url":"https://api.github.com/repos/alphagov/email-alert-service/contributors","subscribers_url":"https://api.github.com/repos/alphagov/email-alert-service/subscribers","subscription_url":"https://api.github.com/repos/alphagov/email-alert-service/subscription","commits_url":"https://api.github.com/repos/alphagov/email-alert-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/email-alert-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/email-alert-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/email-alert-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/email-alert-service/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/email-alert-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/email-alert-service/merges","archive_url":"https://api.github.com/repos/alphagov/email-alert-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/email-alert-service/downloads","issues_url":"https://api.github.com/repos/alphagov/email-alert-service/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/email-alert-service/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/email-alert-service/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/email-alert-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/email-alert-service/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/email-alert-service/releases{/id}","created_at":"2014-09-24T10:14:32Z","updated_at":"2014-12-16T12:13:58Z","pushed_at":"2015-10-23T10:34:01Z","git_url":"git://github.com/alphagov/email-alert-service.git","ssh_url":"git@github.com:alphagov/email-alert-service.git","clone_url":"https://github.com/alphagov/email-alert-service.git","svn_url":"https://github.com/alphagov/email-alert-service","homepage":null,"size":872,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"c72e1e38ddb6a963a2ad5dcb919bc85e39888f4f","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":24410344,"name":"email-alert-service","full_name":"alphagov/email-alert-service","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/email-alert-service","description":"Message queue consumer that triggers email alerts","fork":false,"url":"https://api.github.com/repos/alphagov/email-alert-service","forks_url":"https://api.github.com/repos/alphagov/email-alert-service/forks","keys_url":"https://api.github.com/repos/alphagov/email-alert-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/email-alert-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/email-alert-service/teams","hooks_url":"https://api.github.com/repos/alphagov/email-alert-service/hooks","issue_events_url":"https://api.github.com/repos/alphagov/email-alert-service/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/email-alert-service/events","assignees_url":"https://api.github.com/repos/alphagov/email-alert-service/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/email-alert-service/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/email-alert-service/tags","blobs_url":"https://api.github.com/repos/alphagov/email-alert-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/email-alert-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/email-alert-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/email-alert-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/email-alert-service/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/email-alert-service/languages","stargazers_url":"https://api.github.com/repos/alphagov/email-alert-service/stargazers","contributors_url":"https://api.github.com/repos/alphagov/email-alert-service/contributors","subscribers_url":"https://api.github.com/repos/alphagov/email-alert-service/subscribers","subscription_url":"https://api.github.com/repos/alphagov/email-alert-service/subscription","commits_url":"https://api.github.com/repos/alphagov/email-alert-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/email-alert-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/email-alert-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/email-alert-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/email-alert-service/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/email-alert-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/email-alert-service/merges","archive_url":"https://api.github.com/repos/alphagov/email-alert-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/email-alert-service/downloads","issues_url":"https://api.github.com/repos/alphagov/email-alert-service/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/email-alert-service/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/email-alert-service/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/email-alert-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/email-alert-service/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/email-alert-service/releases{/id}","created_at":"2014-09-24T10:14:32Z","updated_at":"2014-12-16T12:13:58Z","pushed_at":"2015-10-23T10:34:01Z","git_url":"git://github.com/alphagov/email-alert-service.git","ssh_url":"git@github.com:alphagov/email-alert-service.git","clone_url":"https://github.com/alphagov/email-alert-service.git","svn_url":"https://github.com/alphagov/email-alert-service","homepage":null,"size":872,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/email-alert-service/pulls/41"},"html":{"href":"https://github.com/alphagov/email-alert-service/pull/41"},"issue":{"href":"https://api.github.com/repos/alphagov/email-alert-service/issues/41"},"comments":{"href":"https://api.github.com/repos/alphagov/email-alert-service/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/email-alert-service/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/email-alert-service/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/email-alert-service/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/email-alert-service/statuses/1c9b340d2c3ccd4ce96ca613d51d27e3ec24b153"}}}}