浏览代码

fix: Fixes #7514 when promoting new moderator and lobby is enabled.

master
damencho 4 年前
父节点
当前提交
25ae83bcf4
共有 3 个文件被更改,包括 28 次插入8 次删除
  1. 2
    2
      package-lock.json
  2. 1
    1
      package.json
  3. 25
    5
      resources/prosody-plugins/mod_muc_lobby_rooms.lua

+ 2
- 2
package-lock.json 查看文件

@@ -17945,8 +17945,8 @@
17945 17945
       }
17946 17946
     },
17947 17947
     "lib-jitsi-meet": {
17948
-      "version": "github:jitsi/lib-jitsi-meet#d37024751843711b219ebbe184c4d9c0ae99b7a3",
17949
-      "from": "github:jitsi/lib-jitsi-meet#d37024751843711b219ebbe184c4d9c0ae99b7a3",
17948
+      "version": "github:jitsi/lib-jitsi-meet#15dcc57424cc937290e1963b8eb402c1fcf48ccb",
17949
+      "from": "github:jitsi/lib-jitsi-meet#15dcc57424cc937290e1963b8eb402c1fcf48ccb",
17950 17950
       "requires": {
17951 17951
         "@jitsi/js-utils": "1.0.0",
17952 17952
         "@jitsi/sdp-interop": "1.0.3",

+ 1
- 1
package.json 查看文件

@@ -56,7 +56,7 @@
56 56
     "jquery-i18next": "1.2.1",
57 57
     "js-md5": "0.6.1",
58 58
     "jwt-decode": "2.2.0",
59
-    "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#d37024751843711b219ebbe184c4d9c0ae99b7a3",
59
+    "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#15dcc57424cc937290e1963b8eb402c1fcf48ccb",
60 60
     "libflacjs": "github:mmig/libflac.js#93d37e7f811f01cf7d8b6a603e38bd3c3810907d",
61 61
     "lodash": "4.17.19",
62 62
     "moment": "2.19.4",

+ 25
- 5
resources/prosody-plugins/mod_muc_lobby_rooms.lua 查看文件

@@ -132,7 +132,7 @@ function filter_stanza(stanza)
132 132
 
133 133
             -- check is an owner, only owners can receive the presence
134 134
             local room = main_muc_service.get_room_from_jid(jid_bare(node .. '@' .. main_muc_component_config));
135
-            if room.get_affiliation(room, stanza.attr.to) == 'owner' then
135
+            if not room or room.get_affiliation(room, stanza.attr.to) == 'owner' then
136 136
                 return stanza;
137 137
             end
138 138
 
@@ -159,6 +159,11 @@ function attach_lobby_room(room)
159 159
     local lobby_room_jid = node .. '@' .. lobby_muc_component_config;
160 160
     if not lobby_muc_service.get_room_from_jid(lobby_room_jid) then
161 161
         local new_room = lobby_muc_service.create_room(lobby_room_jid);
162
+        -- set persistent the lobby room to avoid it to be destroyed
163
+        -- there are cases like when selecting new moderator after the current one leaves
164
+        -- which can leave the room with no occupants and it will be destroyed and we want to
165
+        -- avoid lobby destroy while it is enabled
166
+        new_room:set_persistent(true);
162 167
         module:log("debug","Lobby room jid = %s created",lobby_room_jid);
163 168
         new_room.main_room = room;
164 169
         room._data.lobbyroom = new_room;
@@ -168,6 +173,18 @@ function attach_lobby_room(room)
168 173
     return false
169 174
 end
170 175
 
176
+-- destroys lobby room for the supplied main room
177
+function destroy_lobby_room(room, newjid, message)
178
+    if not message then
179
+        message = 'Lobby room closed.';
180
+    end
181
+    if room and room._data.lobbyroom then
182
+        room._data.lobbyroom:set_persistent(false);
183
+        room._data.lobbyroom:destroy(newjid, message);
184
+        room._data.lobbyroom = nil;
185
+    end
186
+end
187
+
171 188
 -- process a host module directly if loaded or hooks to wait for its load
172 189
 function process_host_module(name, callback)
173 190
     local function process_host(host)
@@ -280,16 +297,14 @@ process_host_module(main_muc_component_config, function(host_module, host)
280 297
                 notify_lobby_enabled(room, actor, true);
281 298
             end
282 299
         elseif room._data.lobbyroom then
283
-            room._data.lobbyroom:destroy(room.jid, 'Lobby room closed.');
284
-            room._data.lobbyroom = nil;
300
+            destroy_lobby_room(room, room.jid);
285 301
             notify_lobby_enabled(room, actor, false);
286 302
         end
287 303
     end);
288 304
     host_module:hook('muc-room-destroyed',function(event)
289 305
         local room = event.room;
290 306
         if room._data.lobbyroom then
291
-            room._data.lobbyroom:destroy(nil, 'Lobby room closed.');
292
-            room._data.lobbyroom = nil;
307
+            destroy_lobby_room(room, nil);
293 308
         end
294 309
     end);
295 310
     host_module:hook('muc-disco#info', function (event)
@@ -399,7 +414,12 @@ function handle_create_lobby(event)
399 414
     attach_lobby_room(room)
400 415
 end
401 416
 
417
+function handle_destroy_lobby(event)
418
+    destroy_lobby_room(event.room, event.newjid, event.message);
419
+end
420
+
402 421
 module:hook_global('bosh-session', update_session);
403 422
 module:hook_global('websocket-session', update_session);
404 423
 module:hook_global('config-reloaded', load_config);
405 424
 module:hook_global('create-lobby-room', handle_create_lobby);
425
+module:hook_global('destroy-lobby-room', handle_destroy_lobby);

正在加载...
取消
保存