From c9519912a22a2f2e4bc6c10f45f0b56a65625198 Mon Sep 17 00:00:00 2001 From: Amardeep Date: Fri, 22 May 2026 02:41:49 +0530 Subject: [PATCH] count f --- README.md | 3 ++- prosody-plugins/mod_politictalk_roles.lua | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 76682b2..8b34d51 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,8 @@ inactive-room and occupancy callbacks from `templates/prosody-token-auth.cfg.lua.example`. The inactive callback clears the event `meetingCode` when the last host leaves, and the occupancy callback keeps the platform room cards updated with the current room occupancy count, including -the host. +the host. If the occupancy callback URL is omitted, the module derives it from +the inactive callback URL by replacing `room-inactive` with `room-occupancy`. ## Token Auth Rollout diff --git a/prosody-plugins/mod_politictalk_roles.lua b/prosody-plugins/mod_politictalk_roles.lua index ea5b426..6aeb942 100644 --- a/prosody-plugins/mod_politictalk_roles.lua +++ b/prosody-plugins/mod_politictalk_roles.lua @@ -10,7 +10,7 @@ local ROOM_INACTIVE_CALLBACK_URL = module:get_option_string( "politictalk_room_inactive_callback_url", os.getenv("POLITICTALK_ROOM_INACTIVE_CALLBACK_URL") ); -local ROOM_OCCUPANCY_CALLBACK_URL = module:get_option_string( +local configured_room_occupancy_callback_url = module:get_option_string( "politictalk_room_occupancy_callback_url", os.getenv("POLITICTALK_ROOM_OCCUPANCY_CALLBACK_URL") ); @@ -19,6 +19,27 @@ local ROOM_INACTIVE_CALLBACK_SECRET = module:get_option_string( os.getenv("POLITICTALK_ROOM_INACTIVE_CALLBACK_SECRET") ); +local function derive_room_occupancy_callback_url(inactive_url) + if not inactive_url or inactive_url == "" then + return nil; + end + + local derived_url, replacement_count = inactive_url:gsub("room%-inactive$", "room-occupancy"); + if replacement_count > 0 then + return derived_url; + end + + return nil; +end + +local ROOM_OCCUPANCY_CALLBACK_URL = configured_room_occupancy_callback_url; +if not ROOM_OCCUPANCY_CALLBACK_URL or ROOM_OCCUPANCY_CALLBACK_URL == "" then + ROOM_OCCUPANCY_CALLBACK_URL = derive_room_occupancy_callback_url(ROOM_INACTIVE_CALLBACK_URL); + if ROOM_OCCUPANCY_CALLBACK_URL then + module:log("info", "Derived PoliticTalk occupancy callback URL from inactive callback URL"); + end +end + module:log("info", "Loaded PoliticTalk JWT role enforcement"); local function get_user(session)