Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 2172:84dd0fada45b
MUC: Improved handling of incoming groupchat messages (state preserved for possible later use).
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Wed, 25 Nov 2009 21:40:44 +0500 |
parent | 2064:1ee862fd1afe |
child | 2173:f9af31dbfeb8 |
comparison
equal
deleted
inserted
replaced
2171:c418f2ee3ead | 2172:84dd0fada45b |
---|---|
126 stanza.attr.to = sid; | 126 stanza.attr.to = sid; |
127 self:_route_stanza(stanza); | 127 self:_route_stanza(stanza); |
128 end | 128 end |
129 end | 129 end |
130 function room_mt:broadcast_message(stanza, historic) | 130 function room_mt:broadcast_message(stanza, historic) |
131 local to = stanza.attr.to; | |
131 for occupant, o_data in pairs(self._occupants) do | 132 for occupant, o_data in pairs(self._occupants) do |
132 for jid in pairs(o_data.sessions) do | 133 for jid in pairs(o_data.sessions) do |
133 stanza.attr.to = jid; | 134 stanza.attr.to = jid; |
134 self:_route_stanza(stanza); | 135 self:_route_stanza(stanza); |
135 end | 136 end |
136 end | 137 end |
138 stanza.attr.to = to; | |
137 if historic then -- add to history | 139 if historic then -- add to history |
138 local history = self._data['history']; | 140 local history = self._data['history']; |
139 if not history then history = {}; self._data['history'] = history; end | 141 if not history then history = {}; self._data['history'] = history; end |
140 -- stanza = st.clone(stanza); | 142 stanza = st.clone(stanza); |
141 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = datetime.datetime()}):up(); -- XEP-0203 | 143 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = datetime.datetime()}):up(); -- XEP-0203 |
142 stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated) | 144 stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated) |
143 t_insert(history, st.clone(st.preserialize(stanza))); | 145 t_insert(history, st.preserialize(stanza)); |
144 while #history > history_length do t_remove(history, 1) end | 146 while #history > history_length do t_remove(history, 1) end |
145 end | 147 end |
146 end | 148 end |
147 function room_mt:broadcast_except_nick(stanza, nick) | 149 function room_mt:broadcast_except_nick(stanza, nick) |
148 for rnick, occupant in pairs(self._occupants) do | 150 for rnick, occupant in pairs(self._occupants) do |
526 if subject then | 528 if subject then |
527 self:set_subject(current_nick, subject); -- TODO use broadcast_message_stanza | 529 self:set_subject(current_nick, subject); -- TODO use broadcast_message_stanza |
528 else | 530 else |
529 self:broadcast_message(stanza, true); | 531 self:broadcast_message(stanza, true); |
530 end | 532 end |
533 stanza.attr.from = from; | |
531 end | 534 end |
532 elseif stanza.name == "message" and type == "error" and is_kickable_error(stanza) then | 535 elseif stanza.name == "message" and type == "error" and is_kickable_error(stanza) then |
533 local current_nick = self._jid_nick[stanza.attr.from]; | 536 local current_nick = self._jid_nick[stanza.attr.from]; |
534 log("debug", "%s kicked from %s for sending an error message", current_nick, self.jid); | 537 log("debug", "%s kicked from %s for sending an error message", current_nick, self.jid); |
535 self:handle_to_occupant(origin, st.presence({type='unavailable', from=stanza.attr.from, to=stanza.attr.to}) | 538 self:handle_to_occupant(origin, st.presence({type='unavailable', from=stanza.attr.from, to=stanza.attr.to}) |