Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
Continuing with next notification if it crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Aug 13, 2017
1 parent 6841f34 commit e89d4ca
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 30 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

Changelog of Pull Request Notifier for Bitbucket.

## Unreleased
### No issue
Continuing with next notification if it crashes

[8c9672e661bbbb2](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/8c9672e661bbbb2) Tomas Bjerre *2017-08-13 16:32:02*

doc

[6841f34e051d3f4](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/6841f34e051d3f4) Tomas Bjerre *2017-08-02 20:08:31*

## 3.10
### GitHub [#237](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/237) Listing all notifications via API takes a long time
Speeding up restriction filter
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
npm install
grunt
mvn package
atlas-mvn package
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,4 @@ Changelog of Pull Request Notifier for Bitbucket.
<quick.reload.version>2.0.0</quick.reload.version>
<amps.version>6.3.0</amps.version>
</properties>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -102,30 +102,42 @@ private void handleEvent(final PullRequestEvent pullRequestEvent) {
return;
}
final PrnfbSettingsData settings = settingsService.getPrnfbSettingsData();
ClientKeyStore clientKeyStore = new ClientKeyStore(settings);
final ClientKeyStore clientKeyStore = new ClientKeyStore(settings);
for (final PrnfbNotification notification : settingsService.getNotifications()) {
PrnfbPullRequestAction action = fromPullRequestEvent(pullRequestEvent, notification);
VariablesContext variables =
new VariablesContextBuilder() //
.setPullRequestEvent(pullRequestEvent) //
.build();
PrnfbRenderer renderer =
prnfbRendererFactory.create(
pullRequestEvent.getPullRequest(),
action,
notification,
variables,
pullRequestEvent.getUser());
notify(
notification,
action,
pullRequestEvent.getPullRequest(),
renderer,
clientKeyStore,
settings.isShouldAcceptAnyCertificate());
try {
handleEventNotification(pullRequestEvent, settings, clientKeyStore, notification);
} catch (final Exception e) {
LOG.error("Unable to handle notification " + notification, e);
}
}
}

private void handleEventNotification(
final PullRequestEvent pullRequestEvent,
final PrnfbSettingsData settings,
ClientKeyStore clientKeyStore,
final PrnfbNotification notification) {
final PrnfbPullRequestAction action = fromPullRequestEvent(pullRequestEvent, notification);
final VariablesContext variables =
new VariablesContextBuilder() //
.setPullRequestEvent(pullRequestEvent) //
.build();
final PrnfbRenderer renderer =
prnfbRendererFactory.create(
pullRequestEvent.getPullRequest(),
action,
notification,
variables,
pullRequestEvent.getUser());
notify(
notification,
action,
pullRequestEvent.getPullRequest(),
renderer,
clientKeyStore,
settings.isShouldAcceptAnyCertificate());
}

@VisibleForTesting
public void handleEventAsync(final PullRequestEvent pullRequestEvent) {
executorService.execute(
Expand Down Expand Up @@ -192,8 +204,8 @@ public boolean isNotificationTriggeredByAction(

if (notification.getTriggerIfCanMerge() != ALWAYS) {
// Cannot perform canMerge unless PR is open
boolean notYetMerged = pullRequest.isOpen();
boolean isConflicted = notYetMerged && hasConflicts(pullRequest);
final boolean notYetMerged = pullRequest.isOpen();
final boolean isConflicted = notYetMerged && hasConflicts(pullRequest);
if (ignoreBecauseOfConflicting(notification.getTriggerIfCanMerge(), isConflicted)) {
return FALSE;
}
Expand Down Expand Up @@ -236,7 +248,7 @@ public NotificationResponse notify(

Optional<String> postContent = absent();
if (notification.getPostContent().isPresent()) {
ENCODE_FOR encodePostContentFor = notification.getPostContentEncoding();
final ENCODE_FOR encodePostContentFor = notification.getPostContentEncoding();
postContent =
of(
renderer.render(
Expand All @@ -245,7 +257,7 @@ public NotificationResponse notify(
clientKeyStore,
shouldAcceptAnyCertificate));
}
String renderedUrl =
final String renderedUrl =
renderer.render(
notification.getUrl(), ENCODE_FOR.URL, clientKeyStore, shouldAcceptAnyCertificate);
LOG.info(
Expand All @@ -261,21 +273,21 @@ public NotificationResponse notify(
+ ")"
+ " " //
+ renderedUrl);
UrlInvoker urlInvoker =
final UrlInvoker urlInvoker =
urlInvoker() //
.withClientKeyStore(clientKeyStore) //
.withUrlParam(renderedUrl) //
.withMethod(notification.getMethod()) //
.withPostContent(postContent) //
.appendBasicAuth(notification);
for (PrnfbHeader header : notification.getHeaders()) {
for (final PrnfbHeader header : notification.getHeaders()) {
urlInvoker //
.withHeader(
header.getName(),
renderer.render(
header.getValue(), ENCODE_FOR.NONE, clientKeyStore, shouldAcceptAnyCertificate));
}
HttpResponse httpResponse =
final HttpResponse httpResponse =
createInvoker()
.invoke(
urlInvoker //
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/admin.vm
Original file line number Diff line number Diff line change
Expand Up @@ -615,4 +615,4 @@

</body>

</html>
</html>

0 comments on commit e89d4ca

Please sign in to comment.