From 11274884d2831cec722a16e8bf7fd83eda253c9b Mon Sep 17 00:00:00 2001 From: Francois Kritzinger Date: Tue, 27 Feb 2024 18:03:11 +0200 Subject: Use "event" most of the time and "webhook event" for more context --- mod/mod-ci-github.cxx | 20 ++++++++++++++------ mod/mod-ci-github.hxx | 4 +++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx index 6782e71..cb781e3 100644 --- a/mod/mod-ci-github.cxx +++ b/mod/mod-ci-github.cxx @@ -70,9 +70,16 @@ namespace brep // Process headers. // - string event; // @@ TMP Shouldn't we also error<< in some of these header problem cases? // + // @@ TMP From GitHub docs: "You can create webhooks that subscribe to the + // events listed on this page." + // + // So it seems appropriate to generally use the term "event" (which + // we already do for the most part), and "webhook event" only when + // more context would be useful? + // + string event; // Webhook event. { bool content_type (false); @@ -113,8 +120,9 @@ namespace brep throw invalid_request (400, "missing x-github-event header"); } - // There is an event (specified in the x-github-event header) and each event - // contains a bunch of actions (specified in the JSON request body). + // There is a webhook event (specified in the x-github-event header) and + // each event contains a bunch of actions (specified in the JSON request + // body). // // Note: "GitHub continues to add new event types and new actions to // existing event types." As a result we ignore known actions that we are @@ -127,7 +135,7 @@ namespace brep check_suite_event cs; try { - json::parser p (rq.content (64 * 1024), "check_suite webhook"); + json::parser p (rq.content (64 * 1024), "check_suite event"); cs = check_suite_event (p); } @@ -169,7 +177,7 @@ namespace brep // Ignore unknown actions by sending a 200 response with empty body // but also log as an error since we want to notice new actions. // - error << "unknown action '" << cs.action << "' in check_suite webhook"; + error << "unknown action '" << cs.action << "' in check_suite event"; return true; } @@ -193,7 +201,7 @@ namespace brep bool ci_github:: handle_check_suite_request (check_suite_event cs) const { - cout << "" << endl << cs << endl; + cout << "" << endl << cs << endl; installation_access_token iat ( obtain_installation_access_token (cs.installation.id, generate_jwt ())); diff --git a/mod/mod-ci-github.hxx b/mod/mod-ci-github.hxx index f9fb7e6..ca6c7bf 100644 --- a/mod/mod-ci-github.hxx +++ b/mod/mod-ci-github.hxx @@ -31,7 +31,7 @@ namespace brep { namespace json = butl::json; - // The "check_suite" object within a check_suite webhook request. + // The "check_suite" object within a check_suite webhook event request. // struct check_suite { @@ -69,6 +69,8 @@ namespace brep installation () = default; }; + // The check_suite webhook event request. + // struct check_suite_event { string action; -- cgit v1.1