Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(files): add external api events for upload/delete (#16908)

Mihaela Dumitrub4cc46660888
diff --git a/modules/API/API.js b/modules/API/API.js
index b154f45570..7c87172a96 100755
--- a/modules/API/API.js
+++ b/modules/API/API.js
@@ -2253,6 +2253,32 @@ class API {
});
}
+ /**
+ * Notify the external application that a file has been uploaded.
+ *
+ * @param {Object} fileMetadata - The file metadata.
+ * @returns {void}
+ */
+ notifyFileUploaded(fileMetadata) {
+ this._sendEvent({
+ name: 'file-uploaded',
+ file: fileMetadata
+ });
+ }
+
+ /**
+ * Notify the external application that a file has been deleted.
+ *
+ * @param {string} fileId - The ID of the deleted file.
+ * @returns {void}
+ */
+ notifyFileDeleted(fileId) {
+ this._sendEvent({
+ name: 'file-deleted',
+ fileId
+ });
+ }
+
/**
* Notify the external application that the audio or video is being shared by a participant.
*
diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js
index b139558b78..04ca95ead3 100644
--- a/modules/API/external/external_api.js
+++ b/modules/API/external/external_api.js
@@ -133,6 +133,8 @@ const events = {
'face-landmark-detected': 'faceLandmarkDetected',
'feedback-submitted': 'feedbackSubmitted',
'feedback-prompt-displayed': 'feedbackPromptDisplayed',
+ 'file-deleted': 'fileDeleted',
+ 'file-uploaded': 'fileUploaded',
'filmstrip-display-changed': 'filmstripDisplayChanged',
'incoming-message': 'incomingMessage',
'knocking-participant': 'knockingParticipant',
diff --git a/react/features/file-sharing/middleware.web.ts b/react/features/file-sharing/middleware.web.ts
index 9e6acb250b..ebabb6c60f 100644
--- a/react/features/file-sharing/middleware.web.ts
+++ b/react/features/file-sharing/middleware.web.ts
@@ -72,6 +72,9 @@ StateListenerRegistry.register(
type: _FILE_REMOVED,
fileId
});
+
+ // Notify external API about file deletion (for remote participants)
+ APP.API.notifyFileDeleted(fileId);
});
conference.on(JitsiConferenceEvents.FILE_SHARING_FILES_RECEIVED, (files: object) => {
@@ -83,6 +86,11 @@ StateListenerRegistry.register(
files,
localParticipantId: localParticipant?.id
});
+
+ // Notify external API about existing files (for participants joining late)
+ Object.values(files).forEach((file: IFileMetadata) => {
+ APP.API.notifyFileUploaded(file);
+ });
});
}
});
@@ -152,6 +160,8 @@ MiddlewareRegistry.register(store => next => action => {
privateMessage: false,
timestamp: file.timestamp
}));
+
+ APP.API.notifyFileUploaded(file);
}
return result;
@@ -178,6 +188,9 @@ MiddlewareRegistry.register(store => next => action => {
fileId
});
+ // Notify external API about file deletion (for the local participant who deleted it)
+ APP.API.notifyFileDeleted(fileId);
+
const { fileSharing } = state['features/base/config'];
const sessionId = conference.getMeetingUniqueId();