From ddf7a46eda4a9d015a57d3da6931a0d62aa6afa4 Mon Sep 17 00:00:00 2001 From: Amardeep Date: Fri, 29 May 2026 22:49:54 +0530 Subject: [PATCH] toolbar and session --- config/politictalk.parallelglobe.io-config.js | 21 ++-- local/custom-config.js | 7 ++ prosody-plugins/mod_politictalk_roles.lua | 96 ++++++++++++++++++- web/plugin.head.html | 15 +++ 4 files changed, 119 insertions(+), 20 deletions(-) diff --git a/config/politictalk.parallelglobe.io-config.js b/config/politictalk.parallelglobe.io-config.js index ec55ac2..76fea18 100644 --- a/config/politictalk.parallelglobe.io-config.js +++ b/config/politictalk.parallelglobe.io-config.js @@ -892,21 +892,12 @@ var config = { ], // Holds values related to toolbar visibility control. - // toolbarConfig: { - // // Moved from interfaceConfig.INITIAL_TOOLBAR_TIMEOUT - // // The initial number of milliseconds for the toolbar buttons to be visible on screen. - // initialTimeout: 20000, - // // Moved from interfaceConfig.TOOLBAR_TIMEOUT - // // Number of milliseconds for the toolbar buttons to be visible on screen. - // timeout: 4000, - // // Moved from interfaceConfig.TOOLBAR_ALWAYS_VISIBLE - // // Whether toolbar should be always visible or should hide after x milliseconds. - // alwaysVisible: false, - // // Indicates whether the toolbar should still autohide when chat is open - // autoHideWhileChatIsOpen: false, - // // Default background color for the main toolbar. Accepts any valid CSS color. - // // backgroundColor: '#ffffff', - // }, + toolbarConfig: { + initialTimeout: 20000, + timeout: 4000, + alwaysVisible: true, + autoHideWhileChatIsOpen: false + }, // Overrides the buttons displayed in the main toolbar. Depending on the screen size the number of displayed // buttons varies from 2 buttons to 8 buttons. Every array in the mainToolbarButtons array will replace the diff --git a/local/custom-config.js b/local/custom-config.js index 8d99ea0..ec8a4cb 100644 --- a/local/custom-config.js +++ b/local/custom-config.js @@ -55,6 +55,13 @@ config.toolbarButtons = [ 'hangup' ]; +config.toolbarConfig = { + initialTimeout: 20000, + timeout: 4000, + alwaysVisible: true, + autoHideWhileChatIsOpen: false +}; + config.hiddenPremeetingButtons = [ 'microphone', 'camera', diff --git a/prosody-plugins/mod_politictalk_roles.lua b/prosody-plugins/mod_politictalk_roles.lua index 9d85c1b..0da0f1d 100644 --- a/prosody-plugins/mod_politictalk_roles.lua +++ b/prosody-plugins/mod_politictalk_roles.lua @@ -247,6 +247,89 @@ local function get_active_participant_user_ids(room) return user_ids; end +local function rebuild_room_role_lists(room) + if not room then + return; + end + + ensure_room_data(room); + + local moderators = {}; + local participants = {}; + + for _, occupant in room:each_occupant() do + local occupant_jid = occupant and occupant.bare_jid; + local user_id = occupant_jid and room._data.politictalk_jid_user_ids[occupant_jid] or nil; + + if user_id and table_contains(room._data.politictalk_host_jids, occupant_jid) then + moderators = add_unique(moderators, user_id); + elseif user_id and table_contains(room._data.politictalk_participant_jids, occupant_jid) then + participants = add_unique(participants, user_id); + end + end + + room._data.moderators = moderators; + room._data.participants = participants; + module:fire_event("room-metadata-changed", { room = room; }); +end + +local function remove_duplicate_user_occupants(room, current_occupant, user_id) + if not room or not current_occupant or not current_occupant.bare_jid or not user_id then + return 0; + end + + ensure_room_data(room); + + local duplicate_nicks = {}; + + for _, occupant in room:each_occupant() do + local occupant_jid = occupant and occupant.bare_jid; + local occupant_user_id = occupant_jid and room._data.politictalk_jid_user_ids[occupant_jid] or nil; + + if + occupant + and occupant.nick + and occupant_jid + and occupant_jid ~= current_occupant.bare_jid + and occupant_user_id == user_id + then + table.insert(duplicate_nicks, occupant.nick); + end + end + + local removed_count = 0; + + for _, duplicate_nick in ipairs(duplicate_nicks) do + local ok, err = room:set_role(true, duplicate_nick, nil, "Another PoliticTalk session was opened for this account"); + + if ok == false then + module:log( + "warn", + "Failed to remove duplicate PoliticTalk occupant: room=%s user=%s nick=%s error=%s", + tostring(room.jid), + tostring(user_id), + tostring(duplicate_nick), + tostring(err) + ); + else + removed_count = removed_count + 1; + end + end + + if removed_count > 0 then + rebuild_room_role_lists(room); + module:log( + "info", + "Removed duplicate PoliticTalk occupants: room=%s user=%s count=%s", + tostring(room.jid), + tostring(user_id), + tostring(removed_count) + ); + end + + return removed_count; +end + local function get_occupant_count(room) if not room then return 0; @@ -343,8 +426,8 @@ local function notify_room_occupancy(room, reason) ensure_room_data(room); - local participant_count = table_count(room._data.politictalk_participant_jids); local participant_user_ids = get_active_participant_user_ids(room); + local participant_count = table_count(participant_user_ids); local moderator_count = table_count(room._data.moderators); local occupant_count = get_occupant_count(room); local host_count = get_active_host_count(room); @@ -424,15 +507,17 @@ module:hook("muc-occupant-pre-join", function(event) if not is_moderator then ensure_room_data(room); local participant_limit = get_participant_limit(session); - local active_participant_count = table_count(room._data.politictalk_participant_jids); + local active_participant_user_ids = get_active_participant_user_ids(room); + local active_participant_count = table_count(active_participant_user_ids); local active_room_occupancy_count = active_participant_count; if participant_limit + and not table_contains(active_participant_user_ids, user_id) and active_room_occupancy_count >= participant_limit then module:log( "warn", - "Blocking participant %s because PoliticTalk room is full: room=%s active=%s participantSeats=%s limit=%s", + "Blocking participant %s because PoliticTalk room is full: room=%s active=%s uniqueParticipants=%s limit=%s", tostring(user_id), tostring(room and room.jid), tostring(active_room_occupancy_count), @@ -469,6 +554,7 @@ module:hook("muc-occupant-joined", function(event) mark_host(room, occupant, role.user_id); update_room_role_lists(room, role.user_id, true); room:set_affiliation(true, occupant.bare_jid, "owner"); + remove_duplicate_user_occupants(room, occupant, role.user_id); module:log( "info", "PoliticTalk host joined as moderator with AV moderation: %s room=%s", @@ -479,6 +565,7 @@ module:hook("muc-occupant-joined", function(event) mark_participant(room, occupant, role.user_id); update_room_role_lists(room, role.user_id, false); room:set_affiliation(true, occupant.bare_jid, "member"); + remove_duplicate_user_occupants(room, occupant, role.user_id); module:log("info", "PoliticTalk participant joined as member: %s room=%s", tostring(role.user_id), tostring(room.jid)); end @@ -494,8 +581,7 @@ module:hook("muc-occupant-left", function(event) if room and user_id then ensure_room_data(room); - room._data.moderators = remove_value(room._data.moderators, user_id); - room._data.participants = remove_value(room._data.participants, user_id); + rebuild_room_role_lists(room); end if was_host and not has_active_host(room) then diff --git a/web/plugin.head.html b/web/plugin.head.html index 1821809..9a566f1 100644 --- a/web/plugin.head.html +++ b/web/plugin.head.html @@ -468,6 +468,21 @@ top: calc(max(18px, env(safe-area-inset-top)) + 58px) !important; } + html:not(.politictalk-direct-access-blocked) #new-toolbox, + html:not(.politictalk-direct-access-blocked) .toolbox, + html:not(.politictalk-direct-access-blocked) .toolbox-content, + html:not(.politictalk-direct-access-blocked) .toolbox-content-wrapper { + opacity: 1 !important; + pointer-events: auto !important; + visibility: visible !important; + z-index: 1000 !important; + } + + html:not(.politictalk-direct-access-blocked) #new-toolbox, + html:not(.politictalk-direct-access-blocked) .toolbox { + bottom: max(12px, env(safe-area-inset-bottom)) !important; + } + .politictalk-direct-access { align-items: flex-start; padding: 150px 18px 18px;