toolbar and session
This commit is contained in:
@@ -892,21 +892,12 @@ var config = {
|
|||||||
],
|
],
|
||||||
|
|
||||||
// Holds values related to toolbar visibility control.
|
// Holds values related to toolbar visibility control.
|
||||||
// toolbarConfig: {
|
toolbarConfig: {
|
||||||
// // Moved from interfaceConfig.INITIAL_TOOLBAR_TIMEOUT
|
initialTimeout: 20000,
|
||||||
// // The initial number of milliseconds for the toolbar buttons to be visible on screen.
|
timeout: 4000,
|
||||||
// initialTimeout: 20000,
|
alwaysVisible: true,
|
||||||
// // Moved from interfaceConfig.TOOLBAR_TIMEOUT
|
autoHideWhileChatIsOpen: false
|
||||||
// // 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',
|
|
||||||
// },
|
|
||||||
|
|
||||||
// Overrides the buttons displayed in the main toolbar. Depending on the screen size the number of displayed
|
// 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
|
// buttons varies from 2 buttons to 8 buttons. Every array in the mainToolbarButtons array will replace the
|
||||||
|
|||||||
@@ -55,6 +55,13 @@ config.toolbarButtons = [
|
|||||||
'hangup'
|
'hangup'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
config.toolbarConfig = {
|
||||||
|
initialTimeout: 20000,
|
||||||
|
timeout: 4000,
|
||||||
|
alwaysVisible: true,
|
||||||
|
autoHideWhileChatIsOpen: false
|
||||||
|
};
|
||||||
|
|
||||||
config.hiddenPremeetingButtons = [
|
config.hiddenPremeetingButtons = [
|
||||||
'microphone',
|
'microphone',
|
||||||
'camera',
|
'camera',
|
||||||
|
|||||||
@@ -247,6 +247,89 @@ local function get_active_participant_user_ids(room)
|
|||||||
return user_ids;
|
return user_ids;
|
||||||
end
|
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)
|
local function get_occupant_count(room)
|
||||||
if not room then
|
if not room then
|
||||||
return 0;
|
return 0;
|
||||||
@@ -343,8 +426,8 @@ local function notify_room_occupancy(room, reason)
|
|||||||
|
|
||||||
ensure_room_data(room);
|
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_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 moderator_count = table_count(room._data.moderators);
|
||||||
local occupant_count = get_occupant_count(room);
|
local occupant_count = get_occupant_count(room);
|
||||||
local host_count = get_active_host_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
|
if not is_moderator then
|
||||||
ensure_room_data(room);
|
ensure_room_data(room);
|
||||||
local participant_limit = get_participant_limit(session);
|
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;
|
local active_room_occupancy_count = active_participant_count;
|
||||||
if
|
if
|
||||||
participant_limit
|
participant_limit
|
||||||
|
and not table_contains(active_participant_user_ids, user_id)
|
||||||
and active_room_occupancy_count >= participant_limit
|
and active_room_occupancy_count >= participant_limit
|
||||||
then
|
then
|
||||||
module:log(
|
module:log(
|
||||||
"warn",
|
"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(user_id),
|
||||||
tostring(room and room.jid),
|
tostring(room and room.jid),
|
||||||
tostring(active_room_occupancy_count),
|
tostring(active_room_occupancy_count),
|
||||||
@@ -469,6 +554,7 @@ module:hook("muc-occupant-joined", function(event)
|
|||||||
mark_host(room, occupant, role.user_id);
|
mark_host(room, occupant, role.user_id);
|
||||||
update_room_role_lists(room, role.user_id, true);
|
update_room_role_lists(room, role.user_id, true);
|
||||||
room:set_affiliation(true, occupant.bare_jid, "owner");
|
room:set_affiliation(true, occupant.bare_jid, "owner");
|
||||||
|
remove_duplicate_user_occupants(room, occupant, role.user_id);
|
||||||
module:log(
|
module:log(
|
||||||
"info",
|
"info",
|
||||||
"PoliticTalk host joined as moderator with AV moderation: %s room=%s",
|
"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);
|
mark_participant(room, occupant, role.user_id);
|
||||||
update_room_role_lists(room, role.user_id, false);
|
update_room_role_lists(room, role.user_id, false);
|
||||||
room:set_affiliation(true, occupant.bare_jid, "member");
|
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));
|
module:log("info", "PoliticTalk participant joined as member: %s room=%s", tostring(role.user_id), tostring(room.jid));
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -494,8 +581,7 @@ module:hook("muc-occupant-left", function(event)
|
|||||||
|
|
||||||
if room and user_id then
|
if room and user_id then
|
||||||
ensure_room_data(room);
|
ensure_room_data(room);
|
||||||
room._data.moderators = remove_value(room._data.moderators, user_id);
|
rebuild_room_role_lists(room);
|
||||||
room._data.participants = remove_value(room._data.participants, user_id);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if was_host and not has_active_host(room) then
|
if was_host and not has_active_host(room) then
|
||||||
|
|||||||
@@ -468,6 +468,21 @@
|
|||||||
top: calc(max(18px, env(safe-area-inset-top)) + 58px) !important;
|
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 {
|
.politictalk-direct-access {
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
padding: 150px 18px 18px;
|
padding: 150px 18px 18px;
|
||||||
|
|||||||
Reference in New Issue
Block a user