comparison mod_mam_muc/mod_mam_muc.lua @ 1534:4dd6eebc8fbd

mod_mam_muc: Minor moving about of variables
author Kim Alvefur <zash@zash.se>
date Wed, 22 Oct 2014 19:32:52 +0200
parents 915bdcb35e79
children efbb047c01e7
comparison
equal deleted inserted replaced
1533:915bdcb35e79 1534:4dd6eebc8fbd
10 10
11 local st = require "util.stanza"; 11 local st = require "util.stanza";
12 local rsm = module:require "mod_mam/rsm"; 12 local rsm = module:require "mod_mam/rsm";
13 local jid_bare = require "util.jid".bare; 13 local jid_bare = require "util.jid".bare;
14 local jid_split = require "util.jid".split; 14 local jid_split = require "util.jid".split;
15 local room_mt = module:depends"muc".room_mt; 15
16 local mod_muc = module:depends"muc";
17 local room_mt = mod_muc.room_mt;
18 local rooms = mod_muc.rooms;
16 19
17 local getmetatable = getmetatable; 20 local getmetatable = getmetatable;
18 local function is_stanza(x) 21 local function is_stanza(x)
19 return getmetatable(x) == st.stanza_mt; 22 return getmetatable(x) == st.stanza_mt;
20 end 23 end
37 return 40 return
38 elseif not archive.find then 41 elseif not archive.find then
39 module:log("error", "mod_%s does not support archiving, switch to mod_storage_sql2", archive._provided_by); 42 module:log("error", "mod_%s does not support archiving, switch to mod_storage_sql2", archive._provided_by);
40 return 43 return
41 end 44 end
42
43 local rooms = hosts[module.host].modules.muc.rooms;
44 45
45 local send_history, save_to_history; 46 local send_history, save_to_history;
46 47
47 -- Override history methods for all rooms. 48 -- Override history methods for all rooms.
48 module:hook("muc-room-created", function (event) 49 module:hook("muc-room-created", function (event)
166 if not data then 167 if not data then
167 return origin.send(st.error_reply(stanza, "cancel", "internal-server-error")); 168 return origin.send(st.error_reply(stanza, "cancel", "internal-server-error"));
168 end 169 end
169 local count = err; 170 local count = err;
170 171
172 local msg_reply_attr = { to = stanza.attr.from, from = stanza.attr.to };
173
171 -- Wrap it in stuff and deliver 174 -- Wrap it in stuff and deliver
172 local first, last; 175 local fwd_st, first, last;
173 for id, item, when in data do 176 for id, item, when in data do
174 local fwd_st = st.message{ to = orig_from, from = room } 177 fwd_st = st.message(msg_reply_attr)
175 :tag("result", { xmlns = xmlns_mam, queryid = qid, id = id }) 178 :tag("result", { xmlns = xmlns_mam, queryid = qid, id = id })
176 :tag("forwarded", { xmlns = xmlns_forward }) 179 :tag("forwarded", { xmlns = xmlns_forward })
177 :tag("delay", { xmlns = xmlns_delay, stamp = timestamp(when) }):up(); 180 :tag("delay", { xmlns = xmlns_delay, stamp = timestamp(when) }):up();
178 181
179 if not is_stanza(item) then 182 if not is_stanza(item) then