Software / code / prosody
Comparison
plugins/muc/muc.lib.lua @ 10048:e5532fbdd163
MUC: Reflow event tables to improve readability
Also makes it easier to read diffs of added fields.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 19 Jun 2019 08:51:39 +0200 |
| parent | 9862:f5623a1b33e5 |
| child | 10212:a53126b7fe22 |
comparison
equal
deleted
inserted
replaced
| 10047:177a8b92204b | 10048:e5532fbdd163 |
|---|---|
| 389 if is_last_session then | 389 if is_last_session then |
| 390 x:tag("status", {code = "333"}); | 390 x:tag("status", {code = "333"}); |
| 391 end | 391 end |
| 392 self:publicise_occupant_status(new_occupant or occupant, x); | 392 self:publicise_occupant_status(new_occupant or occupant, x); |
| 393 if is_last_session then | 393 if is_last_session then |
| 394 module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); | 394 module:fire_event("muc-occupant-left", { |
| 395 room = self; | |
| 396 nick = occupant.nick; | |
| 397 occupant = occupant; | |
| 398 }); | |
| 395 end | 399 end |
| 396 return true; | 400 return true; |
| 397 end | 401 end |
| 398 | 402 |
| 399 -- Give the room creator owner affiliation | 403 -- Give the room creator owner affiliation |
| 866 self:save_occupant(occupant); | 870 self:save_occupant(occupant); |
| 867 occupants_updated[occupant] = true; | 871 occupants_updated[occupant] = true; |
| 868 end | 872 end |
| 869 for occupant in pairs(occupants_updated) do | 873 for occupant in pairs(occupants_updated) do |
| 870 self:publicise_occupant_status(occupant, x); | 874 self:publicise_occupant_status(occupant, x); |
| 871 module:fire_event("muc-occupant-left", { room = self; nick = occupant.nick; occupant = occupant;}); | 875 module:fire_event("muc-occupant-left", { |
| 876 room = self; | |
| 877 nick = occupant.nick; | |
| 878 occupant = occupant; | |
| 879 }); | |
| 872 end | 880 end |
| 873 end | 881 end |
| 874 | 882 |
| 875 function room_mt:destroy(newjid, reason, password) | 883 function room_mt:destroy(newjid, reason, password) |
| 876 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}) | 884 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}) |
| 1314 | 1322 |
| 1315 if next(occupants_updated) ~= nil then | 1323 if next(occupants_updated) ~= nil then |
| 1316 for occupant, old_role in pairs(occupants_updated) do | 1324 for occupant, old_role in pairs(occupants_updated) do |
| 1317 self:publicise_occupant_status(occupant, x, nil, actor, reason); | 1325 self:publicise_occupant_status(occupant, x, nil, actor, reason); |
| 1318 if occupant.role == nil then | 1326 if occupant.role == nil then |
| 1319 module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); | 1327 module:fire_event("muc-occupant-left", { |
| 1328 room = self; | |
| 1329 nick = occupant.nick; | |
| 1330 occupant = occupant; | |
| 1331 }); | |
| 1320 elseif is_semi_anonymous and | 1332 elseif is_semi_anonymous and |
| 1321 (old_role == "moderator" and occupant.role ~= "moderator") or | 1333 (old_role == "moderator" and occupant.role ~= "moderator") or |
| 1322 (old_role ~= "moderator" and occupant.role == "moderator") then -- Has gained or lost moderator status | 1334 (old_role ~= "moderator" and occupant.role == "moderator") then -- Has gained or lost moderator status |
| 1323 -- Send everyone else's presences (as jid visibility has changed) | 1335 -- Send everyone else's presences (as jid visibility has changed) |
| 1324 for real_jid in occupant:each_session() do | 1336 for real_jid in occupant:each_session() do |
| 1430 end | 1442 end |
| 1431 occupant.role = role; | 1443 occupant.role = role; |
| 1432 self:save_occupant(occupant); | 1444 self:save_occupant(occupant); |
| 1433 self:publicise_occupant_status(occupant, x, nil, actor, reason); | 1445 self:publicise_occupant_status(occupant, x, nil, actor, reason); |
| 1434 if role == nil then | 1446 if role == nil then |
| 1435 module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); | 1447 module:fire_event("muc-occupant-left", { |
| 1448 room = self; | |
| 1449 nick = occupant.nick; | |
| 1450 occupant = occupant; | |
| 1451 }); | |
| 1436 end | 1452 end |
| 1437 return true; | 1453 return true; |
| 1438 end | 1454 end |
| 1439 | 1455 |
| 1440 local whois = module:require "muc/whois"; | 1456 local whois = module:require "muc/whois"; |