Mercurial > prosody-modules
comparison mod_pubsub_github/mod_pubsub_github.lua @ 3526:bcfd6e5bb0f5
mod_pubsub_github: Reorder code to prepare for more code reordering
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 31 Mar 2019 19:02:56 +0200 |
| parents | 8c1a3b989990 |
| children | 6ac98c4dbbd3 |
comparison
equal
deleted
inserted
replaced
| 3525:8c1a3b989990 | 3526:bcfd6e5bb0f5 |
|---|---|
| 51 if not data then | 51 if not data then |
| 52 response.status_code = 400; | 52 response.status_code = 400; |
| 53 return "Invalid JSON. From you of all people..."; | 53 return "Invalid JSON. From you of all people..."; |
| 54 end | 54 end |
| 55 | 55 |
| 56 local node = default_node; | |
| 57 if node_mapping then | |
| 58 node = node_prefix .. data.repository[node_mapping]; | |
| 59 end | |
| 60 | |
| 56 local github_event = request.headers.x_github_event | 61 local github_event = request.headers.x_github_event |
| 57 if github_event == "push" then | 62 if github_event == "push" then |
| 58 module:log("debug", "Handling 'push' event: \n%s\n", tostring(request.body)); | 63 module:log("debug", "Handling 'push' event: \n%s\n", tostring(request.body)); |
| 59 elseif github_event then | 64 elseif github_event then |
| 60 module:log("debug", "Unsupported Github event %q", github_event); | 65 module:log("debug", "Unsupported Github event %q", github_event); |
| 61 return 501; | 66 return 501; |
| 62 end -- else .. is this even github? | 67 end -- else .. is this even github? |
| 63 | |
| 64 local node = default_node; | |
| 65 if node_mapping then | |
| 66 node = node_prefix .. data.repository[node_mapping]; | |
| 67 end | |
| 68 | 68 |
| 69 for _, commit in ipairs(data.commits) do | 69 for _, commit in ipairs(data.commits) do |
| 70 local ok, err = pubsub_service:publish(node, github_actor, commit.id, | 70 local ok, err = pubsub_service:publish(node, github_actor, commit.id, |
| 71 st.stanza("item", { id = commit.id, xmlns = "http://jabber.org/protocol/pubsub" }) | 71 st.stanza("item", { id = commit.id, xmlns = "http://jabber.org/protocol/pubsub" }) |
| 72 :tag("entry", { xmlns = "http://www.w3.org/2005/Atom" }) | 72 :tag("entry", { xmlns = "http://www.w3.org/2005/Atom" }) |
