comparison mod_pubsub_github/mod_pubsub_github.lua @ 3521:a200fbce0ecb

mod_pubsub_github: Add some spacing to improve readability
author Kim Alvefur <zash@zash.se>
date Sun, 31 Mar 2019 18:22:35 +0200
parents 37e89a76c7d7
children c2e038e573be
comparison
equal deleted inserted replaced
3520:37e89a76c7d7 3521:a200fbce0ecb
10 sha384 = hashes.hmac_sha384; 10 sha384 = hashes.hmac_sha384;
11 sha512 = hashes.hmac_sha512; 11 sha512 = hashes.hmac_sha512;
12 }; 12 };
13 13
14 local pubsub_service = module:depends("pubsub").service; 14 local pubsub_service = module:depends("pubsub").service;
15
16 -- configuration
15 local default_node = module:get_option("github_node", "github"); 17 local default_node = module:get_option("github_node", "github");
16 local node_prefix = module:get_option_string("github_node_prefix", "github/"); 18 local node_prefix = module:get_option_string("github_node_prefix", "github/");
17 local node_mapping = module:get_option_string("github_node_mapping"); 19 local node_mapping = module:get_option_string("github_node_mapping");
18 local github_actor = module:get_option_string("github_actor") or true; 20 local github_actor = module:get_option_string("github_actor") or true;
19 local secret = module:get_option("github_secret"); 21 local secret = module:get_option("github_secret");
20 22
23 -- validation
21 assert(secret, "Please set 'github_secret'"); 24 assert(secret, "Please set 'github_secret'");
22 25
23 local error_mapping = { 26 local error_mapping = {
24 ["forbidden"] = 403; 27 ["forbidden"] = 403;
25 ["item-not-found"] = 404; 28 ["item-not-found"] = 404;
41 44
42 if not verify_signature(secret, request.body, request.headers.x_hub_signature) then 45 if not verify_signature(secret, request.body, request.headers.x_hub_signature) then
43 module:log("debug", "Signature validation failed"); 46 module:log("debug", "Signature validation failed");
44 return 401; 47 return 401;
45 end 48 end
49
46 local data = json.decode(request.body); 50 local data = json.decode(request.body);
47 if not data then 51 if not data then
48 response.status_code = 400; 52 response.status_code = 400;
49 return "Invalid JSON. From you of all people..."; 53 return "Invalid JSON. From you of all people...";
50 end 54 end