Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 7397:e49737de9872
MUC: Fix logic for when to broadcast unavailable presence (actual fix for 14170d161b39)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 19 Apr 2016 18:46:07 +0200 |
| parents | 71a7140200fc |
| children | ef7ea3bad7a1 |
comparison
equal
deleted
inserted
replaced
| 7396:71a7140200fc | 7397:e49737de9872 |
|---|---|
| 194 function room_mt:publicise_occupant_status(occupant, base_x, nick, actor, reason) | 194 function room_mt:publicise_occupant_status(occupant, base_x, nick, actor, reason) |
| 195 -- Build real jid and (optionally) occupant jid template presences | 195 -- Build real jid and (optionally) occupant jid template presences |
| 196 local base_presence do | 196 local base_presence do |
| 197 -- Try to use main jid's presence | 197 -- Try to use main jid's presence |
| 198 local pr = occupant:get_presence(); | 198 local pr = occupant:get_presence(); |
| 199 if pr and (pr.attr.type ~= "unavailable" or occupant.role == nil) then | 199 if pr and (pr.attr.type ~= "unavailable" and occupant.role ~= nil) then |
| 200 base_presence = st.clone(pr); | 200 base_presence = st.clone(pr); |
| 201 else -- user is leaving but didn't send a leave presence. make one for them | 201 else -- user is leaving but didn't send a leave presence. make one for them |
| 202 base_presence = st.presence {from = occupant.nick; type = "unavailable";}; | 202 base_presence = st.presence {from = occupant.nick; type = "unavailable";}; |
| 203 end | 203 end |
| 204 end | 204 end |
| 735 occupant.role = nil; | 735 occupant.role = nil; |
| 736 self:save_occupant(occupant); | 736 self:save_occupant(occupant); |
| 737 occupants_updated[occupant] = true; | 737 occupants_updated[occupant] = true; |
| 738 end | 738 end |
| 739 for occupant in pairs(occupants_updated) do | 739 for occupant in pairs(occupants_updated) do |
| 740 occupant:set_session(occupant.jid, st.presence({type="unavailable"}), true); | |
| 741 self:publicise_occupant_status(occupant, x); | 740 self:publicise_occupant_status(occupant, x); |
| 742 module:fire_event("muc-occupant-left", { room = self; nick = occupant.nick; occupant = occupant;}); | 741 module:fire_event("muc-occupant-left", { room = self; nick = occupant.nick; occupant = occupant;}); |
| 743 end | 742 end |
| 744 end | 743 end |
| 745 | 744 |
