Skip to content

Commit

Permalink
Move GHAM notification logic outside recursion
Browse files Browse the repository at this point in the history
Signed-off-by: antoinbo <[email protected]>
  • Loading branch information
antoinbo authored and nscuro committed Nov 28, 2024
1 parent 10f43a6 commit b6a8ad6
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ public void inform(final Event e) {
final long end = System.currentTimeMillis();
LOGGER.info("GitHub Advisory mirroring complete");
LOGGER.info("Time spent (total): " + (end - start) + "ms");

if (mirroredWithoutErrors) {
Notification.dispatch(new Notification()
.scope(NotificationScope.SYSTEM)
.group(NotificationGroup.DATASOURCE_MIRRORING)
.title(NotificationConstants.Title.GITHUB_ADVISORY_MIRROR)
.content("Mirroring of GitHub Advisories completed successfully")
.level(NotificationLevel.INFORMATIONAL)
);
} else {
Notification.dispatch(new Notification()
.scope(NotificationScope.SYSTEM)
.group(NotificationGroup.DATASOURCE_MIRRORING)
.title(NotificationConstants.Title.GITHUB_ADVISORY_MIRROR)
.content("An error occurred mirroring the contents of GitHub Advisories. Check log for details.")
.level(NotificationLevel.ERROR)
);
}
} else {
LOGGER.warn("GitHub Advisory mirroring is enabled, but no personal access token is configured. Skipping.");
}
Expand Down Expand Up @@ -159,24 +177,6 @@ private void retrieveAdvisories(final String advisoriesEndCursor) throws IOExcep
retrieveAdvisories(pageableList.getEndCursor());
}
}

if (mirroredWithoutErrors) {
Notification.dispatch(new Notification()
.scope(NotificationScope.SYSTEM)
.group(NotificationGroup.DATASOURCE_MIRRORING)
.title(NotificationConstants.Title.GITHUB_ADVISORY_MIRROR)
.content("Mirroring of GitHub Advisories completed successfully")
.level(NotificationLevel.INFORMATIONAL)
);
} else {
Notification.dispatch(new Notification()
.scope(NotificationScope.SYSTEM)
.group(NotificationGroup.DATASOURCE_MIRRORING)
.title(NotificationConstants.Title.GITHUB_ADVISORY_MIRROR)
.content("An error occurred mirroring the contents of GitHub Advisories. Check log for details.")
.level(NotificationLevel.ERROR)
);
}
}
}

Expand Down

0 comments on commit b6a8ad6

Please sign in to comment.