Skip to content

Commit

Permalink
its: fix sha1 calculate for GH event
Browse files Browse the repository at this point in the history
  • Loading branch information
brig committed Oct 11, 2023
1 parent f816f5f commit a6993c3
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private static void refreshRepo(String orgName, String projectName, String repoN
}

@SuppressWarnings("unchecked")
private static void sendEvent(String resource, String event, String... params) throws Exception {
private static void sendEvent(String resource, String eventName, String... params) throws Exception {
String payload = resourceToString(resource);
if (params != null) {
for (int i = 0; i < params.length; i += 2) {
Expand All @@ -242,11 +242,14 @@ private static void sendEvent(String resource, String event, String... params) t
}
}

Map<String, Object> event = apiClient().getObjectMapper().readValue(payload, Map.class);
payload = apiClient().getObjectMapper().writeValueAsString(event);

ApiClient client = apiClient();
client.addDefaultHeader("X-Hub-Signature", "sha1=" + GitHubUtils.sign(payload));

GitHubEventsApi eventsApi = new GitHubEventsApi(client);
eventsApi.onEvent( null, "abc", event, new ObjectMapper().readValue(payload, Map.class));
eventsApi.onEvent( null, "abc", eventName, new ObjectMapper().readValue(payload, Map.class));
}

private static String resourceToString(String resource) throws Exception {
Expand Down

0 comments on commit a6993c3

Please sign in to comment.