# HG changeset patch # User daurnimator # Date 1440386209 -36000 # Node ID 5032d4817a30a0044247f83ce9dca7a6ffc2b23e # Parent ad231285efddbb87bad660c99f5c7f047b384347 plugins/muc/muc.lib: Fix issue #505 where unavailable presences were never used diff -r ad231285efdd -r 5032d4817a30 plugins/muc/muc.lib.lua --- a/plugins/muc/muc.lib.lua Wed Aug 26 20:21:12 2015 +0200 +++ b/plugins/muc/muc.lib.lua Mon Aug 24 13:16:49 2015 +1000 @@ -187,15 +187,15 @@ -- Takes the x element that goes into the stanzas function room_mt:publicise_occupant_status(occupant, base_x, nick, actor, reason) -- Build real jid and (optionally) occupant jid template presences - local base_presence; - if occupant.role ~= nil then + local base_presence do -- Try to use main jid's presence local pr = occupant:get_presence(); - if pr ~= nil then + if pr and (pr.attr.type ~= "unavailable" or occupant.role == nil) then base_presence = st.clone(pr); + else -- user is leaving but didn't send a leave presence. make one for them + base_presence = st.presence {from = occupant.nick; type = "unavailable";}; end end - base_presence = base_presence or st.presence {from = occupant.nick; type = "unavailable";}; -- Fire event (before full_p and anon_p are created) local event = {