diff --git a/modules/API/API.js b/modules/API/API.js index 088da294619f..eeaedbc5c3de 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -596,9 +596,13 @@ function initCommands() { * Defaults to "normal" if not provided. * @param { string } arg.timeout - Timeout type, either `short`, `medium`, `long` or `sticky`. * Defaults to "short" if not provided. + * @param { Array } arg.customActions - An array of custom actions to be displayed in the notification. + * Each object should have a `label` and a `uuid` property. It should be used along a listener + * for the `customNotificationActionTriggered` event to handle the custom action. * @returns {void} */ 'show-notification': ({ + customActions = [], title, description, uid, @@ -620,7 +624,15 @@ function initCommands() { return; } + const handlers = customActions.map(({ uuid }) => () => { + APP.API.notifyCustomNotificationActionTriggered(uuid); + }); + + const keys = customActions.map(({ label }) => label); + APP.store.dispatch(showNotification({ + customActionHandler: handlers, + customActionNameKey: keys, uid, title, description, @@ -1501,6 +1513,21 @@ class API { }); } + /** + * Notify external application (if API is enabled) that a custom notification action has been triggered. + * + * @param {string} actionUuid - The UUID of the action that has been triggered. + * @returns {void} + */ + notifyCustomNotificationActionTriggered(actionUuid) { + this._sendEvent({ + name: 'custom-notification-action-triggered', + data: { + id: actionUuid + } + }); + } + /** * Notify external application (if API is enabled) that the list of sharing participants changed. * diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index 7b830b934374..9960851f2859 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -114,6 +114,7 @@ const events = { 'compute-pressure-changed': 'computePressureChanged', 'conference-created-timestamp': 'conferenceCreatedTimestamp', 'content-sharing-participants-changed': 'contentSharingParticipantsChanged', + 'custom-notification-action-triggered': 'customNotificationActionTriggered', 'data-channel-closed': 'dataChannelClosed', 'data-channel-opened': 'dataChannelOpened', 'device-list-changed': 'deviceListChanged',