Mercurial > prosody-modules
comparison mod_muc_intercom/mod_muc_intercom.lua @ 3070:c271bfa3d625
mod_muc_intercom: Fix to use correct name for variable
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 30 May 2018 09:08:33 +0200 |
parents | 6d3935226ffb |
children |
comparison
equal
deleted
inserted
replaced
3069:e1db146984a0 | 3070:c271bfa3d625 |
---|---|
4 local host_session = prosody.hosts[module.host]; | 4 local host_session = prosody.hosts[module.host]; |
5 local st_msg = require "util.stanza".message; | 5 local st_msg = require "util.stanza".message; |
6 local jid = require "util.jid"; | 6 local jid = require "util.jid"; |
7 local now = require "util.datetime".datetime; | 7 local now = require "util.datetime".datetime; |
8 | 8 |
9 local function get_room_by_jid(mod_muc, jid) | 9 local function get_room_from_jid(mod_muc, jid) |
10 if mod_muc.get_room_by_jid then | 10 if mod_muc.get_room_from_jid then |
11 return mod_muc.get_room_by_jid(jid); | 11 return mod_muc.get_room_from_jid(jid); |
12 elseif mod_muc.rooms then | 12 elseif mod_muc.rooms then |
13 return mod_muc.rooms[jid]; -- COMPAT 0.9, 0.10 | 13 return mod_muc.rooms[jid]; -- COMPAT 0.9, 0.10 |
14 end | 14 end |
15 end | 15 end |
16 | 16 |
17 function check_message(data) | 17 function check_message(data) |
18 local origin, stanza = data.origin, data.stanza; | 18 local origin, stanza = data.origin, data.stanza; |
19 local mod_muc = host_session.muc; | 19 local mod_muc = host_session.muc; |
20 if not mod_muc then return; end | 20 if not mod_muc then return; end |
21 | 21 |
22 local this_room = get_room_by_jid(mod_muc, stanza.attr.to); | 22 local this_room = get_room_from_jid(mod_muc, stanza.attr.to); |
23 if not this_room then return; end -- no such room | 23 if not this_room then return; end -- no such room |
24 | 24 |
25 local from_room_jid = this_room._jid_nick[stanza.attr.from]; | 25 local from_room_jid = this_room._jid_nick[stanza.attr.from]; |
26 if not from_room_jid then return; end -- no such nick | 26 if not from_room_jid then return; end -- no such nick |
27 | 27 |
35 | 35 |
36 if target_room == from_room then return; end -- don't route to itself | 36 if target_room == from_room then return; end -- don't route to itself |
37 module:log("debug", "target room is %s", target_room); | 37 module:log("debug", "target room is %s", target_room); |
38 | 38 |
39 local bare_room = jid.join(target_room, from_host); | 39 local bare_room = jid.join(target_room, from_host); |
40 local dest_room = get_room_by_jid(mod_muc, bare_room); | 40 local dest_room = get_room_from_jid(mod_muc, bare_room); |
41 if not dest_room then return; end -- TODO send a error | 41 if not dest_room then return; end -- TODO send a error |
42 module:log("info", "message from %s in %s to %s", from_nick, from_room, target_room); | 42 module:log("info", "message from %s in %s to %s", from_nick, from_room, target_room); |
43 | 43 |
44 local sender = jid.join(target_room, module.host, from_room .. "/" .. from_nick); | 44 local sender = jid.join(target_room, module.host, from_room .. "/" .. from_nick); |
45 local forward_stanza = st_msg({from = sender, to = bare_room, type = "groupchat"}, message); | 45 local forward_stanza = st_msg({from = sender, to = bare_room, type = "groupchat"}, message); |