Comparison

mod_vcard_muc/mod_vcard_muc.lua @ 3077:f16b021e8a61

mod_vcard_muc: Get room from rooms table when get_room_from_jid API is not supported Closes #1152
author Michel Le Bihan <michel@lebihan.pl>
date Wed, 30 May 2018 19:14:01 +0200
parent 3046:d0db28768980
child 3655:d7b589dec591
comparison
equal deleted inserted replaced
3076:091b042cada0 3077:f16b021e8a61
11 local jid_split = require "util.jid".split; 11 local jid_split = require "util.jid".split;
12 local base64 = require"util.encodings".base64; 12 local base64 = require"util.encodings".base64;
13 local sha1 = require"util.hashes".sha1; 13 local sha1 = require"util.hashes".sha1;
14 14
15 local mod_muc = module:depends"muc"; 15 local mod_muc = module:depends"muc";
16 local get_room_from_jid = mod_muc.get_room_from_jid;
17 16
18 local vcards = module:open_store(); 17 local vcards = module:open_store();
19 18
20 module:add_feature("vcard-temp"); 19 module:add_feature("vcard-temp");
20
21 local get_room_from_jid = rawget(mod_muc, "get_room_from_jid") or
22 function (jid)
23 local rooms = rawget(mod_muc, "rooms");
24 return rooms[jid];
25 end
21 26
22 local function broadcast_presence(room_jid, to) 27 local function broadcast_presence(room_jid, to)
23 local room = get_room_from_jid(room_jid); 28 local room = get_room_from_jid(room_jid);
24 local room_node = jid_split(room_jid); 29 local room_node = jid_split(room_jid);
25 local vcard = st.deserialize(vcards:get(room_node)); 30 local vcard = st.deserialize(vcards:get(room_node));