Mercurial > prosody-modules
changeset 3509:94414cadfcaa
mod_pubsub_github: Return appropriate status code on failure to publish
Snippet lifted from mod_pubsub_post
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 31 Mar 2019 16:07:11 +0200 (2019-03-31) |
parents | a98a3922bc01 |
children | f09423c29f31 |
files | mod_pubsub_github/mod_pubsub_github.lua |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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));