comparison mod_slack_webhooks/mod_slack_webhooks.lua @ 3092:0f63e999d0e4

mod_slack_webhooks: Remove unused locals [luacheck]
author Kim Alvefur <zash@zash.se>
date Sat, 02 Jun 2018 14:58:28 +0200
parents b6cac9d72255
children 7ed0589eff3c
comparison
equal deleted inserted replaced
3091:8e5da12205b5 3092:0f63e999d0e4
8 8
9 local host_session = prosody.hosts[module.host]; 9 local host_session = prosody.hosts[module.host];
10 local msg = require "util.stanza".message; 10 local msg = require "util.stanza".message;
11 local jid = require "util.jid"; 11 local jid = require "util.jid";
12 local now = require "util.datetime".datetime; 12 local now = require "util.datetime".datetime;
13 local b64_decode = require "util.encodings".base64.decode;
14 local json = require "util.json" 13 local json = require "util.json"
15 local formdecode = require "net.http".formdecode; 14 local formdecode = require "net.http".formdecode;
16 local xml = require "util.xml";
17 local http = require "net.http"; 15 local http = require "net.http";
18 16
19 local function get_room_from_jid(mod_muc, jid) 17 local function get_room_from_jid(mod_muc, jid)
20 if mod_muc.get_room_from_jid then 18 if mod_muc.get_room_from_jid then
21 return mod_muc.get_room_from_jid(jid); 19 return mod_muc.get_room_from_jid(jid);
26 24
27 local routing = module:get_option("outgoing_webhook_routing") or {}; 25 local routing = module:get_option("outgoing_webhook_routing") or {};
28 local listen_path = module:get_option("incoming_webhook_path") or "/webhook"; 26 local listen_path = module:get_option("incoming_webhook_path") or "/webhook";
29 local default_from_nick = module:get_option("incoming_webhook_default_nick") or "Bot"; 27 local default_from_nick = module:get_option("incoming_webhook_default_nick") or "Bot";
30 28
31 function postcallback(content, code) 29 function postcallback(_, code)
32 module:log("debug", "HTTP result %d", code) 30 module:log("debug", "HTTP result %d", code)
33 end 31 end
34 32
35 function check_message(data) 33 function check_message(data)
36 local origin, stanza = data.origin, data.stanza; 34 local stanza = data.stanza;
37 local mod_muc = host_session.muc; 35 local mod_muc = host_session.muc;
38 if not mod_muc then return; end 36 if not mod_muc then return; end
39 37
40 local this_room = get_room_from_jid(mod_muc, stanza.attr.to); 38 local this_room = get_room_from_jid(mod_muc, stanza.attr.to);
41 if not this_room then return; end -- no such room 39 if not this_room then return; end -- no such room
70 68
71 module:hook("message/bare", check_message, 10); 69 module:hook("message/bare", check_message, 10);
72 70
73 local function route_post(f) 71 local function route_post(f)
74 return function(event, path) 72 return function(event, path)
75 local request = event.request;
76 local headers = request.headers;
77 local bare_room = jid.join(path, module.host); 73 local bare_room = jid.join(path, module.host);
78 local mod_muc = host_session.muc; 74 local mod_muc = host_session.muc;
79 if not get_room_from_jid(mod_muc, bare_room) then 75 if not get_room_from_jid(mod_muc, bare_room) then
80 module:log("warn", "mod_slack_webhook: invalid JID: %s", bare_room); 76 module:log("warn", "mod_slack_webhook: invalid JID: %s", bare_room);
81 return 404; 77 return 404;
86 end 82 end
87 83
88 local function handle_post(event, path) 84 local function handle_post(event, path)
89 local mod_muc = host_session.muc; 85 local mod_muc = host_session.muc;
90 local request = event.request; 86 local request = event.request;
91 local response = event.response;
92 local headers = request.headers; 87 local headers = request.headers;
93 88
94 local body_type = headers.content_type; 89 local body_type = headers.content_type;
95 local message; 90 local message;
96 local post_body; 91 local post_body;