{"action":"created","comment":{"url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls/comments/152911438","pull_request_review_id":78845978,"id":152911438,"diff_hunk":"@@ -298,54 +296,36 @@ private void sendEvents(Object event, Repository repo, EventType eventType)\n         for (WebHookConfiguration webHookConfiguration : webHookConfigurationDao.getEnabledWebHookConfigurations(repo, eventType))\n         {\n             post.setURI(URI.create(webHookConfiguration.getURL()));\n+            PushEventService pushEventService = new PushEventService(webHookConfiguration);\n \n-            if(event instanceof BitbucketPushEvent)\n+            if(event instanceof BitbucketPushEvent && pushEventService.isValidEvent((BitbucketPushEvent) event, webHookConfiguration))\n             {\n-                BitbucketPushEvent bitbucketPushEvent = (BitbucketPushEvent) event;\n-                if (webHookConfiguration.getCommittersToIgnore() != null &&\n-                        bitbucketPushEvent.getActor() != null)\n+                try (CloseableHttpResponse response = httpClient.execute(post))\n                 {\n-                    //Split by comma and remove whitspaces\n-                    String[] committersToIgnore =  webHookConfiguration.getCommittersToIgnore().split(\"\\\\s?,\\\\s?\");\n-                    if(committersToIgnore.length > 0 &&\n-                            Arrays.asList(committersToIgnore).contains(bitbucketPushEvent.getActor().getUsername())) {\n-                        LOGGER.debug(\n-                                \"[repo: {}]| The push event by user {} is ignored because the username is listed as a commit to ignore: [{}({})-committersToIgnore:{}] \\n{}\",\n+                    int statusCode = response.getStatusLine().getStatusCode();\n+                    if (statusCode >= 400)\n+                    {\n+                        LOGGER.error(\n+                                \"[repo: {}]| Something went wrong while posting (response code:{}) the following body to webhook: [{}({})] \\n{}\",\n                                 repo,\n-                                bitbucketPushEvent.getActor().getUsername(),\n+                                statusCode,\n                                 webHookConfiguration.getTitle(),\n                                 webHookConfiguration.getURL(),\n-                                webHookConfiguration.getCommittersToIgnore(),\n                                 body);\n-                        continue;\n                     }\n                 }\n-            }\n-\n-            try (CloseableHttpResponse response = httpClient.execute(post))","path":"src/main/java/nl/topicus/bitbucket/api/PullRequestListener.java","position":53,"original_position":53,"commit_id":"d5dfdef42632537140cd6f8ef147014f4e8560e6","original_commit_id":"d5dfdef42632537140cd6f8ef147014f4e8560e6","user":{"login":"PixelJonas","id":5434875,"avatar_url":"https://avatars3.githubusercontent.com/u/5434875?v=4","gravatar_id":"","url":"https://api.github.com/users/PixelJonas","html_url":"https://github.com/PixelJonas","followers_url":"https://api.github.com/users/PixelJonas/followers","following_url":"https://api.github.com/users/PixelJonas/following{/other_user}","gists_url":"https://api.github.com/users/PixelJonas/gists{/gist_id}","starred_url":"https://api.github.com/users/PixelJonas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PixelJonas/subscriptions","organizations_url":"https://api.github.com/users/PixelJonas/orgs","repos_url":"https://api.github.com/users/PixelJonas/repos","events_url":"https://api.github.com/users/PixelJonas/events{/privacy}","received_events_url":"https://api.github.com/users/PixelJonas/received_events","type":"User","site_admin":false},"body":"I see ... I added some tests to my local instance and will fix this asap. I'll also add some tests to make sure this isn't happening again ;)","created_at":"2017-11-24T07:54:19Z","updated_at":"2017-11-24T07:54:20Z","html_url":"https://github.com/Eernie/bitbucket-webhooks-plugin/pull/71#discussion_r152911438","pull_request_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls/71","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls/comments/152911438"},"html":{"href":"https://github.com/Eernie/bitbucket-webhooks-plugin/pull/71#discussion_r152911438"},"pull_request":{"href":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls/71"}},"in_reply_to_id":152909421},"pull_request":{"url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls/71","id":146651414,"html_url":"https://github.com/Eernie/bitbucket-webhooks-plugin/pull/71","diff_url":"https://github.com/Eernie/bitbucket-webhooks-plugin/pull/71.diff","patch_url":"https://github.com/Eernie/bitbucket-webhooks-plugin/pull/71.patch","issue_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/issues/71","number":71,"state":"closed","locked":false,"title":"add support for ignoring branches","user":{"login":"PixelJonas","id":5434875,"avatar_url":"https://avatars3.githubusercontent.com/u/5434875?v=4","gravatar_id":"","url":"https://api.github.com/users/PixelJonas","html_url":"https://github.com/PixelJonas","followers_url":"https://api.github.com/users/PixelJonas/followers","following_url":"https://api.github.com/users/PixelJonas/following{/other_user}","gists_url":"https://api.github.com/users/PixelJonas/gists{/gist_id}","starred_url":"https://api.github.com/users/PixelJonas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PixelJonas/subscriptions","organizations_url":"https://api.github.com/users/PixelJonas/orgs","repos_url":"https://api.github.com/users/PixelJonas/repos","events_url":"https://api.github.com/users/PixelJonas/events{/privacy}","received_events_url":"https://api.github.com/users/PixelJonas/received_events","type":"User","site_admin":false},"body":"Hey guys,\r\n\r\nthis PR adds the capability to \"exclude branches\" from the WebHook. I used your \"committersToIgnore\" as an example.\r\n\r\nI moved some of the logic validating the Event to it's own JAVA class. You can find the logic at `src/main/java/nl/topicus/bitbucket/api/PushEventService.java`\r\n\r\nI think using RegEx for branches to be excluded is the best way. So we'd be able to do stuff like \"release/.*\"\r\n\r\nIf the configuration paramter is missing or empty, everything should be \"valid\".\r\n\r\nI hope you accept this PR.\r\n\r\nBest Regards,\r\nJonas","created_at":"2017-10-15T14:12:01Z","updated_at":"2017-11-24T07:54:20Z","closed_at":"2017-11-10T14:27:14Z","merged_at":"2017-11-10T14:27:14Z","merge_commit_sha":"ed0af844e4804e90a1662194fbc40529c98d226b","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls/71/commits","review_comments_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls/71/comments","review_comment_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/issues/71/comments","statuses_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/statuses/d5dfdef42632537140cd6f8ef147014f4e8560e6","head":{"label":"PixelJonas:master","ref":"master","sha":"d5dfdef42632537140cd6f8ef147014f4e8560e6","user":{"login":"PixelJonas","id":5434875,"avatar_url":"https://avatars3.githubusercontent.com/u/5434875?v=4","gravatar_id":"","url":"https://api.github.com/users/PixelJonas","html_url":"https://github.com/PixelJonas","followers_url":"https://api.github.com/users/PixelJonas/followers","following_url":"https://api.github.com/users/PixelJonas/following{/other_user}","gists_url":"https://api.github.com/users/PixelJonas/gists{/gist_id}","starred_url":"https://api.github.com/users/PixelJonas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PixelJonas/subscriptions","organizations_url":"https://api.github.com/users/PixelJonas/orgs","repos_url":"https://api.github.com/users/PixelJonas/repos","events_url":"https://api.github.com/users/PixelJonas/events{/privacy}","received_events_url":"https://api.github.com/users/PixelJonas/received_events","type":"User","site_admin":false},"repo":{"id":107002689,"name":"bitbucket-webhooks-plugin","full_name":"PixelJonas/bitbucket-webhooks-plugin","owner":{"login":"PixelJonas","id":5434875,"avatar_url":"https://avatars3.githubusercontent.com/u/5434875?v=4","gravatar_id":"","url":"https://api.github.com/users/PixelJonas","html_url":"https://github.com/PixelJonas","followers_url":"https://api.github.com/users/PixelJonas/followers","following_url":"https://api.github.com/users/PixelJonas/following{/other_user}","gists_url":"https://api.github.com/users/PixelJonas/gists{/gist_id}","starred_url":"https://api.github.com/users/PixelJonas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PixelJonas/subscriptions","organizations_url":"https://api.github.com/users/PixelJonas/orgs","repos_url":"https://api.github.com/users/PixelJonas/repos","events_url":"https://api.github.com/users/PixelJonas/events{/privacy}","received_events_url":"https://api.github.com/users/PixelJonas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PixelJonas/bitbucket-webhooks-plugin","description":null,"fork":true,"url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin","forks_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/forks","keys_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/teams","hooks_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/hooks","issue_events_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/events","assignees_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/tags","blobs_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/languages","stargazers_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/stargazers","contributors_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/contributors","subscribers_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/subscribers","subscription_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/subscription","commits_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/merges","archive_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/downloads","issues_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/labels{/name}","releases_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/PixelJonas/bitbucket-webhooks-plugin/deployments","created_at":"2017-10-15T10:31:21Z","updated_at":"2017-10-15T10:31:23Z","pushed_at":"2017-10-15T14:05:33Z","git_url":"git://github.com/PixelJonas/bitbucket-webhooks-plugin.git","ssh_url":"git@github.com:PixelJonas/bitbucket-webhooks-plugin.git","clone_url":"https://github.com/PixelJonas/bitbucket-webhooks-plugin.git","svn_url":"https://github.com/PixelJonas/bitbucket-webhooks-plugin","homepage":"https://marketplace.atlassian.com/1215474","size":142,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Eernie:master","ref":"master","sha":"0df3c6aa8d7b4d94cc0ec09f54d84c9c8bc4899c","user":{"login":"Eernie","id":2161662,"avatar_url":"https://avatars3.githubusercontent.com/u/2161662?v=4","gravatar_id":"","url":"https://api.github.com/users/Eernie","html_url":"https://github.com/Eernie","followers_url":"https://api.github.com/users/Eernie/followers","following_url":"https://api.github.com/users/Eernie/following{/other_user}","gists_url":"https://api.github.com/users/Eernie/gists{/gist_id}","starred_url":"https://api.github.com/users/Eernie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eernie/subscriptions","organizations_url":"https://api.github.com/users/Eernie/orgs","repos_url":"https://api.github.com/users/Eernie/repos","events_url":"https://api.github.com/users/Eernie/events{/privacy}","received_events_url":"https://api.github.com/users/Eernie/received_events","type":"User","site_admin":false},"repo":{"id":61496173,"name":"bitbucket-webhooks-plugin","full_name":"Eernie/bitbucket-webhooks-plugin","owner":{"login":"Eernie","id":2161662,"avatar_url":"https://avatars3.githubusercontent.com/u/2161662?v=4","gravatar_id":"","url":"https://api.github.com/users/Eernie","html_url":"https://github.com/Eernie","followers_url":"https://api.github.com/users/Eernie/followers","following_url":"https://api.github.com/users/Eernie/following{/other_user}","gists_url":"https://api.github.com/users/Eernie/gists{/gist_id}","starred_url":"https://api.github.com/users/Eernie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eernie/subscriptions","organizations_url":"https://api.github.com/users/Eernie/orgs","repos_url":"https://api.github.com/users/Eernie/repos","events_url":"https://api.github.com/users/Eernie/events{/privacy}","received_events_url":"https://api.github.com/users/Eernie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Eernie/bitbucket-webhooks-plugin","description":null,"fork":false,"url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin","forks_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/forks","keys_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/teams","hooks_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/hooks","issue_events_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/events","assignees_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/tags","blobs_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/languages","stargazers_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/stargazers","contributors_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/contributors","subscribers_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/subscribers","subscription_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/subscription","commits_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/merges","archive_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/downloads","issues_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/labels{/name}","releases_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/deployments","created_at":"2016-06-19T19:17:41Z","updated_at":"2017-11-16T11:58:09Z","pushed_at":"2017-11-15T21:16:31Z","git_url":"git://github.com/Eernie/bitbucket-webhooks-plugin.git","ssh_url":"git@github.com:Eernie/bitbucket-webhooks-plugin.git","clone_url":"https://github.com/Eernie/bitbucket-webhooks-plugin.git","svn_url":"https://github.com/Eernie/bitbucket-webhooks-plugin","homepage":"https://marketplace.atlassian.com/1215474","size":146,"stargazers_count":28,"watchers_count":28,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"archived":false,"open_issues_count":8,"forks":25,"open_issues":8,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls/71"},"html":{"href":"https://github.com/Eernie/bitbucket-webhooks-plugin/pull/71"},"issue":{"href":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/issues/71"},"comments":{"href":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/issues/71/comments"},"review_comments":{"href":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls/71/comments"},"review_comment":{"href":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/pulls/71/commits"},"statuses":{"href":"https://api.github.com/repos/Eernie/bitbucket-webhooks-plugin/statuses/d5dfdef42632537140cd6f8ef147014f4e8560e6"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"PixelJonas"}}