{"action":"created","comment":{"url":"https://api.github.com/repos/cantino/huginn/pulls/comments/55171575","id":55171575,"diff_hunk":"@@ -37,19 +37,27 @@ def default_options\n       }\n     end\n \n+    def working?\n+      received_event_without_error?\n+    end\n+\n     def receive(incoming_events)\n       incoming_events.each do |event|\n         recipients(event.payload).each do |recipient|\n-          log \"Sending mail to #{recipient} with event #{event.id}\"\n-          SystemMailer.send_message(\n-            to: recipient,\n-            from: interpolated(event)['from'],\n-            subject: interpolated(event)['subject'],\n-            headline: interpolated(event)['headline'],\n-            body: interpolated(event)['body'],\n-            content_type: interpolated(event)['content_type'],\n-            groups: [present(event.payload)]\n-          ).deliver_later\n+          begin\n+            SystemMailer.send_message(\n+              to: recipient,\n+              from: interpolated(event)['from'],\n+              subject: interpolated(event)['subject'],\n+              headline: interpolated(event)['headline'],\n+              body: interpolated(event)['body'],\n+              content_type: interpolated(event)['content_type'],\n+              groups: [present(event.payload)]\n+            ).deliver_now\n+            log \"Sent mail to #{recipient} with event #{event.id}\"\n+          rescue => e\n+            error(\"Error sending mail to #{recipient} with event #{event.id}: #{e.message}\")","path":"app/models/agents/email_agent.rb","position":33,"original_position":33,"commit_id":"c1bc45707788e085a3acd50b2a97ae194fc31d79","original_commit_id":"c1bc45707788e085a3acd50b2a97ae194fc31d79","user":{"login":"dsander","id":20943,"avatar_url":"https://avatars.githubusercontent.com/u/20943?v=3","gravatar_id":"","url":"https://api.github.com/users/dsander","html_url":"https://github.com/dsander","followers_url":"https://api.github.com/users/dsander/followers","following_url":"https://api.github.com/users/dsander/following{/other_user}","gists_url":"https://api.github.com/users/dsander/gists{/gist_id}","starred_url":"https://api.github.com/users/dsander/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsander/subscriptions","organizations_url":"https://api.github.com/users/dsander/orgs","repos_url":"https://api.github.com/users/dsander/repos","events_url":"https://api.github.com/users/dsander/events{/privacy}","received_events_url":"https://api.github.com/users/dsander/received_events","type":"User","site_admin":false},"body":"If we re-raise it might be good to add `no_bulk_receive!`","created_at":"2016-03-07T08:06:40Z","updated_at":"2016-03-07T08:06:40Z","html_url":"https://github.com/cantino/huginn/pull/1335#discussion_r55171575","pull_request_url":"https://api.github.com/repos/cantino/huginn/pulls/1335","_links":{"self":{"href":"https://api.github.com/repos/cantino/huginn/pulls/comments/55171575"},"html":{"href":"https://github.com/cantino/huginn/pull/1335#discussion_r55171575"},"pull_request":{"href":"https://api.github.com/repos/cantino/huginn/pulls/1335"}}},"pull_request":{"url":"https://api.github.com/repos/cantino/huginn/pulls/1335","id":61863404,"html_url":"https://github.com/cantino/huginn/pull/1335","diff_url":"https://github.com/cantino/huginn/pull/1335.diff","patch_url":"https://github.com/cantino/huginn/pull/1335.patch","issue_url":"https://api.github.com/repos/cantino/huginn/issues/1335","number":1335,"state":"open","locked":false,"title":"Rescue and log email sending errors","user":{"login":"cantino","id":83835,"avatar_url":"https://avatars.githubusercontent.com/u/83835?v=3","gravatar_id":"","url":"https://api.github.com/users/cantino","html_url":"https://github.com/cantino","followers_url":"https://api.github.com/users/cantino/followers","following_url":"https://api.github.com/users/cantino/following{/other_user}","gists_url":"https://api.github.com/users/cantino/gists{/gist_id}","starred_url":"https://api.github.com/users/cantino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cantino/subscriptions","organizations_url":"https://api.github.com/users/cantino/orgs","repos_url":"https://api.github.com/users/cantino/repos","events_url":"https://api.github.com/users/cantino/events{/privacy}","received_events_url":"https://api.github.com/users/cantino/received_events","type":"User","site_admin":false},"body":"Replaces #1300 with a more thread-safe appracoh.\r\n\r\n@dsander, see any downside to just sending emails immediately instead of using jobs since we're inside a job anyway?","created_at":"2016-03-07T01:32:20Z","updated_at":"2016-03-07T08:06:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"308a4f2faa01fb2dd90770e114909c88a35f5307","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cantino/huginn/pulls/1335/commits","review_comments_url":"https://api.github.com/repos/cantino/huginn/pulls/1335/comments","review_comment_url":"https://api.github.com/repos/cantino/huginn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cantino/huginn/issues/1335/comments","statuses_url":"https://api.github.com/repos/cantino/huginn/statuses/c1bc45707788e085a3acd50b2a97ae194fc31d79","head":{"label":"cantino:rescue_mail_errors","ref":"rescue_mail_errors","sha":"c1bc45707788e085a3acd50b2a97ae194fc31d79","user":{"login":"cantino","id":83835,"avatar_url":"https://avatars.githubusercontent.com/u/83835?v=3","gravatar_id":"","url":"https://api.github.com/users/cantino","html_url":"https://github.com/cantino","followers_url":"https://api.github.com/users/cantino/followers","following_url":"https://api.github.com/users/cantino/following{/other_user}","gists_url":"https://api.github.com/users/cantino/gists{/gist_id}","starred_url":"https://api.github.com/users/cantino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cantino/subscriptions","organizations_url":"https://api.github.com/users/cantino/orgs","repos_url":"https://api.github.com/users/cantino/repos","events_url":"https://api.github.com/users/cantino/events{/privacy}","received_events_url":"https://api.github.com/users/cantino/received_events","type":"User","site_admin":false},"repo":{"id":8681349,"name":"huginn","full_name":"cantino/huginn","owner":{"login":"cantino","id":83835,"avatar_url":"https://avatars.githubusercontent.com/u/83835?v=3","gravatar_id":"","url":"https://api.github.com/users/cantino","html_url":"https://github.com/cantino","followers_url":"https://api.github.com/users/cantino/followers","following_url":"https://api.github.com/users/cantino/following{/other_user}","gists_url":"https://api.github.com/users/cantino/gists{/gist_id}","starred_url":"https://api.github.com/users/cantino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cantino/subscriptions","organizations_url":"https://api.github.com/users/cantino/orgs","repos_url":"https://api.github.com/users/cantino/repos","events_url":"https://api.github.com/users/cantino/events{/privacy}","received_events_url":"https://api.github.com/users/cantino/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cantino/huginn","description":"Build agents that monitor and act on your behalf.  Your agents are standing by!","fork":false,"url":"https://api.github.com/repos/cantino/huginn","forks_url":"https://api.github.com/repos/cantino/huginn/forks","keys_url":"https://api.github.com/repos/cantino/huginn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cantino/huginn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cantino/huginn/teams","hooks_url":"https://api.github.com/repos/cantino/huginn/hooks","issue_events_url":"https://api.github.com/repos/cantino/huginn/issues/events{/number}","events_url":"https://api.github.com/repos/cantino/huginn/events","assignees_url":"https://api.github.com/repos/cantino/huginn/assignees{/user}","branches_url":"https://api.github.com/repos/cantino/huginn/branches{/branch}","tags_url":"https://api.github.com/repos/cantino/huginn/tags","blobs_url":"https://api.github.com/repos/cantino/huginn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cantino/huginn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cantino/huginn/git/refs{/sha}","trees_url":"https://api.github.com/repos/cantino/huginn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cantino/huginn/statuses/{sha}","languages_url":"https://api.github.com/repos/cantino/huginn/languages","stargazers_url":"https://api.github.com/repos/cantino/huginn/stargazers","contributors_url":"https://api.github.com/repos/cantino/huginn/contributors","subscribers_url":"https://api.github.com/repos/cantino/huginn/subscribers","subscription_url":"https://api.github.com/repos/cantino/huginn/subscription","commits_url":"https://api.github.com/repos/cantino/huginn/commits{/sha}","git_commits_url":"https://api.github.com/repos/cantino/huginn/git/commits{/sha}","comments_url":"https://api.github.com/repos/cantino/huginn/comments{/number}","issue_comment_url":"https://api.github.com/repos/cantino/huginn/issues/comments{/number}","contents_url":"https://api.github.com/repos/cantino/huginn/contents/{+path}","compare_url":"https://api.github.com/repos/cantino/huginn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cantino/huginn/merges","archive_url":"https://api.github.com/repos/cantino/huginn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cantino/huginn/downloads","issues_url":"https://api.github.com/repos/cantino/huginn/issues{/number}","pulls_url":"https://api.github.com/repos/cantino/huginn/pulls{/number}","milestones_url":"https://api.github.com/repos/cantino/huginn/milestones{/number}","notifications_url":"https://api.github.com/repos/cantino/huginn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cantino/huginn/labels{/name}","releases_url":"https://api.github.com/repos/cantino/huginn/releases{/id}","deployments_url":"https://api.github.com/repos/cantino/huginn/deployments","created_at":"2013-03-10T06:00:31Z","updated_at":"2016-03-07T07:20:53Z","pushed_at":"2016-03-07T06:44:15Z","git_url":"git://github.com/cantino/huginn.git","ssh_url":"git@github.com:cantino/huginn.git","clone_url":"https://github.com/cantino/huginn.git","svn_url":"https://github.com/cantino/huginn","homepage":null,"size":8465,"stargazers_count":13290,"watchers_count":13290,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1376,"mirror_url":null,"open_issues_count":171,"forks":1376,"open_issues":171,"watchers":13290,"default_branch":"master"}},"base":{"label":"cantino:master","ref":"master","sha":"1c83ffaf25a3d644e6f3f4a07f0a02487764b34d","user":{"login":"cantino","id":83835,"avatar_url":"https://avatars.githubusercontent.com/u/83835?v=3","gravatar_id":"","url":"https://api.github.com/users/cantino","html_url":"https://github.com/cantino","followers_url":"https://api.github.com/users/cantino/followers","following_url":"https://api.github.com/users/cantino/following{/other_user}","gists_url":"https://api.github.com/users/cantino/gists{/gist_id}","starred_url":"https://api.github.com/users/cantino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cantino/subscriptions","organizations_url":"https://api.github.com/users/cantino/orgs","repos_url":"https://api.github.com/users/cantino/repos","events_url":"https://api.github.com/users/cantino/events{/privacy}","received_events_url":"https://api.github.com/users/cantino/received_events","type":"User","site_admin":false},"repo":{"id":8681349,"name":"huginn","full_name":"cantino/huginn","owner":{"login":"cantino","id":83835,"avatar_url":"https://avatars.githubusercontent.com/u/83835?v=3","gravatar_id":"","url":"https://api.github.com/users/cantino","html_url":"https://github.com/cantino","followers_url":"https://api.github.com/users/cantino/followers","following_url":"https://api.github.com/users/cantino/following{/other_user}","gists_url":"https://api.github.com/users/cantino/gists{/gist_id}","starred_url":"https://api.github.com/users/cantino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cantino/subscriptions","organizations_url":"https://api.github.com/users/cantino/orgs","repos_url":"https://api.github.com/users/cantino/repos","events_url":"https://api.github.com/users/cantino/events{/privacy}","received_events_url":"https://api.github.com/users/cantino/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cantino/huginn","description":"Build agents that monitor and act on your behalf.  Your agents are standing by!","fork":false,"url":"https://api.github.com/repos/cantino/huginn","forks_url":"https://api.github.com/repos/cantino/huginn/forks","keys_url":"https://api.github.com/repos/cantino/huginn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cantino/huginn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cantino/huginn/teams","hooks_url":"https://api.github.com/repos/cantino/huginn/hooks","issue_events_url":"https://api.github.com/repos/cantino/huginn/issues/events{/number}","events_url":"https://api.github.com/repos/cantino/huginn/events","assignees_url":"https://api.github.com/repos/cantino/huginn/assignees{/user}","branches_url":"https://api.github.com/repos/cantino/huginn/branches{/branch}","tags_url":"https://api.github.com/repos/cantino/huginn/tags","blobs_url":"https://api.github.com/repos/cantino/huginn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cantino/huginn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cantino/huginn/git/refs{/sha}","trees_url":"https://api.github.com/repos/cantino/huginn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cantino/huginn/statuses/{sha}","languages_url":"https://api.github.com/repos/cantino/huginn/languages","stargazers_url":"https://api.github.com/repos/cantino/huginn/stargazers","contributors_url":"https://api.github.com/repos/cantino/huginn/contributors","subscribers_url":"https://api.github.com/repos/cantino/huginn/subscribers","subscription_url":"https://api.github.com/repos/cantino/huginn/subscription","commits_url":"https://api.github.com/repos/cantino/huginn/commits{/sha}","git_commits_url":"https://api.github.com/repos/cantino/huginn/git/commits{/sha}","comments_url":"https://api.github.com/repos/cantino/huginn/comments{/number}","issue_comment_url":"https://api.github.com/repos/cantino/huginn/issues/comments{/number}","contents_url":"https://api.github.com/repos/cantino/huginn/contents/{+path}","compare_url":"https://api.github.com/repos/cantino/huginn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cantino/huginn/merges","archive_url":"https://api.github.com/repos/cantino/huginn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cantino/huginn/downloads","issues_url":"https://api.github.com/repos/cantino/huginn/issues{/number}","pulls_url":"https://api.github.com/repos/cantino/huginn/pulls{/number}","milestones_url":"https://api.github.com/repos/cantino/huginn/milestones{/number}","notifications_url":"https://api.github.com/repos/cantino/huginn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cantino/huginn/labels{/name}","releases_url":"https://api.github.com/repos/cantino/huginn/releases{/id}","deployments_url":"https://api.github.com/repos/cantino/huginn/deployments","created_at":"2013-03-10T06:00:31Z","updated_at":"2016-03-07T07:20:53Z","pushed_at":"2016-03-07T06:44:15Z","git_url":"git://github.com/cantino/huginn.git","ssh_url":"git@github.com:cantino/huginn.git","clone_url":"https://github.com/cantino/huginn.git","svn_url":"https://github.com/cantino/huginn","homepage":null,"size":8465,"stargazers_count":13290,"watchers_count":13290,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1376,"mirror_url":null,"open_issues_count":171,"forks":1376,"open_issues":171,"watchers":13290,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cantino/huginn/pulls/1335"},"html":{"href":"https://github.com/cantino/huginn/pull/1335"},"issue":{"href":"https://api.github.com/repos/cantino/huginn/issues/1335"},"comments":{"href":"https://api.github.com/repos/cantino/huginn/issues/1335/comments"},"review_comments":{"href":"https://api.github.com/repos/cantino/huginn/pulls/1335/comments"},"review_comment":{"href":"https://api.github.com/repos/cantino/huginn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cantino/huginn/pulls/1335/commits"},"statuses":{"href":"https://api.github.com/repos/cantino/huginn/statuses/c1bc45707788e085a3acd50b2a97ae194fc31d79"}}}}