213 :tag('status'):text('This participant is kicked from the room because he sent an error presence')); -- send unavailable |
213 :tag('status'):text('This participant is kicked from the room because he sent an error presence')); -- send unavailable |
214 end |
214 end |
215 elseif type == "unavailable" then -- unavailable |
215 elseif type == "unavailable" then -- unavailable |
216 if current_nick then |
216 if current_nick then |
217 log("debug", "%s leaving %s", current_nick, room); |
217 log("debug", "%s leaving %s", current_nick, room); |
218 local data = self._occupants[current_nick]; |
218 local occupant = self._occupants[current_nick]; |
219 data.role = 'none'; |
219 local old_session = occupant.sessions[from]; |
220 self:broadcast_presence(pr); |
220 local new_jid = next(occupant.sessions); |
221 self._occupants[current_nick] = nil; |
221 if new_jid == from then new_jid = next(occupant.sessions, new_jid); end |
|
222 if new_jid then |
|
223 occupant.jid = new_jid; |
|
224 occupant.sessions[from] = nil; |
|
225 local pr = st.clone(occupant[new_jid]) |
|
226 :tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) |
|
227 :tag("item", {affiliation=occupant.affiliation, role=occupant.role}); |
|
228 self:broadcast_except_nick(pr, current_nick); |
|
229 else |
|
230 occupant.role = 'none'; |
|
231 self:broadcast_presence(pr); |
|
232 self._occupants[current_nick] = nil; |
|
233 end |
222 self._jid_nick[from] = nil; |
234 self._jid_nick[from] = nil; |
223 end |
235 end |
224 elseif not type then -- available |
236 elseif not type then -- available |
225 if current_nick then |
237 if current_nick then |
226 --if #pr == #stanza or current_nick ~= to then -- commented because google keeps resending directed presence |
238 --if #pr == #stanza or current_nick ~= to then -- commented because google keeps resending directed presence |