1311 else |
1311 else |
1312 x:tag("status", {code="321"}):up(); -- affiliation change |
1312 x:tag("status", {code="321"}):up(); -- affiliation change |
1313 end |
1313 end |
1314 end |
1314 end |
1315 local is_semi_anonymous = self:get_whois() == "moderators"; |
1315 local is_semi_anonymous = self:get_whois() == "moderators"; |
1316 for occupant, old_role in pairs(occupants_updated) do |
1316 |
1317 self:publicise_occupant_status(occupant, x, nil, actor, reason); |
1317 if next(occupants_updated) ~= nil then |
1318 if occupant.role == nil then |
1318 for occupant, old_role in pairs(occupants_updated) do |
1319 module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); |
1319 self:publicise_occupant_status(occupant, x, nil, actor, reason); |
1320 elseif is_semi_anonymous and |
1320 if occupant.role == nil then |
1321 (old_role == "moderator" and occupant.role ~= "moderator") or |
1321 module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); |
1322 (old_role ~= "moderator" and occupant.role == "moderator") then -- Has gained or lost moderator status |
1322 elseif is_semi_anonymous and |
1323 -- Send everyone else's presences (as jid visibility has changed) |
1323 (old_role == "moderator" and occupant.role ~= "moderator") or |
1324 for real_jid in occupant:each_session() do |
1324 (old_role ~= "moderator" and occupant.role == "moderator") then -- Has gained or lost moderator status |
1325 self:send_occupant_list(real_jid, function(occupant_jid, occupant) --luacheck: ignore 212 433 |
1325 -- Send everyone else's presences (as jid visibility has changed) |
1326 return occupant.bare_jid ~= jid; |
1326 for real_jid in occupant:each_session() do |
1327 end); |
1327 self:send_occupant_list(real_jid, function(occupant_jid, occupant) --luacheck: ignore 212 433 |
1328 end |
1328 return occupant.bare_jid ~= jid; |
1329 end |
1329 end); |
|
1330 end |
|
1331 end |
|
1332 end |
|
1333 else |
|
1334 -- Announce affiliation change for a user that is not currently in the room, |
|
1335 -- XEP-0045 (v1.31.2) example 195 |
|
1336 -- add_item(x, affiliation, role, jid, nick, actor_nick, actor_jid, reason) |
|
1337 local announce_msg = st.message({ from = self.jid }) |
|
1338 :add_child(add_item(st.clone(x), affiliation, nil, jid, nil, nil, nil, reason)); |
|
1339 local min_role = is_semi_anonymous and "moderator" or "none"; |
|
1340 self:broadcast(announce_msg, muc_util.only_with_min_role(min_role)); |
1330 end |
1341 end |
1331 |
1342 |
1332 self:save(true); |
1343 self:save(true); |
1333 |
1344 |
1334 module:fire_event("muc-set-affiliation", { |
1345 module:fire_event("muc-set-affiliation", { |