Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 5776:bd0ff8ae98a8
Remove all trailing whitespace
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Fri, 09 Aug 2013 17:48:21 +0200 |
parent | 5681:43cc1f95395e |
child | 5808:026367992a0f |
comparison
equal
deleted
inserted
replaced
5775:a6c2b8933507 | 5776:bd0ff8ae98a8 |
---|---|
1 -- Prosody IM | 1 -- Prosody IM |
2 -- Copyright (C) 2008-2010 Matthew Wild | 2 -- Copyright (C) 2008-2010 Matthew Wild |
3 -- Copyright (C) 2008-2010 Waqas Hussain | 3 -- Copyright (C) 2008-2010 Waqas Hussain |
4 -- | 4 -- |
5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 | 8 |
9 local select = select; | 9 local select = select; |
145 function room_mt:send_history(to, stanza) | 145 function room_mt:send_history(to, stanza) |
146 local history = self._data['history']; -- send discussion history | 146 local history = self._data['history']; -- send discussion history |
147 if history then | 147 if history then |
148 local x_tag = stanza and stanza:get_child("x", "http://jabber.org/protocol/muc"); | 148 local x_tag = stanza and stanza:get_child("x", "http://jabber.org/protocol/muc"); |
149 local history_tag = x_tag and x_tag:get_child("history", "http://jabber.org/protocol/muc"); | 149 local history_tag = x_tag and x_tag:get_child("history", "http://jabber.org/protocol/muc"); |
150 | 150 |
151 local maxchars = history_tag and tonumber(history_tag.attr.maxchars); | 151 local maxchars = history_tag and tonumber(history_tag.attr.maxchars); |
152 if maxchars then maxchars = math.floor(maxchars); end | 152 if maxchars then maxchars = math.floor(maxchars); end |
153 | 153 |
154 local maxstanzas = math.floor(history_tag and tonumber(history_tag.attr.maxstanzas) or #history); | 154 local maxstanzas = math.floor(history_tag and tonumber(history_tag.attr.maxstanzas) or #history); |
155 if not history_tag then maxstanzas = 20; end | 155 if not history_tag then maxstanzas = 20; end |
156 | 156 |
157 local seconds = history_tag and tonumber(history_tag.attr.seconds); | 157 local seconds = history_tag and tonumber(history_tag.attr.seconds); |
158 if seconds then seconds = datetime.datetime(os.time() - math.floor(seconds)); end | 158 if seconds then seconds = datetime.datetime(os.time() - math.floor(seconds)); end |
161 if since then since = datetime.parse(since); since = since and datetime.datetime(since); end | 161 if since then since = datetime.parse(since); since = since and datetime.datetime(since); end |
162 if seconds and (not since or since < seconds) then since = seconds; end | 162 if seconds and (not since or since < seconds) then since = seconds; end |
163 | 163 |
164 local n = 0; | 164 local n = 0; |
165 local charcount = 0; | 165 local charcount = 0; |
166 | 166 |
167 for i=#history,1,-1 do | 167 for i=#history,1,-1 do |
168 local entry = history[i]; | 168 local entry = history[i]; |
169 if maxchars then | 169 if maxchars then |
170 if not entry.chars then | 170 if not entry.chars then |
171 entry.stanza.attr.to = ""; | 171 entry.stanza.attr.to = ""; |
349 local function construct_stanza_id(room, stanza) | 349 local function construct_stanza_id(room, stanza) |
350 local from_jid, to_nick = stanza.attr.from, stanza.attr.to; | 350 local from_jid, to_nick = stanza.attr.from, stanza.attr.to; |
351 local from_nick = room._jid_nick[from_jid]; | 351 local from_nick = room._jid_nick[from_jid]; |
352 local occupant = room._occupants[to_nick]; | 352 local occupant = room._occupants[to_nick]; |
353 local to_jid = occupant.jid; | 353 local to_jid = occupant.jid; |
354 | 354 |
355 return from_nick, to_jid, base64.encode(to_jid.."\0"..stanza.attr.id.."\0"..md5(from_jid)); | 355 return from_nick, to_jid, base64.encode(to_jid.."\0"..stanza.attr.id.."\0"..md5(from_jid)); |
356 end | 356 end |
357 local function deconstruct_stanza_id(room, stanza) | 357 local function deconstruct_stanza_id(room, stanza) |
358 local from_jid_possiblybare, to_nick = stanza.attr.from, stanza.attr.to; | 358 local from_jid_possiblybare, to_nick = stanza.attr.from, stanza.attr.to; |
359 local from_jid, id, to_jid_hash = (base64.decode(stanza.attr.id) or ""):match("^(.+)%z(.*)%z(.+)$"); | 359 local from_jid, id, to_jid_hash = (base64.decode(stanza.attr.id) or ""):match("^(.+)%z(.*)%z(.+)$"); |