# HG changeset patch # User Kim Alvefur # Date 1554041231 -7200 # Node ID 94414cadfcaac070ba667229593848ac8917c990 # Parent a98a3922bc01ee4148144db1a6ac8fb0afa12d42 mod_pubsub_github: Return appropriate status code on failure to publish Snippet lifted from mod_pubsub_post diff -r a98a3922bc01 -r 94414cadfcaa mod_pubsub_github/mod_pubsub_github.lua --- a/mod_pubsub_github/mod_pubsub_github.lua Sun Mar 31 16:05:24 2019 +0200 +++ b/mod_pubsub_github/mod_pubsub_github.lua Sun Mar 31 16:07:11 2019 +0200 @@ -8,6 +8,13 @@ local node = module:get_option("github_node", "github"); local secret = module:get_option("github_secret"); +local error_mapping = { + ["forbidden"] = 403; + ["item-not-found"] = 404; + ["internal-server-error"] = 500; + ["conflict"] = 409; +}; + function handle_POST(event) local request, response = event.request, event.response; if secret and ("sha1=" .. hmac_sha1(secret, request.body, true)) ~= request.headers.x_hub_signature then @@ -32,6 +39,9 @@ :tag("email"):text(commit.author.email):up() :up() ); + if not ok then + return error_mapping[err] or 500; + end end module:log("debug", "Handled POST: \n%s\n", tostring(request.body));