Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 2053:f5a198127dd3
MUC: Fixed: affiliation='none' was omitted from some presence broadcasts.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 25 Oct 2009 21:07:32 +0500 |
parent | 2051:2567f4bf0085 |
child | 2064:1ee862fd1afe |
comparison
equal
deleted
inserted
replaced
2052:161db352822c | 2053:f5a198127dd3 |
---|---|
113 | 113 |
114 function room_mt:broadcast_presence(stanza, sid, code, nick) | 114 function room_mt:broadcast_presence(stanza, sid, code, nick) |
115 stanza = get_filtered_presence(stanza); | 115 stanza = get_filtered_presence(stanza); |
116 local occupant = self._occupants[stanza.attr.from]; | 116 local occupant = self._occupants[stanza.attr.from]; |
117 stanza:tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) | 117 stanza:tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) |
118 :tag("item", {affiliation=occupant.affiliation, role=occupant.role, nick=nick}):up(); | 118 :tag("item", {affiliation=occupant.affiliation or "none", role=occupant.role or "none", nick=nick}):up(); |
119 if code then | 119 if code then |
120 stanza:tag("status", {code=code}):up(); | 120 stanza:tag("status", {code=code}):up(); |
121 end | 121 end |
122 self:broadcast_except_nick(stanza, stanza.attr.from); | 122 self:broadcast_except_nick(stanza, stanza.attr.from); |
123 local me = self._occupants[stanza.attr.from]; | 123 local me = self._occupants[stanza.attr.from]; |
160 for occupant, o_data in pairs(self._occupants) do | 160 for occupant, o_data in pairs(self._occupants) do |
161 if occupant ~= current_nick then | 161 if occupant ~= current_nick then |
162 local pres = get_filtered_presence(o_data.sessions[o_data.jid]); | 162 local pres = get_filtered_presence(o_data.sessions[o_data.jid]); |
163 pres.attr.to, pres.attr.from = to, occupant; | 163 pres.attr.to, pres.attr.from = to, occupant; |
164 pres:tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) | 164 pres:tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) |
165 :tag("item", {affiliation=o_data.affiliation, role=o_data.role}):up(); | 165 :tag("item", {affiliation=o_data.affiliation or "none", role=o_data.role or "none"}):up(); |
166 self:route_stanza(pres); | 166 self:route_stanza(pres); |
167 end | 167 end |
168 end | 168 end |
169 end | 169 end |
170 function room_mt:send_history(to) | 170 function room_mt:send_history(to) |
230 local jid = occupant.jid; | 230 local jid = occupant.jid; |
231 occupant.jid = new_jid; | 231 occupant.jid = new_jid; |
232 occupant.sessions[from] = nil; | 232 occupant.sessions[from] = nil; |
233 pr.attr.to = from; | 233 pr.attr.to = from; |
234 pr:tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) | 234 pr:tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) |
235 :tag("item", {affiliation=occupant.affiliation, role='none'}):up() | 235 :tag("item", {affiliation=occupant.affiliation or "none", role='none'}):up() |
236 :tag("status", {code='110'}); | 236 :tag("status", {code='110'}); |
237 self:route_stanza(pr); | 237 self:route_stanza(pr); |
238 if jid ~= new_jid then | 238 if jid ~= new_jid then |
239 pr = st.clone(occupant.sessions[new_jid]) | 239 pr = st.clone(occupant.sessions[new_jid]) |
240 :tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) | 240 :tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) |
241 :tag("item", {affiliation=occupant.affiliation, role=occupant.role}); | 241 :tag("item", {affiliation=occupant.affiliation or "none", role=occupant.role or "none"}); |
242 pr.attr.from = current_nick; | 242 pr.attr.from = current_nick; |
243 self:broadcast_except_nick(pr, current_nick); | 243 self:broadcast_except_nick(pr, current_nick); |
244 end | 244 end |
245 else | 245 else |
246 occupant.role = 'none'; | 246 occupant.role = 'none'; |
321 if not is_merge then | 321 if not is_merge then |
322 self:broadcast_presence(pr, from); | 322 self:broadcast_presence(pr, from); |
323 else | 323 else |
324 pr.attr.to = from; | 324 pr.attr.to = from; |
325 self:route_stanza(pr:tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) | 325 self:route_stanza(pr:tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) |
326 :tag("item", {affiliation=affiliation, role=role}):up() | 326 :tag("item", {affiliation=affiliation or "none", role=role or "none"}):up() |
327 :tag("status", {code='110'})); | 327 :tag("status", {code='110'})); |
328 end | 328 end |
329 self:send_history(from); | 329 self:send_history(from); |
330 else -- banned | 330 else -- banned |
331 local reply = st.error_reply(stanza, "auth", "forbidden"):up(); | 331 local reply = st.error_reply(stanza, "auth", "forbidden"):up(); |