Comparison

plugins/muc/muc.lib.lua @ 6801:5032d4817a30

plugins/muc/muc.lib: Fix issue #505 where unavailable presences were never used
author daurnimator <quae@daurnimator.com>
date Mon, 24 Aug 2015 13:16:49 +1000
parent 6776:4412a2307c89
child 6827:19c4532946b3
comparison
equal deleted inserted replaced
6800:ad231285efdd 6801:5032d4817a30
185 185
186 -- Broadcasts an occupant's presence to the whole room 186 -- Broadcasts an occupant's presence to the whole room
187 -- Takes the x element that goes into the stanzas 187 -- Takes the x element that goes into the stanzas
188 function room_mt:publicise_occupant_status(occupant, base_x, nick, actor, reason) 188 function room_mt:publicise_occupant_status(occupant, base_x, nick, actor, reason)
189 -- Build real jid and (optionally) occupant jid template presences 189 -- Build real jid and (optionally) occupant jid template presences
190 local base_presence; 190 local base_presence do
191 if occupant.role ~= nil then
192 -- Try to use main jid's presence 191 -- Try to use main jid's presence
193 local pr = occupant:get_presence(); 192 local pr = occupant:get_presence();
194 if pr ~= nil then 193 if pr and (pr.attr.type ~= "unavailable" or occupant.role == nil) then
195 base_presence = st.clone(pr); 194 base_presence = st.clone(pr);
196 end 195 else -- user is leaving but didn't send a leave presence. make one for them
197 end 196 base_presence = st.presence {from = occupant.nick; type = "unavailable";};
198 base_presence = base_presence or st.presence {from = occupant.nick; type = "unavailable";}; 197 end
198 end
199 199
200 -- Fire event (before full_p and anon_p are created) 200 -- Fire event (before full_p and anon_p are created)
201 local event = { 201 local event = {
202 room = self; stanza = base_presence; x = base_x; 202 room = self; stanza = base_presence; x = base_x;
203 occupant = occupant; nick = nick; actor = actor; 203 occupant = occupant; nick = nick; actor = actor;