19 end |
19 end |
20 |
20 |
21 function handle_POST(event) |
21 function handle_POST(event) |
22 local request = event.request; |
22 local request = event.request; |
23 local body = request.body; |
23 local body = request.body; |
24 |
24 |
25 if auth_key then |
25 if auth_key then |
26 local digest_header = request.headers["google-code-project-hosting-hook-hmac"]; |
26 local digest_header = request.headers["google-code-project-hosting-hook-hmac"]; |
27 local digest = hmac_md5(auth_key, body, true); |
27 local digest = hmac_md5(auth_key, body, true); |
28 if digest ~= digest_header then |
28 if digest ~= digest_header then |
29 module:log("warn", "Commit POST failed authentication check, sender gave %s, we got %s, body was:\n%s", tostring(digest_header), tostring(digest), tostring(body)); |
29 module:log("warn", "Commit POST failed authentication check, sender gave %s, we got %s, body was:\n%s", tostring(digest_header), tostring(digest), tostring(body)); |
30 return "No thanks."; |
30 return "No thanks."; |
31 end |
31 end |
32 end |
32 end |
33 |
33 |
34 local data = json.decode(body); |
34 local data = json.decode(body); |
35 |
35 |
36 local project = data.project_name or "somewhere"; |
36 local project = data.project_name or "somewhere"; |
37 for _, rev in ipairs(data.revisions) do |
37 for _, rev in ipairs(data.revisions) do |
38 if rev.url:match("^http://wiki.") then |
38 if rev.url:match("^http://wiki.") then |
39 local what; |
39 local what; |
40 for _, page in ipairs(rev.added) do |
40 for _, page in ipairs(rev.added) do |
47 if what then break; end |
47 if what then break; end |
48 end |
48 end |
49 end |
49 end |
50 rev.message = "wiki ("..(what or "unknown page").."): "..rev.message; |
50 rev.message = "wiki ("..(what or "unknown page").."): "..rev.message; |
51 end |
51 end |
52 |
52 |
53 local name = rev.author; |
53 local name = rev.author; |
54 local email = name:match("<([^>]+)>$"); |
54 local email = name:match("<([^>]+)>$"); |
55 if email then |
55 if email then |
56 name = name:gsub("%s*<[^>]+>$", ""); |
56 name = name:gsub("%s*<[^>]+>$", ""); |
57 end |
57 end |