mod_mam_muc/mod_mam_muc.lua
changeset 1519 67c80abe742e
parent 1430 18f5f1b13353
child 1532 71d85bc0dea8
equal deleted inserted replaced
1518:9475fe14d58d 1519:67c80abe742e
     1 -- XEP-0313: Message Archive Management for Prosody MUC
     1 -- XEP-0313: Message Archive Management for Prosody MUC
     2 -- Copyright (C) 2011-2013 Kim Alvefur
     2 -- Copyright (C) 2011-2014 Kim Alvefur
     3 --
     3 --
     4 -- This file is MIT/X11 licensed.
     4 -- This file is MIT/X11 licensed.
     5 
     5 
     6 local xmlns_mam     = "urn:xmpp:mam:tmp";
     6 local xmlns_mam     = "urn:xmpp:mam:tmp";
     7 local xmlns_delay   = "urn:xmpp:delay";
     7 local xmlns_delay   = "urn:xmpp:delay";
   197 	return origin.send(st.reply(stanza)
   197 	return origin.send(st.reply(stanza)
   198 		:query(xmlns_mam):add_child(rsm.generate {
   198 		:query(xmlns_mam):add_child(rsm.generate {
   199 			first = first, last = last, count = count }));
   199 			first = first, last = last, count = count }));
   200 end);
   200 end);
   201 
   201 
   202 function room_mt:send_history(to, stanza)
   202 function send_history(self, to, stanza)
   203 	local maxchars, maxstanzas, seconds, since;
   203 	local maxchars, maxstanzas, seconds, since;
   204 	local history_tag = stanza:find("{http://jabber.org/protocol/muc}x/history")
   204 	local history_tag = stanza:find("{http://jabber.org/protocol/muc}x/history")
   205 	if history_tag then
   205 	if history_tag then
   206 		module:log("debug", tostring(history_tag));
   206 		module:log("debug", tostring(history_tag));
   207 		local history_attr = history_tag.attr;
   207 		local history_attr = history_tag.attr;
   247 		self:_route_stanza(to_send[i]);
   247 		self:_route_stanza(to_send[i]);
   248 	end
   248 	end
   249 end
   249 end
   250 
   250 
   251 -- Handle messages
   251 -- Handle messages
   252 function room_mt:save_to_history(stanza)
   252 function save_to_history(self, stanza)
   253 	local orig_to = stanza.attr.to;
   253 	local orig_to = stanza.attr.to;
   254 	local room = jid_split(self.jid);
   254 	local room = jid_split(self.jid);
   255 
   255 
   256 	-- Policy check
   256 	-- Policy check
   257 	if not ( log_all_rooms == true -- Logging forced on all rooms
   257 	if not ( log_all_rooms == true -- Logging forced on all rooms