Comparison

plugins/muc/muc.lib.lua @ 4766:1d2646b63084

mod_muc/muc.lib.lua: Remove unused imports and variables
author Matthew Wild <mwild1@gmail.com>
date Sat, 28 Apr 2012 04:12:34 +0100
parent 4528:875b90d5ce0f
child 4785:36234dc4b177
comparison
equal deleted inserted replaced
4765:21eb0b86c904 4766:1d2646b63084
7 -- 7 --
8 8
9 local select = select; 9 local select = select;
10 local pairs, ipairs = pairs, ipairs; 10 local pairs, ipairs = pairs, ipairs;
11 11
12 local datamanager = require "util.datamanager";
13 local datetime = require "util.datetime"; 12 local datetime = require "util.datetime";
14 13
15 local dataform = require "util.dataforms"; 14 local dataform = require "util.dataforms";
16 15
17 local jid_split = require "util.jid".split; 16 local jid_split = require "util.jid".split;
18 local jid_bare = require "util.jid".bare; 17 local jid_bare = require "util.jid".bare;
19 local jid_prep = require "util.jid".prep; 18 local jid_prep = require "util.jid".prep;
20 local st = require "util.stanza"; 19 local st = require "util.stanza";
21 local log = require "util.logger".init("mod_muc"); 20 local log = require "util.logger".init("mod_muc");
22 local multitable_new = require "util.multitable".new;
23 local t_insert, t_remove = table.insert, table.remove; 21 local t_insert, t_remove = table.insert, table.remove;
24 local setmetatable = setmetatable; 22 local setmetatable = setmetatable;
25 local base64 = require "util.encodings".base64; 23 local base64 = require "util.encodings".base64;
26 local md5 = require "util.hashes".md5; 24 local md5 = require "util.hashes".md5;
27 25
131 local history = self._data['history']; 129 local history = self._data['history'];
132 if not history then history = {}; self._data['history'] = history; end 130 if not history then history = {}; self._data['history'] = history; end
133 stanza = st.clone(stanza); 131 stanza = st.clone(stanza);
134 stanza.attr.to = ""; 132 stanza.attr.to = "";
135 local stamp = datetime.datetime(); 133 local stamp = datetime.datetime();
136 local chars = #tostring(stanza);
137 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = stamp}):up(); -- XEP-0203 134 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = stamp}):up(); -- XEP-0203
138 stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated) 135 stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated)
139 local entry = { stanza = stanza, stamp = stamp }; 136 local entry = { stanza = stanza, stamp = stamp };
140 t_insert(history, entry); 137 t_insert(history, entry);
141 while #history > self._data.history_length do t_remove(history, 1) end 138 while #history > self._data.history_length do t_remove(history, 1) end
183 if since then since = datetime.parse(since); since = since and datetime.datetime(since); end 180 if since then since = datetime.parse(since); since = since and datetime.datetime(since); end
184 if seconds and (not since or since < seconds) then since = seconds; end 181 if seconds and (not since or since < seconds) then since = seconds; end
185 182
186 local n = 0; 183 local n = 0;
187 local charcount = 0; 184 local charcount = 0;
188 local stanzacount = 0;
189 185
190 for i=#history,1,-1 do 186 for i=#history,1,-1 do
191 local entry = history[i]; 187 local entry = history[i];
192 if maxchars then 188 if maxchars then
193 if not entry.chars then 189 if not entry.chars then
853 elseif type == "set" or type == "get" then 849 elseif type == "set" or type == "get" then
854 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); 850 origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
855 end 851 end
856 elseif stanza.name == "message" and type == "groupchat" then 852 elseif stanza.name == "message" and type == "groupchat" then
857 local from, to = stanza.attr.from, stanza.attr.to; 853 local from, to = stanza.attr.from, stanza.attr.to;
858 local room = jid_bare(to);
859 local current_nick = self._jid_nick[from]; 854 local current_nick = self._jid_nick[from];
860 local occupant = self._occupants[current_nick]; 855 local occupant = self._occupants[current_nick];
861 if not occupant then -- not in room 856 if not occupant then -- not in room
862 origin.send(st.error_reply(stanza, "cancel", "not-acceptable")); 857 origin.send(st.error_reply(stanza, "cancel", "not-acceptable"));
863 elseif occupant.role == "visitor" then 858 elseif occupant.role == "visitor" then