Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 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 |
parent | 6453:14b62ad88d8a |
child | 6475:3c815a64042b |
comparison
equal
deleted
inserted
replaced
6453:14b62ad88d8a | 6454:6842b07fc7bc |
---|---|
322 :tag('status'):text(error_message)); | 322 :tag('status'):text(error_message)); |
323 self:save_occupant(occupant); | 323 self:save_occupant(occupant); |
324 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user";}) | 324 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user";}) |
325 :tag("status", {code = "307"}) | 325 :tag("status", {code = "307"}) |
326 self:publicise_occupant_status(occupant, x); | 326 self:publicise_occupant_status(occupant, x); |
327 if occupant.jid == real_jid then -- Was last session | |
328 module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); | |
329 end | |
327 return true; | 330 return true; |
328 end | 331 end |
329 | 332 |
330 -- Give the room creator owner affiliation | 333 -- Give the room creator owner affiliation |
331 module:hook("muc-room-pre-create", function(event) | 334 module:hook("muc-room-pre-create", function(event) |
1048 end | 1051 end |
1049 end | 1052 end |
1050 local is_semi_anonymous = self:get_whois() == "moderators"; | 1053 local is_semi_anonymous = self:get_whois() == "moderators"; |
1051 for occupant, old_role in pairs(occupants_updated) do | 1054 for occupant, old_role in pairs(occupants_updated) do |
1052 self:publicise_occupant_status(occupant, x, nil, actor, reason); | 1055 self:publicise_occupant_status(occupant, x, nil, actor, reason); |
1053 if is_semi_anonymous and | 1056 if occupant.role == nil then |
1057 module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); | |
1058 elseif is_semi_anonymous and | |
1054 (old_role == "moderator" and occupant.role ~= "moderator") or | 1059 (old_role == "moderator" and occupant.role ~= "moderator") or |
1055 (old_role ~= "moderator" and occupant.role == "moderator") then -- Has gained or lost moderator status | 1060 (old_role ~= "moderator" and occupant.role == "moderator") then -- Has gained or lost moderator status |
1056 -- Send everyone else's presences (as jid visibility has changed) | 1061 -- Send everyone else's presences (as jid visibility has changed) |
1057 for real_jid in occupant:each_session() do | 1062 for real_jid in occupant:each_session() do |
1058 self:send_occupant_list(real_jid, function(occupant_jid, occupant) | 1063 self:send_occupant_list(real_jid, function(occupant_jid, occupant) |
1120 x:tag("status", {code = "307"}):up(); | 1125 x:tag("status", {code = "307"}):up(); |
1121 end | 1126 end |
1122 occupant.role = role; | 1127 occupant.role = role; |
1123 self:save_occupant(occupant); | 1128 self:save_occupant(occupant); |
1124 self:publicise_occupant_status(occupant, x, nil, actor, reason); | 1129 self:publicise_occupant_status(occupant, x, nil, actor, reason); |
1130 if role == nil then | |
1131 module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); | |
1132 end | |
1125 return true; | 1133 return true; |
1126 end | 1134 end |
1127 | 1135 |
1128 local affiliation_notify = module:require "muc/affiliation_notify"; | 1136 local affiliation_notify = module:require "muc/affiliation_notify"; |
1129 | 1137 |