Software /
code /
prosody
Changeset
6454:6842b07fc7bc
plugins/muc/muc.lib: Fire muc-occupant-left from other places an occupant may leave the room
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Fri, 26 Sep 2014 17:44:14 -0400 |
parents | 6453:14b62ad88d8a |
children | 6456:a8d9d3eea6f4 |
files | plugins/muc/muc.lib.lua |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua Fri Sep 26 17:43:00 2014 -0400 +++ b/plugins/muc/muc.lib.lua Fri Sep 26 17:44:14 2014 -0400 @@ -324,6 +324,9 @@ local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user";}) :tag("status", {code = "307"}) self:publicise_occupant_status(occupant, x); + if occupant.jid == real_jid then -- Was last session + module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); + end return true; end @@ -1050,7 +1053,9 @@ local is_semi_anonymous = self:get_whois() == "moderators"; for occupant, old_role in pairs(occupants_updated) do self:publicise_occupant_status(occupant, x, nil, actor, reason); - if is_semi_anonymous and + if occupant.role == nil then + module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); + elseif is_semi_anonymous and (old_role == "moderator" and occupant.role ~= "moderator") or (old_role ~= "moderator" and occupant.role == "moderator") then -- Has gained or lost moderator status -- Send everyone else's presences (as jid visibility has changed) @@ -1122,6 +1127,9 @@ occupant.role = role; self:save_occupant(occupant); self:publicise_occupant_status(occupant, x, nil, actor, reason); + if role == nil then + module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); + end return true; end