comparison mod_pastebin/mod_pastebin.lua @ 3035:60ca0d03f3e3

mod_pastebin: Support the new MUC API in Prosody trunk
author Kim Alvefur <zash@zash.se>
date Wed, 23 May 2018 00:34:46 +0200
parents 6e9096b66704
children be9e213d089b
comparison
equal deleted inserted replaced
3034:6e9096b66704 3035:60ca0d03f3e3
4 local uuid_new = require "util.uuid".generate; 4 local uuid_new = require "util.uuid".generate;
5 local os_time = os.time; 5 local os_time = os.time;
6 local t_remove = table.remove; 6 local t_remove = table.remove;
7 local add_task = require "util.timer".add_task; 7 local add_task = require "util.timer".add_task;
8 local jid_bare = require "util.jid".bare; 8 local jid_bare = require "util.jid".bare;
9 local muc_rooms; 9
10 local function get_room_from_jid() end;
10 local is_component = module:get_host_type() == "component"; 11 local is_component = module:get_host_type() == "component";
11 if is_component then 12 if is_component then
12 muc_rooms = module:depends "muc".rooms; 13 local mod_muc = module:depends "muc";
14 local muc_rooms = rawget(mod_muc, "rooms");
15 get_room_from_jid = rawget(mod_muc, "get_room_from_jid") or
16 function (jid)
17 return muc_rooms[jid];
18 end
13 end 19 end
14 20
15 local utf8_pattern = "[\194-\244][\128-\191]*$"; 21 local utf8_pattern = "[\194-\244][\128-\191]*$";
16 local function drop_invalid_utf8(seq) 22 local function drop_invalid_utf8(seq)
17 local start = seq:byte(); 23 local start = seq:byte();
94 function check_message(data) 100 function check_message(data)
95 local stanza = data.stanza; 101 local stanza = data.stanza;
96 102
97 -- Only check for MUC presence when loaded on a component. 103 -- Only check for MUC presence when loaded on a component.
98 if is_component then 104 if is_component then
99 local room = muc_rooms[jid_bare(stanza.attr.to)]; 105 local room = get_room_from_jid(jid_bare(stanza.attr.to));
100 if not room then return; end 106 if not room then return; end
101 107
102 local nick = room._jid_nick[stanza.attr.from]; 108 local nick = room._jid_nick[stanza.attr.from];
103 if not nick then return; end 109 if not nick then return; end
104 end 110 end