Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 3330:bdc325ce9fbc
MUC: Make number of stored history messages configurable with option max_history_messages (thanks michal and others who requested)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 06 Jul 2010 17:09:23 +0100 |
| parents | fd6ab269ecc2 |
| children | 8d4e7c231d3e |
comparison
equal
deleted
inserted
replaced
| 3329:9adafeeadecb | 3330:bdc325ce9fbc |
|---|---|
| 22 local setmetatable = setmetatable; | 22 local setmetatable = setmetatable; |
| 23 local base64 = require "util.encodings".base64; | 23 local base64 = require "util.encodings".base64; |
| 24 local md5 = require "util.hashes".md5; | 24 local md5 = require "util.hashes".md5; |
| 25 | 25 |
| 26 local muc_domain = nil; --module:get_host(); | 26 local muc_domain = nil; --module:get_host(); |
| 27 local history_length = 20; | 27 local default_history_length = 20; |
| 28 | 28 |
| 29 ------------ | 29 ------------ |
| 30 local function filter_xmlns_from_array(array, filters) | 30 local function filter_xmlns_from_array(array, filters) |
| 31 local count = 0; | 31 local count = 0; |
| 32 for i=#array,1,-1 do | 32 for i=#array,1,-1 do |
| 134 local chars = #tostring(stanza); | 134 local chars = #tostring(stanza); |
| 135 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = stamp}):up(); -- XEP-0203 | 135 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = stamp}):up(); -- XEP-0203 |
| 136 stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated) | 136 stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated) |
| 137 local entry = { stanza = stanza, stamp = stamp }; | 137 local entry = { stanza = stanza, stamp = stamp }; |
| 138 t_insert(history, entry); | 138 t_insert(history, entry); |
| 139 while #history > history_length do t_remove(history, 1) end | 139 while #history > self._data.history_length do t_remove(history, 1) end |
| 140 end | 140 end |
| 141 end | 141 end |
| 142 function room_mt:broadcast_except_nick(stanza, nick) | 142 function room_mt:broadcast_except_nick(stanza, nick) |
| 143 for rnick, occupant in pairs(self._occupants) do | 143 for rnick, occupant in pairs(self._occupants) do |
| 144 if rnick ~= nick then | 144 if rnick ~= nick then |
| 970 end | 970 end |
| 971 end | 971 end |
| 972 | 972 |
| 973 local _M = {}; -- module "muc" | 973 local _M = {}; -- module "muc" |
| 974 | 974 |
| 975 function _M.new_room(jid) | 975 function _M.new_room(jid, config) |
| 976 return setmetatable({ | 976 return setmetatable({ |
| 977 jid = jid; | 977 jid = jid; |
| 978 _jid_nick = {}; | 978 _jid_nick = {}; |
| 979 _occupants = {}; | 979 _occupants = {}; |
| 980 _data = { | 980 _data = { |
| 981 whois = 'moderators', | 981 whois = 'moderators'; |
| 982 history_length = (config and config.history_length) or default_history_length; | |
| 982 }; | 983 }; |
| 983 _affiliations = {}; | 984 _affiliations = {}; |
| 984 }, room_mt); | 985 }, room_mt); |
| 985 end | 986 end |
| 986 | 987 |
