Kaynağa Gözat

FIX: better URL handler for jibri queue events

master
Aaron Van Meerten 4 yıl önce
ebeveyn
işleme
24c75b7332

+ 14
- 27
resources/prosody-plugins/mod_jibri_queue_component.lua Dosyayı Görüntüle

@@ -61,6 +61,9 @@ if queueServiceURL == nil then
61 61
     return;
62 62
 end
63 63
 
64
+-- option to enable/disable token verifications
65
+local disableTokenVerification
66
+    = module:get_option_boolean("disable_jibri_queue_token_verification", false);
64 67
 
65 68
 local http_headers = {
66 69
     ["User-Agent"] = "Prosody ("..prosody.version.."; "..prosody.platform..")",
@@ -261,7 +264,7 @@ module:log("info", "Loading jibri_queue_component");
261 264
 -- @param group name of the group (optional)
262 265
 -- @param session the session to use for storing token specific fields
263 266
 -- @return true if values are ok or false otherwise
264
-function verify_token(token, room_name, group, session)
267
+function verify_token(token, room_name, session)
265 268
     if disableTokenVerification then
266 269
         return true;
267 270
     end
@@ -301,49 +304,33 @@ end
301 304
 --- Handles request for updating jibri queue status
302 305
 -- @param event the http event, holds the request query
303 306
 -- @return GET response, containing a json with response details
304
-function handle_update_jibri_queue (event)
307
+function handle_update_jibri_queue(event)
305 308
     if (not event.request.url.query) then
306 309
         return { status_code = 400; };
307 310
     end
308 311
 
309 312
     local params = parse(event.request.url.query);
310
-    local user_id = params["user"];
311
-    local room_name = params["room"];
312
-    local group = params["group"];
313
-    local status = params["status"];
314
-    local call_id = params["callid"];
315
-
316
-    local call_cancel = false
317
-    if params["callcancel"] == "true" then
318
-       call_cancel = true;
319
-    end
313
+    local user_jid = params["user"];
314
+    local roomAddress = params["room"];
320 315
 
321
-    if not verify_token(params["token"], room_name, group, {}) then
316
+    if not verify_token(params["token"], roomAddress, {}) then
322 317
         return { status_code = 403; };
323 318
     end
324 319
 
325
-    local room = get_room(room_name, group);
320
+    local room = get_room_from_jid(room_jid_match_rewrite(roomAddress));
326 321
     if (not room) then
327
-        log("error", "no room found %s", room_name);
322
+        log("error", "no room found %s", roomAddress);
328 323
         return { status_code = 404; };
329 324
     end
330 325
 
331
-    local username = poltergeist.get_username(room, user_id);
332
-    if (not username) then
326
+    local occupant = room:get_occupant_by_real_jid(user_jid);
327
+    if not occupant then
328
+        log("warn", "No occupant %s found for %s", user_jid, roomAddress);
333 329
         return { status_code = 404; };
334 330
     end
335 331
 
336
-    local call_details = {
337
-        ["cancel"] = call_cancel;
338
-        ["id"] = call_id;
339
-    };
340
-
341
-    local nick = poltergeist.create_nick(username);
342
-    if (not poltergeist.occupies(room, nick)) then
343
-       return { status_code = 404; };
344
-    end
332
+    -- TODO: actually implement udpate code here
345 333
 
346
-    poltergeist.update(room, nick, status, call_details);
347 334
     return { status_code = 200; };
348 335
 end
349 336
 

Loading…
İptal
Kaydet