Browse Source

fix(breakout-rooms): Adds few nil checks in lua code.

master
Дамян Минков 3 years ago
parent
commit
04f9ad32e1
1 changed files with 7 additions and 3 deletions
  1. 7
    3
      resources/prosody-plugins/mod_muc_breakout_rooms.lua

+ 7
- 3
resources/prosody-plugins/mod_muc_breakout_rooms.lua View File

@@ -213,7 +213,7 @@ end
213 213
 function destroy_breakout_room(room_jid, message)
214 214
     local main_room, main_room_jid = get_main_room(room_jid);
215 215
 
216
-    if room_jid == main_room_jid then
216
+    if room_jid == main_room_jid or not main_room then
217 217
         return;
218 218
     end
219 219
 
@@ -339,7 +339,7 @@ function on_occupant_joined(event)
339 339
 
340 340
     local main_room = get_main_room(room.jid);
341 341
 
342
-    if main_room._data.breakout_rooms_active then
342
+    if main_room and main_room._data.breakout_rooms_active then
343 343
         if jid_node(event.occupant.jid) ~= 'focus' then
344 344
             broadcast_breakout_rooms(room.jid);
345 345
         end
@@ -388,6 +388,10 @@ function on_occupant_left(event)
388 388
 
389 389
     local main_room = get_main_room(room_jid);
390 390
 
391
+    if not main_room then
392
+        return;
393
+    end
394
+
391 395
     if main_room._data.breakout_rooms_active and jid_node(event.occupant.jid) ~= 'focus' then
392 396
         broadcast_breakout_rooms(room_jid);
393 397
     end
@@ -477,7 +481,7 @@ function process_breakout_rooms_muc_loaded(breakout_rooms_muc, host_module)
477 481
         event.formdata['muc#roominfo_breakout_main_room'] = main_room_jid;
478 482
 
479 483
         -- If the main room has a lobby, make it so this breakout room also uses it.
480
-        if (main_room._data.lobbyroom and main_room:get_members_only()) then
484
+        if (main_room and main_room._data.lobbyroom and main_room:get_members_only()) then
481 485
             table.insert(event.form, {
482 486
                 name = 'muc#roominfo_lobbyroom';
483 487
                 label = 'Lobby room jid';

Loading…
Cancel
Save