Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat: Visitors chat (#13112)
Дамян Минков397b94da799c
diff --git a/lang/main-bg.json b/lang/main-bg.jsonindex 6edfdd8aa5..d39538276c 100644--- a/lang/main-bg.json+++ b/lang/main-bg.json@@ -58,7 +58,7 @@"today": "Днес"},"chat": {- "error": "Грешка: вашето съобщение не бе изпратено, пради: {{error}}",+ "error": "Грешка: вашето съобщение не бе изпратено, поради: {{error}}","fieldPlaceHolder": "Въведете съобщението","messageTo": "Лично съобщение до {{recipient}}","messagebox": "Въведете съобщение",diff --git a/lang/main-enGB.json b/lang/main-enGB.jsonindex be09e49655..95a4f93ca0 100644--- a/lang/main-enGB.json+++ b/lang/main-enGB.json@@ -46,21 +46,15 @@"today": "Today"},"chat": {- "error": "Error: your message \"{{originalText}}\" was not sent. Reason: {{error}}",- "fieldPlaceHolder": "",- "messageTo": "","messagebox": "Type a message","nickname": {"popover": "Choose a nickname","title": "Enter a nickname to use chat","titleWithPolls": "Enter a nickname to use chat"},- "noMessagesMessage": "",- "privateNotice": "","sendButton": "Send","title": "Chat",- "titleWithPolls": "Chat",- "you": ""+ "titleWithPolls": "Chat"},"chromeExtensionBanner": {"buttonText": "",diff --git a/lang/main.json b/lang/main.jsonindex 2ccd3f133e..4c4b9d494c 100644--- a/lang/main.json+++ b/lang/main.json@@ -1378,6 +1378,7 @@"webAssemblyWarningDescription": "WebAssembly disabled or not supported by this browser"},"visitors": {+ "chatIndicator": "(visitor)","labelTooltip": "Number of visitors: {{count}}","notification": {"description": "To participate raise your hand",diff --git a/react/features/base/config/constants.ts b/react/features/base/config/constants.tsindex f5b210fb88..af3947383f 100644--- a/react/features/base/config/constants.ts+++ b/react/features/base/config/constants.ts@@ -64,7 +64,7 @@ export const THIRD_PARTY_PREJOIN_BUTTONS = [ 'microphone', 'camera', 'select-bac/*** The toolbar buttons to show when in visitors mode.*/-export const VISITORS_MODE_BUTTONS = [ 'hangup', 'raisehand', 'tileview' ];+export const VISITORS_MODE_BUTTONS = [ 'chat', 'hangup', 'raisehand', 'tileview' ];/*** The set of feature flags.diff --git a/react/features/chat/middleware.ts b/react/features/chat/middleware.tsindex acb3cf3ee2..d16f6c7cc7 100644--- a/react/features/chat/middleware.ts+++ b/react/features/chat/middleware.ts@@ -6,6 +6,7 @@ import { CONFERENCE_JOINED } from '../base/conference/actionTypes';import { getCurrentConference } from '../base/conference/functions';import { IJitsiConference } from '../base/conference/reducer';import { openDialog } from '../base/dialog/actions';+import i18next from '../base/i18n/i18next';import {JitsiConferenceErrors,JitsiConferenceEvents@@ -229,10 +230,14 @@ function _addChatMsgListener(conference: IJitsiConference, store: IStore) {conference.on(JitsiConferenceEvents.MESSAGE_RECEIVED,- (id: string, message: string, timestamp: number) => {- _onConferenceMessageReceived(store, { id,+ // eslint-disable-next-line max-params+ (id: string, message: string, timestamp: number, displayName: string, isGuest?: boolean) => {+ _onConferenceMessageReceived(store, {+ id: id || displayName, // in case of messages coming from visitors we can have unknown idmessage,timestamp,+ displayName,+ isGuest,privateMessage: false });});@@ -291,8 +296,9 @@ function _addChatMsgListener(conference: IJitsiConference, store: IStore) {* @param {Object} message - The message object.* @returns {void}*/-function _onConferenceMessageReceived(store: IStore, { id, message, timestamp, privateMessage }: {- id: string; message: string; privateMessage: boolean; timestamp: number; }) {+function _onConferenceMessageReceived(store: IStore, { displayName, id, isGuest, message, timestamp, privateMessage }: {+ displayName?: string; id: string; isGuest?: boolean;+ message: string; privateMessage: boolean; timestamp: number; }) {const isGif = isGifMessage(message);if (isGif) {@@ -302,7 +308,9 @@ function _onConferenceMessageReceived(store: IStore, { id, message, timestamp, p}}_handleReceivedMessage(store, {+ displayName,id,+ isGuest,message,privateMessage,lobbyChat: false,@@ -389,13 +397,14 @@ function getLobbyChatDisplayName(state: IReduxState, id: string) {** @param {Store} store - The Redux store.* @param {Object} message - The message object.- * @param {boolean} shouldPlaySound - Whether or not to play the incoming message sound.- * @param {boolean} isReaction - Whether or not the message is a reaction message.+ * @param {boolean} shouldPlaySound - Whether to play the incoming message sound.+ * @param {boolean} isReaction - Whether the message is a reaction message.* @returns {void}*/function _handleReceivedMessage({ dispatch, getState }: IStore,- { id, message, privateMessage, timestamp, lobbyChat }: {- id: string; lobbyChat: boolean; message: string; privateMessage: boolean; timestamp: number; },+ { displayName, id, isGuest, message, privateMessage, timestamp, lobbyChat }: {+ displayName?: string; id: string; isGuest?: boolean; lobbyChat: boolean;+ message: string; privateMessage: boolean; timestamp: number; },shouldPlaySound = true,isReaction = false) {@@ -408,14 +417,14 @@ function _handleReceivedMessage({ dispatch, getState }: IStore,dispatch(playSound(INCOMING_MSG_SOUND_ID));}- // Provide a default for for the case when a message is being+ // Provide a default for the case when a message is being// backfilled for a participant that has left the conference.const participant = getParticipantById(state, id) || { local: undefined };const localParticipant = getLocalParticipant(getState);- const displayName = lobbyChat+ let displayNameToShow = lobbyChat? getLobbyChatDisplayName(state, id)- : getParticipantDisplayName(state, id);+ : displayName || getParticipantDisplayName(state, id);const hasRead = participant.local || isChatOpen;const timestampToDate = timestamp ? new Date(timestamp) : new Date();const millisecondsTimestamp = timestampToDate.getTime();@@ -424,8 +433,12 @@ function _handleReceivedMessage({ dispatch, getState }: IStore,const shouldShowNotification = userSelectedNotifications?.['notify.chatMessages']&& !hasRead && !isReaction && !timestamp;+ if (isGuest) {+ displayNameToShow = `${displayNameToShow} ${i18next.t('visitors.chatIndicator')}`;+ }+dispatch(addMessage({- displayName,+ displayName: displayNameToShow,hasRead,id,messageType: participant.local ? MESSAGE_TYPE_LOCAL : MESSAGE_TYPE_REMOTE,@@ -439,7 +452,7 @@ function _handleReceivedMessage({ dispatch, getState }: IStore,if (shouldShowNotification) {dispatch(showMessageNotification({- title: displayName,+ title: displayNameToShow,description: message}, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));}@@ -450,7 +463,7 @@ function _handleReceivedMessage({ dispatch, getState }: IStore,APP.API.notifyReceivedChatMessage({body: message,id,- nick: displayName,+ nick: displayNameToShow,privateMessage,ts: timestamp});diff --git a/react/features/video-menu/components/web/ParticipantContextMenu.tsx b/react/features/video-menu/components/web/ParticipantContextMenu.tsxindex 419d292d79..c6df7bc255 100644--- a/react/features/video-menu/components/web/ParticipantContextMenu.tsx+++ b/react/features/video-menu/components/web/ParticipantContextMenu.tsx@@ -25,6 +25,7 @@ import { getQuickActionButtonType, isForceMuted } from '../../../participants-pa// @ts-ignoreimport { requestRemoteControl, stopController } from '../../../remote-control';import { showOverflowDrawer } from '../../../toolbox/functions.web';+import { iAmVisitor } from '../../../visitors/functions';import CustomOptionButton from './CustomOptionButton';// @ts-ignore@@ -146,6 +147,7 @@ const ParticipantContextMenu = ({const _overflowDrawer: boolean = useSelector(showOverflowDrawer);const { remoteVideoMenu = {}, disableRemoteMute, startSilent, customParticipantMenuButtons }= useSelector((state: IReduxState) => state['features/base/config']);+ const visitorsMode = useSelector((state: IReduxState) => iAmVisitor(state));const { disableKick, disableGrantModerator, disablePrivateChat } = remoteVideoMenu;const { participantsVolume } = useSelector((state: IReduxState) => state['features/filmstrip']);const _volume = (participant?.local ?? true ? undefined@@ -264,7 +266,7 @@ const ParticipantContextMenu = ({participantID = { _getCurrentParticipantId() } />);}- if (!disablePrivateChat) {+ if (!disablePrivateChat && !visitorsMode) {buttons2.push(<PrivateMessageMenuButtonkey = 'privateMessage'participantID = { _getCurrentParticipantId() } />diff --git a/resources/extra-large-conference/pre-configure.sh b/resources/extra-large-conference/pre-configure.shindex ee778629d2..b51d6f0501 100755--- a/resources/extra-large-conference/pre-configure.sh+++ b/resources/extra-large-conference/pre-configure.sh@@ -26,6 +26,11 @@ docp prosody.cfg.lua.visitor.template /etc/prosody-v${i}/prosody.cfg.luased -i "s/vX/v${i}/g" /etc/prosody-v${i}/prosody.cfg.luased -i "s/jitmeet.example.com/$JICOFO_HOSTNAME/g" /etc/prosody-v${i}/prosody.cfg.lua+ # fix the ports+ sed -i "s/52691/5269${i}/g" /etc/prosody-v${i}/prosody.cfg.lua+ sed -i "s/52221/5222${i}/g" /etc/prosody-v${i}/prosody.cfg.lua+ sed -i "s/52801/5280${i}/g" /etc/prosody-v${i}/prosody.cfg.lua+ sed -i "s/52811/5281${i}/g" /etc/prosody-v${i}/prosody.cfg.luadone# Configure jicofodiff --git a/resources/extra-large-conference/prosody.cfg.lua.visitor.template b/resources/extra-large-conference/prosody.cfg.lua.visitor.templateindex 11465c4131..263464326e 100644--- a/resources/extra-large-conference/prosody.cfg.lua.visitor.template+++ b/resources/extra-large-conference/prosody.cfg.lua.visitor.template@@ -35,11 +35,13 @@ modules_enabled = {};s2s_whitelist = {+ 'conference.jitmeet.example.com', -- needed for visitors to send messages to main room'visitors.jitmeet.example.com'; -- needed for sending promotion request to visitors.jitmeet.example.com component'jitmeet.example.com'; -- unavailable presences back to main room};s2s_connect_overrides = {+ ["conference.jitmeet.example.com"] = { "127.0.0.1", 5269 }; -- needed for visitors to send messages to main room["jitmeet.example.com"] = { "127.0.0.1", 5269 }; -- needed for the main room when connecting in to send main participants["visitors.jitmeet.example.com"] = { "127.0.0.1", 5269 }; -- needed for sending promotion request to visitors.jitmeet.example.com component}diff --git a/resources/prosody-plugins/mod_fmuc.lua b/resources/prosody-plugins/mod_fmuc.luaindex b50b94d449..91aa61ce59 100644--- a/resources/prosody-plugins/mod_fmuc.lua+++ b/resources/prosody-plugins/mod_fmuc.lua@@ -10,7 +10,6 @@--- NOTE: Make sure all communication between prosodies is using the real jids ([foo][email protected]), as there--- are certain configs for whitelisted domains and connections that are domain based--- TODO: filter presence from main occupants back to main prosody---- TODO: filter messages back to main prosodylocal jid = require 'util.jid';local st = require 'util.stanza';local new_id = require 'util.id'.medium;@@ -24,6 +23,8 @@ local internal_room_jid_match_rewrite = util.internal_room_jid_match_rewrite;local muc_domain_prefix = module:get_option_string('muc_mapper_domain_prefix', 'conference');local main_domain = string.gsub(module.host, muc_domain_prefix..'.', '');+local NICK_NS = 'http://jabber.org/protocol/nick';+-- This is the domain of the main prosody that is federating with us;local fmuc_main_domain;@@ -138,7 +139,6 @@ module:hook('muc-broadcast-presence', function (event)local raiseHand = full_p:get_child_text('jitsi_participant_raisedHand');-- a promotion detected let's send it to main prosodyif raiseHand then- -- TODO check room= with tenantslocal iq_id = new_id();sent_iq_cache:set(iq_id, socket.gettime());local promotion_request = st.iq({@@ -149,7 +149,12 @@ module:hook('muc-broadcast-presence', function (event):tag('visitors', { xmlns = 'jitsi:visitors',room = jid.join(jid.node(room.jid), muc_domain_prefix..'.'..fmuc_main_domain) }):tag('promotion-request', { xmlns = 'jitsi:visitors', jid = occupant.jid }):up();- -- TODO what about name ???? it will be coming from the token, but we need to extract it and send it to the moderators++ local nick_element = occupant:get_presence():get_child('nick', NICK_NS);+ if nick_element then+ promotion_request:add_child(nick_element);+ end+module:send(promotion_request);end@@ -236,3 +241,56 @@ endprocess_host_module(main_domain, function(host_module, host)host_module:hook('iq/host', stanza_handler, 10);end);++-- only live chat is supported for visitors+module:hook("muc-occupant-groupchat", function(event)+ local occupant, room, stanza = event.occupant, event.room, event.stanza;+ local from = stanza.attr.from;+ local occupant_host = jid.host(occupant.bare_jid);++ -- if there is no occupant this is a message from main, probably coming from other vnode+ if occupant then+ -- we manage nick only for visitors+ if occupant_host ~= fmuc_main_domain then+ -- add to message stanza display name for the visitor+ -- remove existing nick to avoid forgery+ stanza:remove_children('nick', NICK_NS);+ local nick_element = occupant:get_presence():get_child('nick', NICK_NS);+ if nick_element then+ stanza:add_child(nick_element);+ else+ stanza:tag('nick', { xmlns = NICK_NS })+ :text('anonymous'):up();+ end+ end++ stanza.attr.from = occupant.nick;+ else+ stanza.attr.from = jid.join(jid.node(from), module.host);+ end++ -- let's send it to main chat and rest of visitors here+ for _, o in room:each_occupant() do+ -- filter remote occupants+ if jid.host(o.bare_jid) == main_domain then+ room:route_to_occupant(o, stanza)+ end+ end++ -- send to main participants only messages from local occupants (skip from remote vnodes)+ if occupant and occupant_host ~= fmuc_main_domain then+ local main_message = st.clone(stanza);+ main_message.attr.to = jid.join(jid.node(room.jid), muc_domain_prefix..'.'..fmuc_main_domain);+ module:send(main_message);+ end+ stanza.attr.from = from; -- something prosody does internally++ return true;+end, 55); -- prosody check for visitor's chat is prio 50, we want to override it++module:hook('muc-private-message', function(event)+ -- private messaging is forbidden+ event.origin.send(st.error_reply(event.stanza, "auth", "forbidden",+ "Private messaging is disabled on visitor nodes"));+ return true;+end, 10);diff --git a/resources/prosody-plugins/mod_muc_meeting_id.lua b/resources/prosody-plugins/mod_muc_meeting_id.luaindex cba135c270..e9e9fca11d 100644--- a/resources/prosody-plugins/mod_muc_meeting_id.lua+++ b/resources/prosody-plugins/mod_muc_meeting_id.lua@@ -99,3 +99,9 @@ function handle_jicofo_unlock(event)endmodule:hook('jicofo-unlock-room', handle_jicofo_unlock);++-- make sure we remove nick if someone is sending it with a message to protect+-- forgery of display name+module:hook("muc-occupant-groupchat", function(event)+ event.stanza:remove_children('nick', 'http://jabber.org/protocol/nick');+end, 45); -- prosody check is prio 50, we want to run after itdiff --git a/resources/prosody-plugins/mod_visitors.lua b/resources/prosody-plugins/mod_visitors.luaindex c922760572..ed37160253 100644--- a/resources/prosody-plugins/mod_visitors.lua+++ b/resources/prosody-plugins/mod_visitors.lua@@ -4,11 +4,9 @@--- vm1-ip-address conference.visitors1.domain.com--- vm2-ip-address visitors2.domain.com--- vm2-ip-address conference.visitors2.domain.com---- TODO: drop the /etc/hosts changes for https://modules.prosody.im/mod_s2soutinjection.html--- Enable in global modules: 's2s_bidi' and 'certs_all'--- Make sure 's2s' is not in modules_disabled--- Open port 5269 on the provider side and on the firewall on the machine (iptables -I INPUT 4 -p tcp -m tcp --dport 5269 -j ACCEPT)---- TODO: make it work with tenants--- NOTE: Make sure all communication between prosodies is using the real jids ([foo][email protected])local st = require 'util.stanza';local jid = require 'util.jid';@@ -127,7 +125,6 @@ module:hook('presence/full', function(event)local stanza = event.stanza;local room_name, from_host = jid.split(stanza.attr.from);if stanza.attr.type == 'unavailable' and from_host ~= main_muc_component_config then- -- TODO tenants???local room_jid = jid.join(room_name, main_muc_component_config); -- converts from visitor to main room jidlocal x = stanza:get_child('x', 'http://jabber.org/protocol/muc#user');@@ -231,4 +228,53 @@ process_host_module(main_muc_component_config, function(host_module, host)module:send(fmuc_pr);endend);+ -- forwards messages from main participants to vnodes+ host_module:hook("muc-occupant-groupchat", function(event)+ local room, stanza, occupant = event.room, event.stanza, event.occupant;++ if not visitors_nodes[room.jid] then+ return;+ end++ local vnodes = visitors_nodes[room.jid].nodes;+ local user = jid.node(occupant.nick);+ -- a main participant we need to update all active visitor nodes+ for k in pairs(vnodes) do+ local fmuc_msg = st.clone(stanza);+ fmuc_msg.attr.to = jid.join(user, k);+ fmuc_msg.attr.from = occupant.jid;+ module:send(fmuc_msg);+ end+ end);+ -- receiving messages from visitor nodes and forward them to local main participants+ -- and forward them to the rest of visitor nodes+ host_module:hook("muc-occupant-groupchat", function(event)+ local occupant, room, stanza = event.occupant, event.room, event.stanza;+ local to = stanza.attr.to;+ local from = stanza.attr.from;+ local from_vnode = jid.host(from);++ if occupant or not (visitors_nodes[to] or visitors_nodes[to].nodes[from_vnode]) then+ return;+ end++ -- a message from visitor occupant of known visitor node+ stanza.attr.from = to;+ for _, o in room:each_occupant() do+ -- send it to the nick to be able to route it to the room (ljm multiple rooms) from unknown occupant+ room:route_to_occupant(o, stanza);+ end++ -- now we need to send to rest of visitor nodes+ local vnodes = visitors_nodes[room.jid].nodes;+ for k in pairs(vnodes) do+ if k ~= from_vnode then+ local st_copy = st.clone(stanza);+ st_copy.attr.to = jid.join(jid.node(room.jid), k);+ module:send(st_copy);+ end+ end++ return true;+ end, 55); -- prosody check for unknown participant chat is prio 50, we want to override itend);