Mercurial > prosody-modules
comparison mod_pubsub_github/mod_pubsub_github.lua @ 3514:8811b7dbe6e2
mod_pubsub_github: Add support for specifying an actor with less privileges
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 31 Mar 2019 17:59:17 +0200 |
parents | 9556e92b2ec4 |
children | f756e051fa02 |
comparison
equal
deleted
inserted
replaced
3513:9556e92b2ec4 | 3514:8811b7dbe6e2 |
---|---|
4 local json = require "util.json"; | 4 local json = require "util.json"; |
5 local hmac_sha1 = require "util.hashes".hmac_sha1; | 5 local hmac_sha1 = require "util.hashes".hmac_sha1; |
6 | 6 |
7 local pubsub_service = module:depends("pubsub").service; | 7 local pubsub_service = module:depends("pubsub").service; |
8 local node = module:get_option("github_node", "github"); | 8 local node = module:get_option("github_node", "github"); |
9 local github_actor = module:get_option_string("github_actor") or true; | |
9 local secret = module:get_option("github_secret"); | 10 local secret = module:get_option("github_secret"); |
10 | 11 |
11 local error_mapping = { | 12 local error_mapping = { |
12 ["forbidden"] = 403; | 13 ["forbidden"] = 403; |
13 ["item-not-found"] = 404; | 14 ["item-not-found"] = 404; |
33 module:log("debug", "Unsupported Github event %q", github_event); | 34 module:log("debug", "Unsupported Github event %q", github_event); |
34 return 501; | 35 return 501; |
35 end -- else .. is this even github? | 36 end -- else .. is this even github? |
36 | 37 |
37 for _, commit in ipairs(data.commits) do | 38 for _, commit in ipairs(data.commits) do |
38 local ok, err = pubsub_service:publish(node, true, data.repository.name, | 39 local ok, err = pubsub_service:publish(node, github_actor, data.repository.name, |
39 st.stanza("item", { id = data.repository.name, xmlns = "http://jabber.org/protocol/pubsub" }) | 40 st.stanza("item", { id = data.repository.name, xmlns = "http://jabber.org/protocol/pubsub" }) |
40 :tag("entry", { xmlns = "http://www.w3.org/2005/Atom" }) | 41 :tag("entry", { xmlns = "http://www.w3.org/2005/Atom" }) |
41 :tag("id"):text(commit.id):up() | 42 :tag("id"):text(commit.id):up() |
42 :tag("title"):text(commit.message):up() | 43 :tag("title"):text(commit.message):up() |
43 :tag("link", { rel = "alternate", href = commit.url }):up() | 44 :tag("link", { rel = "alternate", href = commit.url }):up() |