Skip to content

Commit 8c57da7

Browse files
committed
Move GHAM notification logic outside recursion
1 parent ea002e9 commit 8c57da7

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/main/java/org/dependencytrack/tasks/GitHubAdvisoryMirrorTask.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,24 @@ public void inform(final Event e) {
113113
final long end = System.currentTimeMillis();
114114
LOGGER.info("GitHub Advisory mirroring complete");
115115
LOGGER.info("Time spent (total): " + (end - start) + "ms");
116+
117+
if (mirroredWithoutErrors) {
118+
Notification.dispatch(new Notification()
119+
.scope(NotificationScope.SYSTEM)
120+
.group(NotificationGroup.DATASOURCE_MIRRORING)
121+
.title(NotificationConstants.Title.GITHUB_ADVISORY_MIRROR)
122+
.content("Mirroring of GitHub Advisories completed successfully")
123+
.level(NotificationLevel.INFORMATIONAL)
124+
);
125+
} else {
126+
Notification.dispatch(new Notification()
127+
.scope(NotificationScope.SYSTEM)
128+
.group(NotificationGroup.DATASOURCE_MIRRORING)
129+
.title(NotificationConstants.Title.GITHUB_ADVISORY_MIRROR)
130+
.content("An error occurred mirroring the contents of GitHub Advisories. Check log for details.")
131+
.level(NotificationLevel.ERROR)
132+
);
133+
}
116134
} else {
117135
LOGGER.warn("GitHub Advisory mirroring is enabled, but no personal access token is configured. Skipping.");
118136
}
@@ -160,24 +178,6 @@ private void retrieveAdvisories(final String advisoriesEndCursor) throws IOExcep
160178
retrieveAdvisories(pageableList.getEndCursor());
161179
}
162180
}
163-
164-
if (mirroredWithoutErrors) {
165-
Notification.dispatch(new Notification()
166-
.scope(NotificationScope.SYSTEM)
167-
.group(NotificationGroup.DATASOURCE_MIRRORING)
168-
.title(NotificationConstants.Title.GITHUB_ADVISORY_MIRROR)
169-
.content("Mirroring of GitHub Advisories completed successfully")
170-
.level(NotificationLevel.INFORMATIONAL)
171-
);
172-
} else {
173-
Notification.dispatch(new Notification()
174-
.scope(NotificationScope.SYSTEM)
175-
.group(NotificationGroup.DATASOURCE_MIRRORING)
176-
.title(NotificationConstants.Title.GITHUB_ADVISORY_MIRROR)
177-
.content("An error occurred mirroring the contents of GitHub Advisories. Check log for details.")
178-
.level(NotificationLevel.ERROR)
179-
);
180-
}
181181
}
182182
}
183183

0 commit comments

Comments
 (0)