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(file-sharing) add support for file sharing
Calin-Teodor82f2060ebf12
diff --git a/config.js b/config.jsindex 7ed162e764..4249238df3 100644--- a/config.js+++ b/config.js@@ -1882,6 +1882,14 @@ var config = {// If true remove the tint foreground on focused user camera in filmstrip// disableCameraTintForeground: false,++ // File sharign service.+ // fileSharing: {+ // // The URL of the file sharing service API. See resources/file-sharing.yaml for more details.+ // apiUrl: 'https://example.com',+ // // Whether the file sharing service is enabled or not.+ // enabled: true,+ // },};// Set the default values for JaaS customersdiff --git a/lang/main.json b/lang/main.jsonindex 0bc4319562..dd98949e9d 100644--- a/lang/main.json+++ b/lang/main.json@@ -124,7 +124,8 @@"title": "Enter a nickname to use chat","titleWithCC": "Enter a nickname to use chat and closed captions","titleWithPolls": "Enter a nickname to use chat and polls",- "titleWithPollsAndCC": "Enter a nickname to use chat, polls and closed captions"+ "titleWithPollsAndCC": "Enter a nickname to use chat, polls and closed captions",+ "titleWithPollsAndCCAndFileSharing": "Enter a nickname to use chat, polls, closed captions and files"},"noMessagesMessage": "There are no messages in the meeting yet. Start a conversation here!","privateNotice": "Private message to {{recipient}}",@@ -134,12 +135,14 @@"tabs": {"chat": "Chat","closedCaptions": "CC",+ "fileSharing": "Files","polls": "Polls"},"title": "Chat",- "titleWithCC": "Chat and CC",- "titleWithPolls": "Chat and Polls",- "titleWithPollsAndCC": "Chat, Polls and CC",+ "titleWithCC": "CC",+ "titleWithFeatures": "Chat and",+ "titleWithFileSharing": "Files",+ "titleWithPolls": "Polls","you": "you"},"chromeExtensionBanner": {@@ -539,6 +542,17 @@"veryBad": "Very Bad","veryGood": "Very Good"},+ "fileSharing": {+ "downloadFailedDescription": "Please try again.",+ "downloadFailedTitle": "Download failed",+ "downloadFile": "Download",+ "dragAndDrop": "Drag and drop files here",+ "fileAlreadyUploaded": "File has already been uploaded to this meeting",+ "removeFile": "Remove",+ "uploadFailedDescription": "Please try again.",+ "uploadFailedTitle": "Upload failed",+ "uploadFile": "Share file"+ },"filmstrip": {"accessibilityLabel": {"heading": "Video thumbnails"diff --git a/react/features/app/middlewares.web.ts b/react/features/app/middlewares.web.tsindex d6b9f0aaec..391aafaab3 100644--- a/react/features/app/middlewares.web.ts+++ b/react/features/app/middlewares.web.ts@@ -22,5 +22,6 @@ import '../toolbox/middleware';import '../face-landmarks/middleware';import '../gifs/middleware';import '../whiteboard/middleware.web';+import '../file-sharing/middleware.web';import './middlewares.any';diff --git a/react/features/app/reducers.web.ts b/react/features/app/reducers.web.tsindex 33ccaff673..f81950b13d 100644--- a/react/features/app/reducers.web.ts+++ b/react/features/app/reducers.web.ts@@ -17,5 +17,6 @@ import '../screenshot-capture/reducer';import '../talk-while-muted/reducer';import '../virtual-background/reducer';import '../web-hid/reducer';+import '../file-sharing/reducer';import './reducers.any';diff --git a/react/features/app/types.ts b/react/features/app/types.tsindex 28a07e7664..c24445b92c 100644--- a/react/features/app/types.ts+++ b/react/features/app/types.ts@@ -38,6 +38,7 @@ import { IE2EEState } from '../e2ee/reducer';import { IEtherpadState } from '../etherpad/reducer';import { IFaceLandmarksState } from '../face-landmarks/reducer';import { IFeedbackState } from '../feedback/reducer';+import { IFileSharingState } from '../file-sharing/reducer';import { IFilmstripState } from '../filmstrip/reducer';import { IFollowMeState } from '../follow-me/reducer';import { IGifsState } from '../gifs/reducer';@@ -128,6 +129,7 @@ export interface IReduxState {'features/etherpad': IEtherpadState;'features/face-landmarks': IFaceLandmarksState;'features/feedback': IFeedbackState;+ 'features/file-sharing': IFileSharingState;'features/filmstrip': IFilmstripState;'features/follow-me': IFollowMeState;'features/full-screen': IFullScreenState;diff --git a/react/features/base/conference/reducer.ts b/react/features/base/conference/reducer.tsindex b8ddee54a8..6ec7cc6be0 100644--- a/react/features/base/conference/reducer.ts+++ b/react/features/base/conference/reducer.ts@@ -54,6 +54,19 @@ const DEFAULT_STATE = {};export interface IConferenceMetadata {+ files: {+ [fileId: string]: {+ authorParticipantJid: string;+ authorParticipantName: string;+ conferenceFullName: string;+ fileId: string;+ fileName: string;+ fileSize: number;+ fileType: string;+ progress?: number;+ timestamp: number;+ };+ };recording?: {isTranscribingEnabled: boolean;};diff --git a/react/features/base/config/configType.ts b/react/features/base/config/configType.tsindex 2a32e7dc41..c1bf893c3e 100644--- a/react/features/base/config/configType.ts+++ b/react/features/base/config/configType.ts@@ -387,6 +387,10 @@ export interface IConfig {feedbackPercentage?: number;fileRecordingsServiceEnabled?: boolean;fileRecordingsServiceSharingEnabled?: boolean;+ fileSharing?: {+ apiUrl?: string;+ enabled?: boolean;+ };filmstrip?: {disableResizable?: boolean;disableStageFilmstrip?: boolean;diff --git a/react/features/base/config/configWhitelist.ts b/react/features/base/config/configWhitelist.tsindex abffe3cfd5..729e647de5 100644--- a/react/features/base/config/configWhitelist.ts+++ b/react/features/base/config/configWhitelist.ts@@ -150,6 +150,7 @@ export default ['enableTcc','faceLandmarks','feedbackPercentage',+ 'fileSharing.enabled','filmstrip','flags','forceTurnRelay',diff --git a/react/features/base/icons/components/Icon.tsx b/react/features/base/icons/components/Icon.tsxindex 4e6af8f937..665bec8998 100644--- a/react/features/base/icons/components/Icon.tsx+++ b/react/features/base/icons/components/Icon.tsx@@ -72,6 +72,11 @@ interface IProps extends IIconProps {*/id?: string;+ /**+ * On click handler.+ */+ onClick?: (e?: any) => void;+/*** Keydown handler.*/diff --git a/react/features/base/ui/components/types.ts b/react/features/base/ui/components/types.tsindex f3b72bdec5..7fdb1d4cdb 100644--- a/react/features/base/ui/components/types.ts+++ b/react/features/base/ui/components/types.ts@@ -1,5 +1,3 @@-import { GestureResponderEvent } from 'react-native';-import { BUTTON_TYPES } from '../constants.any';export interface IButtonProps {@@ -32,7 +30,7 @@ export interface IButtonProps {/*** Click callback.*/- onClick?: (e?: React.MouseEvent<HTMLButtonElement> | GestureResponderEvent) => void;+ onClick?: (e?: any) => void;/*** Key press callback.diff --git a/react/features/base/ui/components/web/Tabs.tsx b/react/features/base/ui/components/web/Tabs.tsxindex 323168c22e..e92df387de 100644--- a/react/features/base/ui/components/web/Tabs.tsx+++ b/react/features/base/ui/components/web/Tabs.tsx@@ -2,6 +2,7 @@ import React, { useCallback, useEffect } from 'react';import { makeStyles } from 'tss-react/mui';import { isMobileBrowser } from '../../../environment/utils';+import Icon from '../../../icons/components/Icon';import { withPixelLineHeight } from '../../../styles/functions.web';interface ITabProps {@@ -14,8 +15,9 @@ interface ITabProps {controlsId: string;countBadge?: number;disabled?: boolean;+ icon?: Function;id: string;- label: string;+ label?: string;}>;}@@ -74,6 +76,10 @@ const useStyles = makeStyles()(theme => {borderRadius: '100%',backgroundColor: theme.palette.warning01,marginLeft: theme.spacing(2)+ },++ icon: {+ marginRight: theme.spacing(1)}};});@@ -134,6 +140,9 @@ const Tabs = ({onKeyDown = { onKeyDown(index) }role = 'tab'tabIndex = { selected === tab.id ? undefined : -1 }>+ {tab.icon && <Icon+ className = { classes.icon }+ src = { tab.icon } />}{tab.label}{tab.countBadge && <span className = { classes.badge }>{tab.countBadge}</span>}</button>diff --git a/react/features/base/ui/types.ts b/react/features/base/ui/types.tsindex 8a3bd8857c..4871763f4e 100644--- a/react/features/base/ui/types.ts+++ b/react/features/base/ui/types.ts@@ -1,6 +1,6 @@interface ITypographyType {fontSize: number;- fontWeight: string;+ fontWeight: number; // TODO: revisit this.letterSpacing: number;lineHeight: number;}diff --git a/react/features/chat/components/web/Chat.tsx b/react/features/chat/components/web/Chat.tsxindex efd7703238..658b743188 100644--- a/react/features/chat/components/web/Chat.tsx+++ b/react/features/chat/components/web/Chat.tsx@@ -8,11 +8,14 @@ import { translate } from '../../../base/i18n/functions';import { getLocalParticipant } from '../../../base/participants/functions';import Tabs from '../../../base/ui/components/web/Tabs';import { arePollsDisabled } from '../../../conference/functions.any';+import FileSharing from '../../../file-sharing/components/web/FileSharing';+import { isFileSharingEnabled } from '../../../file-sharing/functions.any';import PollsPane from '../../../polls/components/web/PollsPane';import { isCCTabEnabled } from '../../../subtitles/functions.any';import { setChatIsResizing, setUserChatWidth, sendMessage, setFocusedTab, toggleChat } from '../../actions.web';import { CHAT_SIZE, ChatTabs, SMALL_WIDTH_THRESHOLD } from '../../constants';import { IChatProps as AbstractProps } from '../../types';+import { IconMessage, IconInfo, IconSubtitles, IconShareDoc } from '../../../base/icons/svg';import ChatHeader from './ChatHeader';import ChatInput from './ChatInput';@@ -35,6 +38,11 @@ interface IProps extends AbstractProps {*/_isCCTabEnabled: boolean;+ /**+ * True if file sharing tab is enabled.+ */+ _isFileSharingTabEnabled: boolean;+/*** Whether the chat is opened in a modal or not (computed based on window width).*/@@ -215,6 +223,7 @@ const Chat = ({_isOpen,_isPollsEnabled,_isCCTabEnabled,+ _isFileSharingTabEnabled,_focusedTab,_isResizing,_messages,@@ -380,7 +389,10 @@ const Chat = ({aria-labelledby = { ChatTabs.CHAT }className = { cx(classes.chatPanel,- !_isPollsEnabled && !_isCCTabEnabled && classes.chatPanelNoTabs,+ !_isPollsEnabled+ && !_isCCTabEnabled+ && !_isFileSharingTabEnabled+ && classes.chatPanelNoTabs,_focusedTab !== ChatTabs.CHAT && 'hide') }id = { `${ChatTabs.CHAT}-panel` }@@ -413,6 +425,14 @@ const Chat = ({tabIndex = { 2 }><ClosedCaptionsTab /></div> }+ { _isFileSharingTabEnabled && <div+ aria-labelledby = { ChatTabs.FILE_SHARING }+ className = { cx(classes.chatPanel, _focusedTab !== ChatTabs.FILE_SHARING && 'hide') }+ id = { `${ChatTabs.FILE_SHARING}-panel` }+ role = 'tabpanel'+ tabIndex = { 3 }>+ <FileSharing />+ </div> }</>);}@@ -432,7 +452,7 @@ const Chat = ({_focusedTab !== ChatTabs.CHAT && _nbUnreadMessages > 0 ? _nbUnreadMessages : undefined,id: ChatTabs.CHAT,controlsId: `${ChatTabs.CHAT}-panel`,- label: t('chat.tabs.chat')+ icon: IconMessage}];@@ -442,7 +462,7 @@ const Chat = ({countBadge: _focusedTab !== ChatTabs.POLLS && _nbUnreadPolls > 0 ? _nbUnreadPolls : undefined,id: ChatTabs.POLLS,controlsId: `${ChatTabs.POLLS}-panel`,- label: t('chat.tabs.polls')+ icon: IconInfo});}@@ -452,13 +472,32 @@ const Chat = ({countBadge: undefined,id: ChatTabs.CLOSED_CAPTIONS,controlsId: `${ChatTabs.CLOSED_CAPTIONS}-panel`,- label: t('chat.tabs.closedCaptions')+ icon: IconSubtitles+ });+ }++ if (_isFileSharingTabEnabled) {+ tabs.push({+ accessibilityLabel: t('chat.tabs.fileSharing'),+ countBadge: undefined,+ id: ChatTabs.FILE_SHARING,+ controlsId: `${ChatTabs.FILE_SHARING}-panel`,+ icon: IconShareDoc});}return (<Tabs- accessibilityLabel = { t(_isPollsEnabled ? 'chat.titleWithPolls' : 'chat.title') }+ accessibilityLabel = { _isPollsEnabled || _isCCTabEnabled || _isFileSharingTabEnabled+ ? t('chat.titleWithFeatures', {+ features: [+ _isPollsEnabled ? t('chat.titleWithPolls') : '',+ _isCCTabEnabled ? t('chat.titleWithCC') : '',+ _isFileSharingTabEnabled ? t('chat.titleWithFileSharing') : ''+ ].filter(Boolean).join(', ')+ })+ : t('chat.title')+ }onChange = { onChangeTab }selected = { _focusedTab }tabs = { tabs } />@@ -524,6 +563,7 @@ function _mapStateToProps(state: IReduxState, _ownProps: any) {_isOpen: isOpen,_isPollsEnabled: !arePollsDisabled(state),_isCCTabEnabled: isCCTabEnabled(state),+ _isFileSharingTabEnabled: isFileSharingEnabled(state),_focusedTab: focusedTab,_messages: messages,_nbUnreadMessages: nbUnreadMessages,diff --git a/react/features/chat/components/web/ChatHeader.tsx b/react/features/chat/components/web/ChatHeader.tsxindex f20ee671ea..9a17d19d4a 100644--- a/react/features/chat/components/web/ChatHeader.tsx+++ b/react/features/chat/components/web/ChatHeader.tsx@@ -1,10 +1,13 @@import React, { useCallback } from 'react';import { useTranslation } from 'react-i18next';-import { useDispatch } from 'react-redux';+import { useDispatch, useSelector } from 'react-redux';import Icon from '../../../base/icons/components/Icon';import { IconCloseLarge } from '../../../base/icons/svg';import { toggleChat } from '../../actions.web';+import { IReduxState } from '../../../app/types';+import { ChatTabs } from '../../constants';+import { isFileSharingEnabled } from '../../../file-sharing/functions.any';interface IProps {@@ -34,9 +37,11 @@ interface IProps {** @returns {React$Element<any>}*/-function ChatHeader({ className, isPollsEnabled, isCCTabEnabled }: IProps) {+function ChatHeader({ className, isCCTabEnabled, isPollsEnabled }: IProps) {const dispatch = useDispatch();const { t } = useTranslation();+ const { focusedTab } = useSelector((state: IReduxState) => state['features/chat']);+ const fileSharingTabEnabled = useSelector(isFileSharingEnabled);const onCancel = useCallback(() => {dispatch(toggleChat());@@ -51,12 +56,14 @@ function ChatHeader({ className, isPollsEnabled, isCCTabEnabled }: IProps) {let title = 'chat.title';- if (isCCTabEnabled && isPollsEnabled) {- title = 'chat.titleWithPollsAndCC';- } else if (isCCTabEnabled) {- title = 'chat.titleWithCC';- } else if (isPollsEnabled) {- title = 'chat.titleWithPolls';+ if (focusedTab === ChatTabs.CHAT) {+ title = 'chat.tabs.chat';+ } else if (isPollsEnabled && focusedTab === ChatTabs.POLLS) {+ title = 'chat.tabs.polls';+ } else if (isCCTabEnabled && focusedTab === ChatTabs.CLOSED_CAPTIONS) {+ title = 'chat.tabs.closedCaptions';+ } else if (fileSharingTabEnabled && focusedTab === ChatTabs.FILE_SHARING) {+ title = 'chat.tabs.fileSharing';}return (diff --git a/react/features/chat/constants.ts b/react/features/chat/constants.tsindex c20f0fa0ad..21d23310ea 100644--- a/react/features/chat/constants.ts+++ b/react/features/chat/constants.ts@@ -42,6 +42,7 @@ export const LOBBY_CHAT_MESSAGE = 'LOBBY_CHAT_MESSAGE';export enum ChatTabs {CHAT = 'chat-tab',CLOSED_CAPTIONS = 'cc-tab',+ FILE_SHARING = 'file_sharing-tab',POLLS = 'polls-tab'}diff --git a/react/features/file-sharing/actionTypes.ts b/react/features/file-sharing/actionTypes.tsnew file mode 100644index 0000000000..0db6f8f814--- /dev/null+++ b/react/features/file-sharing/actionTypes.ts@@ -0,0 +1,50 @@+/**+ * The type of redux action to update file progress.+ *+ * {+ * type: UPDATE_FILE_UPLOAD_PROGRESS,+ * fileId: string,+ * progress: number+ * }+ */+export const UPDATE_FILE_UPLOAD_PROGRESS = 'UPDATE_FILE_UPLOAD_PROGRESS';++/**+ * The type of redux action to upload files.+ *+ * {+ * type: UPLOAD_FILES,+ * files: Array<File>+ * }+ */+export const UPLOAD_FILES = 'UPLOAD_FILES';++/**+ * The type of redux action to add file data to the state.+ *+ * {+ * type: ADD_FILE,+ * file: IFileMetadata+ * }+ */+export const ADD_FILE = 'ADD_FILE';++/**+ * The type of redux action to remove a file from the state.+ *+ * {+ * type: REMOVE_FILE,+ * fileId: string+ * }+ */+export const REMOVE_FILE = 'REMOVE_FILE';++/**+ * The type of redux action to download a file.+ *+ * {+ * type: DOWNLOAD_FILE,+ * fileId: string+ * }+ */+export const DOWNLOAD_FILE = 'DOWNLOAD_FILE';diff --git a/react/features/file-sharing/actions.ts b/react/features/file-sharing/actions.tsnew file mode 100644index 0000000000..eb6512687c--- /dev/null+++ b/react/features/file-sharing/actions.ts@@ -0,0 +1,75 @@+import {+ ADD_FILE,+ REMOVE_FILE,+ UPDATE_FILE_UPLOAD_PROGRESS,+ UPLOAD_FILES,+ DOWNLOAD_FILE+} from './actionTypes';+import { IFileMetadata } from './types';++/**+ * Upload files.+ *+ * @param {File[]} files - The files to upload.+ * @returns {Object}+ */+export function uploadFiles(files: File[]) {+ return {+ type: UPLOAD_FILES,+ files+ };+}++/**+ * Update a file's upload progress.+ *+ * @param {string} fileId - The ID of the file to update.+ * @param {number} progress - The new progress value.+ * @returns {Object}+ */+export function updateFileProgress(fileId: string, progress: number) {+ return {+ type: UPDATE_FILE_UPLOAD_PROGRESS,+ fileId,+ progress+ };+}++/**+ * Add a file.+ *+ * @param {IFileMetadata} file - The file to add to the state.+ * @returns {Object}+ */+export function addFile(file: IFileMetadata) {+ return {+ type: ADD_FILE,+ file+ };+}++/**+ * Remove a file.+ *+ * @param {string} fileId - The ID of the file to remove.+ * @returns {Object}+ */+export function removeFile(fileId: string) {+ return {+ type: REMOVE_FILE,+ fileId+ };+}++/**+ * Download a file.+ *+ * @param {string} fileId - The ID of the file to download.+ * @returns {Object}+ */+export function downloadFile(fileId: string) {+ return {+ type: DOWNLOAD_FILE,+ fileId+ };+}diff --git a/react/features/file-sharing/components/web/FileSharing.tsx b/react/features/file-sharing/components/web/FileSharing.tsxnew file mode 100644index 0000000000..ea98699477--- /dev/null+++ b/react/features/file-sharing/components/web/FileSharing.tsx@@ -0,0 +1,362 @@+import React, { useCallback, useState, useRef } from 'react';+import { useTranslation } from 'react-i18next';+import { useDispatch, useSelector } from 'react-redux';+import { makeStyles } from 'tss-react/mui';++import { IReduxState } from '../../../app/types';+import { IconCloudUpload, IconDownload, IconTrash } from '../../../base/icons/svg';+import Button from '../../../base/ui/components/web/Button';+import { BUTTON_TYPES } from '../../../base/ui/constants.web';+import Icon from '../../../base/icons/components/Icon';+import { isLocalParticipantModerator } from '../../../base/participants/functions';+import { withPixelLineHeight } from '../../../base/styles/functions.web';+import BaseTheme from '../../../base/ui/components/BaseTheme.web';+import { downloadFile, removeFile, uploadFiles } from '../../actions';+import { formatFileSize, formatTimestamp, getFileIcon } from '../../functions.any';++const useStyles = makeStyles()(theme => {+ return {+ buttonContainer: {+ alignItems: 'center',+ display: 'flex',+ justifyContent: 'end',+ gap: theme.spacing(2),+ position: 'absolute',+ top: 0,+ right: 16,+ bottom: 16,+ left: 0+ },++ container: {+ boxSizing: 'border-box',+ height: '100%',+ margin: '0 auto',+ maxWidth: '600px',+ padding: theme.spacing(3),+ position: 'relative',+ width: '100%'+ },++ downloadButton: {+ marginRight: theme.spacing(1)+ },++ dropZone: {+ backgroundColor: theme.palette.ui02,+ border: `2px dashed ${theme.palette.ui03}`,+ borderRadius: theme.shape.borderRadius,+ bottom: 0,+ left: 0,+ opacity: 0,+ position: 'absolute',+ right: 0,+ top: 0,+ transition: 'opacity 0.15s ease-in-out',+ zIndex: 0,++ '&.dragging': {+ backgroundColor: theme.palette.ui03,+ borderColor: theme.palette.action01,+ opacity: 0.8+ }+ },++ fileIconContainer: {+ display: 'flex',+ margin: 'auto'+ },++ fileItem: {+ backgroundColor: theme.palette.ui02,+ borderRadius: theme.shape.borderRadius,+ display: 'flex',+ flexDirection: 'row',+ gap: theme.spacing(1),+ justifyContent: 'space-between',+ marginBottom: theme.spacing(3),+ padding: theme.spacing(3),++ '&:hover': {+ backgroundColor: theme.palette.ui03,+ borderRadius: theme.shape.borderRadius,++ '& .actionIconVisibility': {+ visibility: 'visible'+ },++ '& .timestampVisibility': {+ visibility: 'hidden'+ }+ }+ },++ fileItemDetails: {+ display: 'flex',+ flexDirection: 'column',+ flexGrow: 2,+ gap: theme.spacing(1),+ minWidth: 0+ },++ fileList: {+ display: 'flex',+ flexDirection: 'column',+ gap: theme.spacing(2),+ gridTemplateColumns: 'repeat(auto-fill, minmax(200px, 1fr))',+ position: 'relative',+ zIndex: 1+ },++ fileName: {+ ...theme.typography.labelBold,+ gap: theme.spacing(1),+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ whiteSpace: 'nowrap'+ },++ fileSize: {+ ...theme.typography.labelRegular+ },++ fileTimestamp: {+ ...theme.typography.labelRegular,+ alignItems: 'center',+ display: 'flex',+ textAlign: 'center'+ },++ hiddenInput: {+ visibility: 'hidden'+ },++ noFilesContainer: {+ display: 'flex',+ flexDirection: 'column',+ height: '88%',+ justifyContent: 'center',+ textAlign: 'center'+ },++ noFilesText: {+ ...withPixelLineHeight(theme.typography.bodyLongBold),+ color: theme.palette.text02,+ padding: '0 24px',+ textAlign: 'center'+ },++ progressBar: {+ backgroundColor: theme.palette.ui03,+ borderRadius: theme.shape.borderRadius,+ height: '4px',+ overflow: 'hidden',+ width: '100%'+ },++ progressFill: {+ backgroundColor: theme.palette.action01,+ height: '100%',+ transition: 'width 0.3s ease'+ },++ removeButton: {+ alignItems: 'center',+ cursor: 'pointer',+ display: 'flex',+ justifyContent: 'center'+ },++ uploadButton: {+ bottom: theme.spacing(4),+ cursor: 'pointer',+ left: '50%',+ position: 'absolute',+ transform: 'translateX(-50%)',+ width: '85%',+ zIndex: 1+ },++ uploadIcon: {+ margin: '0 auto'+ },++ actionIcon: {+ cursor: 'pointer',+ padding: theme.spacing(1),+ visibility: 'hidden'+ }+ };+});++const FileSharing = () => {+ const { classes } = useStyles();+ const [ isDragging, setIsDragging ] = useState(false);+ const fileInputRef = useRef<HTMLInputElement>(null);+ const { t } = useTranslation();+ const dispatch = useDispatch();+ const { files } = useSelector((state: IReduxState) => state['features/file-sharing']);+ const isModerator = useSelector(isLocalParticipantModerator);++ const handleDragEnter = useCallback((e: React.DragEvent) => {+ e.preventDefault();+ e.stopPropagation();+ setIsDragging(true);+ }, []);++ const handleDragLeave = useCallback((e: React.DragEvent) => {+ e.preventDefault();+ e.stopPropagation();+ setIsDragging(false);+ }, []);++ const handleDragOver = useCallback((e: React.DragEvent) => {+ e.preventDefault();+ e.stopPropagation();+ }, []);++ const processFiles = useCallback((fileList: FileList | File[]) => {+ const newFiles = Array.from(fileList);++ dispatch(uploadFiles(newFiles));+ }, [ dispatch ]);++ const handleFileSelect = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {+ if (e.target.files) {+ processFiles(e.target.files);+ }+ }, [ processFiles ]);++ const handleDrop = useCallback((e: React.DragEvent) => {+ e.preventDefault();+ e.stopPropagation();+ setIsDragging(false);++ if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {+ processFiles(e.dataTransfer.files);+ }+ }, [ processFiles ]);++ const handleClick = useCallback(() => {+ fileInputRef.current?.click();+ }, []);++ const handleKeyPress = useCallback((e: React.KeyboardEvent) => {+ if (e.key === 'Enter' || e.key === ' ') {+ fileInputRef.current?.click();+ }+ }, []);++ return (+ <div className = { classes.container }>+ {+ isModerator && (+ <>+ <div+ className = { `${classes.dropZone} ${+ isDragging ? 'dragging' : ''+ }` }+ onDragEnter = { handleDragEnter }+ onDragLeave = { handleDragLeave }+ onDragOver = { handleDragOver }+ onDrop = { handleDrop }+ role = 'button'+ tabIndex = { 0 }>+ <input+ className = { classes.hiddenInput }+ multiple = { true }+ onChange = { handleFileSelect }+ ref = { fileInputRef }+ type = 'file' />+ </div>+ { files.size === 0 && (+ <div className = { classes.noFilesContainer }>+ <Icon+ className = { classes.uploadIcon }+ color = { BaseTheme.palette.icon03 }+ size = { 160 }+ src = { IconCloudUpload } />+ <span className = { classes.noFilesText }>+ { t('fileSharing.dragAndDrop') }+ </span>+ </div>+ ) }+ </>+ )+ }+ { files.size > 0 && (+ <div className = { classes.fileList }>+ { Array.from(files.entries()).map(([ fileId, file ]) => (+ <div+ className = { classes.fileItem }+ key = { fileId }>+ { (file.progress ?? 100) === 100 && (+ <>+ <div className = { classes.fileIconContainer }>+ <Icon+ color = { BaseTheme.palette.icon01 }+ size = { 64 }+ src = { getFileIcon(file.fileType) } />+ </div>+ <div className = { classes.fileItemDetails }>+ <div className = { classes.fileName }>+ { file.fileName }+ </div>+ <div className = { classes.fileSize }>+ { formatFileSize(file.fileSize) }+ </div>+ </div>+ <div className = { `${classes.fileTimestamp} timestampVisibility` }>+ <pre>+ { formatTimestamp(file.timestamp) }+ </pre>+ </div>+ <div className = { classes.buttonContainer }>+ <Icon+ className = { `${classes.actionIcon} actionIconVisibility` }+ color = { BaseTheme.palette.icon01 }++ // eslint-disable-next-line react/jsx-no-bind+ onClick = { () => dispatch(downloadFile(file.fileId)) }+ size = { 24 }+ src = { IconDownload } />+ { isModerator && (+ <Icon+ className = { `${classes.actionIcon} actionIconVisibility` }+ color = { BaseTheme.palette.icon01 }++ // eslint-disable-next-line react/jsx-no-bind+ onClick = { () => dispatch(removeFile(file.fileId)) }+ size = { 24 }+ src = { IconTrash } />+ ) }+ </div>+ </>+ ) }+ { (file.progress ?? 100) < 100 && (+ <div className = { classes.progressBar }>+ <div+ className = { classes.progressFill }+ style = {{ width: `${file.progress}%` }} />+ </div>+ ) }+ </div>+ )) }+ </div>+ )}+ {+ isModerator && (+ <Button+ accessibilityLabel = { t('fileSharing.uploadFile') }+ className = { classes.uploadButton }+ labelKey = { 'fileSharing.uploadFile' }+ onClick = { handleClick }+ onKeyPress = { handleKeyPress }+ type = { BUTTON_TYPES.PRIMARY } />+ )+ }+ </div>+ );+};++export default FileSharing;diff --git a/react/features/file-sharing/constants.ts b/react/features/file-sharing/constants.tsnew file mode 100644index 0000000000..ef163f620e--- /dev/null+++ b/react/features/file-sharing/constants.ts@@ -0,0 +1,4 @@+/**+ * The key for file sharing metadata in the conference.+ */+export const FILE_SHARING_ID = 'files';diff --git a/react/features/file-sharing/functions.any.ts b/react/features/file-sharing/functions.any.tsnew file mode 100644index 0000000000..8c8880342f--- /dev/null+++ b/react/features/file-sharing/functions.any.ts@@ -0,0 +1,94 @@+import { IReduxState } from '../app/types';+import {+ IconImage,+ IconShareDoc,+ IconVideo,+ IconVolumeUp+} from '../base/icons/svg';+import { getLocalizedDateFormatter } from '../base/i18n/dateUtil';++/**+ * Checks whether file sharing feature is enabled.+ *+ * @param {IReduxState} state - The redux state.+ * @returns {boolean} - Indicates if file sharing feature is enabled.+ */+export function isFileSharingEnabled(state: IReduxState) {+ const { fileSharing } = state['features/base/config'] ?? {};++ return Boolean(fileSharing?.enabled && fileSharing?.apiUrl);+}++/**+ * Gets the file extension from a file name.+ *+ * @param {string} fileName - The name of the file to extract the extension from.+ * @returns {string} The file extension or an empty string if none exists.+ */+export function getFileExtension(fileName: string): string {+ const parts = fileName.split('.');++ if (parts.length > 1) {+ return parts.pop()?.toLowerCase() || '';+ }++ return '';+}++/**+ * Gets the appropriate icon for a file based on its type.+ *+ * @param {string} fileType - The file type.+ * @returns {Function} The icon component to use.+ */+export function getFileIcon(fileType: string) {+ if ([ 'mkv', 'mp4', 'mov', 'avi', 'webm' ].includes(fileType)) {+ return IconVideo;+ }++ if ([ 'mp3', 'wav', 'ogg' ].includes(fileType)) {+ return IconVolumeUp;+ }++ if ([ 'jpg', 'jpeg', 'png', 'gif' ].includes(fileType)) {+ return IconImage;+ }++ return IconShareDoc;+}++/**+ * Formats the file size into a human-readable string.+ *+ * @param {number} bytes - The size in bytes.+ * @returns {string} The formatted file size string.+ */+export function formatFileSize(bytes: number): string {+ if (bytes <= 0) {+ return '0 Bytes';+ }++ const sizes = [ 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB' ];+ const i = Math.floor(Math.log(bytes) / Math.log(1024));+ const size = bytes / Math.pow(1024, i);++ // Check if size is an integer after rounding to 2 decimals+ const rounded = Math.round(size * 100) / 100;+ const formattedSize = Number.isInteger(rounded) ? rounded : rounded.toFixed(2);++ return `${formattedSize} ${sizes[i]}`;+}++/**+ * Formats the timestamp into a human-readable string.+ *+ * @param {number} timestamp - The timestamp to format.+ * @returns {string} The formatted timestamp string.+ */+export function formatTimestamp(timestamp: number): string {+ const date = getLocalizedDateFormatter(timestamp);+ const monthDay = date.format('MMM D'); // Eg. "May 15"+ const time = date.format('h:mm A'); // Eg. "2:30 PM"++ return `${monthDay}\n${time}`;+}diff --git a/react/features/file-sharing/logger.ts b/react/features/file-sharing/logger.tsnew file mode 100644index 0000000000..f13cd504c9--- /dev/null+++ b/react/features/file-sharing/logger.ts@@ -0,0 +1,3 @@+import { getLogger } from '../base/logging/functions';++export default getLogger('features/file-sharing');diff --git a/react/features/file-sharing/middleware.web.ts b/react/features/file-sharing/middleware.web.tsnew file mode 100644index 0000000000..0565dbb81f--- /dev/null+++ b/react/features/file-sharing/middleware.web.ts@@ -0,0 +1,193 @@+import { v4 as uuidv4 } from 'uuid';++import { getCurrentConference } from '../base/conference/functions';+import { getLocalParticipant, getParticipantDisplayName } from '../base/participants/functions';+import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';+import { showErrorNotification } from '../notifications/actions';+import { NOTIFICATION_TIMEOUT_TYPE, NOTIFICATION_TYPE } from '../notifications/constants';++import { DOWNLOAD_FILE, REMOVE_FILE, UPLOAD_FILES } from './actionTypes';+import { addFile, removeFile, updateFileProgress } from './actions';+import { getFileExtension } from './functions.any';+import logger from './logger';+import { FILE_SHARING_ID } from './constants';+import { IFileMetadata } from './types';++/**+ * Middleware that handles file sharing actions.+ *+ * @param {Store} store - The redux store.+ * @returns {Function}+ */+MiddlewareRegistry.register(store => next => async action => {+ switch (action.type) {+ case UPLOAD_FILES: {+ const state = store.getState();+ const conference = getCurrentConference(state);+ const sessionId = conference?.getMeetingUniqueId();+ const localParticipant = getLocalParticipant(state);+ const { fileSharing } = state['features/base/config'];+ const { connection } = state['features/base/connection'];+ const { jwt } = state['features/base/jwt'];+ const roomJid = conference?.room?.roomjid;++ for (const file of action.files) {+ const jid = connection!.getJid();+ const fileId = uuidv4();+ const fileMetadata: IFileMetadata = {+ authorParticipantJid: jid,+ authorParticipantName: getParticipantDisplayName(state, localParticipant!.id),+ conferenceFullName: roomJid ?? '',+ fileId,+ fileName: file.name,+ fileSize: file.size,+ fileType: getFileExtension(file.name),+ timestamp: Date.now()+ };++ store.dispatch(addFile(fileMetadata));+ store.dispatch(updateFileProgress(fileId, 1));++ // Upload file.+ const formData = new FormData();++ formData.append('metadata', JSON.stringify(fileMetadata));++ // @ts-ignore+ formData.append('file', file as Blob, file.name);++ // Use XMLHttpRequest to track upload+ const xhr = new XMLHttpRequest();++ xhr.open('POST', `${fileSharing!.apiUrl!}/sessions/${sessionId}/files`);++ if (jwt) {+ xhr.setRequestHeader('Authorization', `Bearer ${jwt}`);+ }++ xhr.upload.onprogress = event => {+ if (event.lengthComputable) {+ const percent = (event.loaded / event.total) * 100;++ store.dispatch(updateFileProgress(fileId, percent));+ }+ };++ xhr.onload = () => {+ const metadataHandler = conference?.getMetadataHandler();++ if (metadataHandler) {+ const existingMetadata = metadataHandler.getMetadata()[FILE_SHARING_ID] ?? {};++ metadataHandler.setMetadata(FILE_SHARING_ID, {+ ...existingMetadata,+ [fileId]: fileMetadata+ });+ }+ };++ xhr.onerror = () => {+ logger.warn('Could not upload file:', xhr.statusText);++ store.dispatch(removeFile(fileId));+ store.dispatch(showErrorNotification({+ titleKey: 'fileSharing.uploadFailedTitle',+ descriptionKey: 'fileSharing.uploadFailedDescription',+ appearance: NOTIFICATION_TYPE.ERROR+ }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));+ };++ xhr.send(formData);+ }++ return next(action);+ }++ case REMOVE_FILE: {+ const state = store.getState();+ const conference = getCurrentConference(state);+ const { fileSharing } = state['features/base/config'];+ const { jwt } = state['features/base/jwt'];+ const sessionId = conference?.getMeetingUniqueId();+ let doDelete = false;++ // First remove the file metadata so others won't attempt to download it anymore.+ const metadataHandler = conference?.getMetadataHandler();++ if (metadataHandler) {+ const existingMetadata = metadataHandler.getMetadata()[FILE_SHARING_ID] ?? {};+ const fileMetadata = existingMetadata[action.fileId];++ doDelete = (fileMetadata?.process ?? 100) === 100;++ delete existingMetadata[action.fileId];+ metadataHandler.setMetadata(FILE_SHARING_ID, existingMetadata);+ }++ if (!doDelete) {+ return next(action);+ }++ // Now delete it from the server.+ fetch(`${fileSharing!.apiUrl!}/sessions/${sessionId}/files/${action.fileId}`, {+ method: 'DELETE',+ headers: {+ ...jwt && { 'Authorization': `Bearer ${jwt}` }+ }+ })+ .then(response => {+ if (!response.ok) {+ throw new Error(`Failed to delete file: ${response.statusText}`);+ }+ })+ .catch(error => {+ logger.warn('Could not delete file:', error);+ });++ return next(action);+ }++ case DOWNLOAD_FILE: {+ const state = store.getState();+ const { fileSharing } = state['features/base/config'];+ const { jwt } = state['features/base/jwt'];+ const conference = getCurrentConference(state);+ const sessionId = conference?.getMeetingUniqueId();++ fetch(`${fileSharing!.apiUrl!}/sessions/${sessionId}/document`, {+ method: 'GET',+ headers: {+ ...jwt && { 'Authorization': `Bearer ${jwt}` },+ 'X-File-Id': action.fileId,+ }+ })+ .then(response => response.json())+ .then(data => {+ const url = data.presignedUrl;++ if (!url) {+ throw new Error('No presigned URL found in the response.');+ }++ const newTab = window.open(url, '_blank', 'noreferrer,noopener');++ if (!newTab) {+ throw new Error('Failed to open a new tab for the file download.');+ }+ })+ .catch(error => {+ logger.warn('Could not download file:', error);++ store.dispatch(showErrorNotification({+ titleKey: 'fileSharing.downloadFailedTitle',+ descriptionKey: 'fileSharing.downloadFailedDescription',+ appearance: NOTIFICATION_TYPE.ERROR+ }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));+ });++ return next(action);+ }+ }++ return next(action);+});diff --git a/react/features/file-sharing/reducer.ts b/react/features/file-sharing/reducer.tsnew file mode 100644index 0000000000..9592a98019--- /dev/null+++ b/react/features/file-sharing/reducer.ts@@ -0,0 +1,77 @@+import { UPDATE_CONFERENCE_METADATA } from '../base/conference/actionTypes';+import ReducerRegistry from '../base/redux/ReducerRegistry';++import {+ ADD_FILE,+ REMOVE_FILE,+ UPDATE_FILE_UPLOAD_PROGRESS+} from './actionTypes';+import { FILE_SHARING_ID } from './constants';+import { IFileMetadata } from './types';++export interface IFileSharingState {+ files: Map<string, IFileMetadata>;+}++const DEFAULT_STATE = {+ files: new Map<string, IFileMetadata>()+};++ReducerRegistry.register<IFileSharingState>('features/file-sharing',+(state = DEFAULT_STATE, action): IFileSharingState => {+ switch (action.type) {+ case ADD_FILE: {+ const newFiles = new Map(state.files);++ newFiles.set(action.file.fileId, action.file);++ return {+ files: newFiles+ };+ }++ case REMOVE_FILE: {+ const newFiles = new Map(state.files);++ newFiles.delete(action.fileId);++ return {+ files: newFiles+ };+ }++ case UPDATE_FILE_UPLOAD_PROGRESS: {+ const newFiles = new Map(state.files);+ const file = newFiles.get(action.fileId);++ if (file) {+ newFiles.set(action.fileId, { ...file, progress: action.progress });+ }++ return {+ files: newFiles+ };+ }++ case UPDATE_CONFERENCE_METADATA: {+ const { metadata } = action;+ const files = metadata?.[FILE_SHARING_ID];++ if (files) {+ const newFiles: Map<string, IFileMetadata> = new Map(Object.entries(files));++ return {+ files: new Map([+ ...state.files,+ ...newFiles+ ])+ };+ }++ return state;+ }++ default:+ return state;+ }+});diff --git a/react/features/file-sharing/types.ts b/react/features/file-sharing/types.tsnew file mode 100644index 0000000000..308ea68184--- /dev/null+++ b/react/features/file-sharing/types.ts@@ -0,0 +1,11 @@+export interface IFileMetadata {+ authorParticipantJid: string;+ authorParticipantName: string;+ conferenceFullName: string;+ fileId: string;+ fileName: string;+ fileSize: number;+ fileType: string;+ progress?: number;+ timestamp: number;+}diff --git a/resources/file-sharing.yaml b/resources/file-sharing.yamlnew file mode 100644index 0000000000..bef87fb766--- /dev/null+++ b/resources/file-sharing.yaml@@ -0,0 +1,264 @@+openapi: 3.0.1+info:+ title: File Sharing API+ description: Management of the file sharing feature+ version: 1.0.0+servers:+ - url: https://your-server-here+ description: Generated server url+security:+ - HttpBearerKey: []+tags:+ - name: Content sharing history+ description: crud operation for screenshots+ - name: Webhook controller+ description: listens for room destroy events and generates screenshots webhooks and return jaas sign links+ - name: Document sharing history+ description: crud operation for shared documents+ - name: JaaS controller+ description: Management of jaas screenshots+paths:+ /v1/documents/sessions/{sessionId}/files:+ get:+ tags:+ - Document sharing history+ summary: Return a list of metadata with pre-sign urls for download+ description: Used to get the list of files in past meetings+ operationId: retrieveContentSharingHistory_1+ parameters:+ - name: sessionId+ in: path+ required: true+ schema:+ type: string+ - name: offset+ in: query+ required: false+ schema:+ type: integer+ format: int32+ default: 0+ - name: page-size+ in: query+ required: false+ schema:+ type: integer+ format: int32+ default: 20+ responses:+ '200':+ description: OK+ content:+ application/json:+ schema:+ type: array+ items:+ $ref: '#/components/schemas/CssFileMetadataResponse'+ post:+ tags:+ - Document sharing history+ summary: Save an document and metadata+ description: Add a document to a meeting - allowed only to moderators if any+ operationId: addDocumentInMeeting+ parameters:+ - name: sessionId+ in: path+ required: true+ schema:+ type: string+ requestBody:+ content:+ multipart/form-data:+ schema:+ required:+ - file+ - metadata+ type: object+ properties:+ metadata:+ type: string+ example: '{"conferenceFullName":"[email protected]","timestamp":1741017572040,"fileSize":1042157,"fileId":"e393a7e5-e790-4f43-836e-d27238201904","authorParticipantJid":"[email protected]/SVBypbHvcgRT"}'+ file:+ type: string+ format: binary+ responses:+ '200':+ description: Document added successfully+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/AddDocumentResponse'+ example:+ fileId: e393a7e5-e790-4f43-836e-d27238201904+ delete:+ tags:+ - Document sharing history+ summary: Deletes documents for a given session, user and customer+ operationId: deleteDocumentsForSessionCustomerAndUser+ parameters:+ - name: sessionId+ in: path+ required: true+ schema:+ type: string+ - name: user-id+ in: query+ required: true+ schema:+ type: string+ - name: customer-id+ in: query+ required: true+ schema:+ type: string+ responses:+ '204':+ description: No Content+ /v1/documents/sessions/{sessionId}/document:+ get:+ tags:+ - Document sharing history+ summary: Get file pre-signed URL plus document info+ description: Used by UI to get the presign url for the file before serving it to the user who needs it+ operationId: getFileInfo+ parameters:+ - name: sessionId+ in: path+ required: true+ schema:+ type: string+ - name: X-File-Id+ in: header+ required: true+ schema:+ type: string+ responses:+ '200':+ description: OK+ content:+ '*/*':+ schema:+ $ref: '#/components/schemas/DocumentMetadataResponse'+ /v1/documents/sessions/{sessionId}/files/{fileId}:+ delete:+ tags:+ - Document sharing history+ summary: Delete a file by sessionId and fileId+ description: Delete a file by sessionId and fileId allowed by all moderators+ operationId: deleteFile+ parameters:+ - name: sessionId+ in: path+ required: true+ schema:+ type: string+ - name: fileId+ in: path+ required: true+ schema:+ type: string+ responses:+ '200':+ description: OK+components:+ schemas:+ Payload:+ type: object+ properties:+ isBreakout:+ type: boolean+ conference:+ type: string+ AddDocumentResponse:+ type: object+ properties:+ fileId:+ type: string+ description: File ID of the added document+ example: e393a7e5-e790-4f43-836e-d27238201904+ description: Response body containing the fileId of the added document+ CssFileMetadataResponse:+ type: object+ properties:+ objectId:+ type: string+ description: Object id - can be file id+ example: e393a7e5-e790-4f43-836e-d27238201904+ sessionId:+ type: string+ description: Session id+ example: 85a32e37-ddd5-45de-89a6-e94ccffe547a+ timestamp:+ type: integer+ description: Added timestamp+ format: int64+ example: 124+ contentType:+ type: string+ description: Content type+ example: application/pdf+ objectName:+ type: string+ description: Object name+ example: e393a7e5-e790-4f43-836e-d27238201904+ initiatorId:+ type: string+ description: User id for the author+ example: f56g5y4+ preSignedUrl:+ type: string+ description: Presign url - expires after 24h for JaaS+ example: https://oracle.com/presigned-url+ description: Response body containing the file metadata+ PaginatedResponseCssFileMetadataResponse:+ type: object+ properties:+ content:+ type: array+ items:+ $ref: '#/components/schemas/CssFileMetadataResponse'+ nextStartWith:+ type: string+ DocumentMetadataResponse:+ type: object+ properties:+ fileId:+ type: string+ description: File ID of the document+ example: e393a7e5-e790-4f43-836e-d27238201904+ sessionId:+ type: string+ description: Session ID of the document+ example: 85a32e37-ddd5-45de-89a6-e94ccffe547a+ fileName:+ type: string+ description: Filename+ example: sample.pdf+ customerId:+ type: string+ description: Customer id+ example: vthtryv56yb65+ userId:+ type: string+ description: User id+ example: dvdsvfhjv+ presignedUrl:+ type: string+ description: Presign url - points to document sharing since for CSS the link expires in 3h+ example: https://content-sharing-url.com+ createdAt:+ type: integer+ description: Created at+ format: int64+ example: 1745436546+ fileSize:+ type: integer+ description: File Size+ format: int64+ example: 124+ description: Response body containing the document metadata+ securitySchemes:+ HttpBearerKey:+ type: http+ description: Http request Authorization header+ scheme: bearer