@ -1,6 +1,10 @@
// @flow
import { getMeetingRegion , getRecordingSharingUrl } from '../base/config' ;
import JitsiMeetJS , { JitsiRecordingConstants } from '../base/lib-jitsi-meet' ;
import { getLocalParticipant , getParticipantDisplayName } from '../base/participants' ;
import { copyText } from '../base/util/helpers' ;
import { getVpaasTenant , isVpaasMeeting } from '../billing-counter/functions' ;
import {
NOTIFICATION _TIMEOUT ,
hideNotification ,
@ -14,6 +18,8 @@ import {
SET _PENDING _RECORDING _NOTIFICATION _UID ,
SET _STREAM _KEY
} from './actionTypes' ;
import { getRecordingLink , getResourceId } from './functions' ;
import logger from './logger' ;
/ * *
* Clears the data of every recording sessions .
@ -136,26 +142,68 @@ export function showStoppedRecordingNotification(streamType: string, participant
* Signals that a started recording notification should be shown on the
* screen for a given period .
*
* @ param { string } streamTyp e - The type of the stream ( { @ code file } or
* { @ code stream } ) .
* @ param { string } participantName - The participant name that started the recording .
* @ returns { showNotifica tion}
* @ param { string } mod e - The type of the recording : Stream of File .
* @ param { string | Object } initiator - The participant who started recording .
* @ param { string } sessionId - The recording session id .
* @ returns { Func tion}
* /
export function showStartedRecordingNotification ( streamType : string , participantName : string ) {
const isLiveStreaming
= streamType === JitsiMeetJS . constants . recording . mode . STREAM ;
const descriptionArguments = { name : participantName } ;
const dialogProps = isLiveStreaming ? {
descriptionKey : participantName ? 'liveStreaming.onBy' : 'liveStreaming.on' ,
descriptionArguments ,
titleKey : 'dialog.liveStreaming'
} : {
descriptionKey : participantName ? 'recording.onBy' : 'recording.on' ,
descriptionArguments ,
titleKey : 'dialog.recording'
} ;
export function showStartedRecordingNotification (
mode : string ,
initiator : Object | string ,
sessionId : string ) {
return async ( dispatch : Function , getState : Function ) => {
const state = getState ( ) ;
const initiatorId = getResourceId ( initiator ) ;
const participantName = getParticipantDisplayName ( state , initiatorId ) ;
let dialogProps = {
customActionNameKey : undefined ,
descriptionKey : participantName ? 'liveStreaming.onBy' : 'liveStreaming.on' ,
descriptionArguments : { name : participantName } ,
isDismissAllowed : true ,
titleKey : 'dialog.liveStreaming'
} ;
return showNotification ( dialogProps , NOTIFICATION _TIMEOUT ) ;
if ( mode !== JitsiMeetJS . constants . recording . mode . STREAM ) {
const recordingSharingUrl = getRecordingSharingUrl ( state ) ;
const iAmRecordingInitiator = getLocalParticipant ( state ) . id === initiatorId ;
dialogProps = {
customActionHandler : undefined ,
customActionNameKey : undefined ,
descriptionKey : participantName ? 'recording.onBy' : 'recording.on' ,
descriptionArguments : { name : participantName } ,
isDismissAllowed : true ,
titleKey : 'dialog.recording'
} ;
// fetch the recording link from the server for recording initiators in jaas meetings
if ( recordingSharingUrl
&& isVpaasMeeting ( state )
&& iAmRecordingInitiator ) {
const region = getMeetingRegion ( state ) ;
const tenant = getVpaasTenant ( state ) ;
try {
const link = await getRecordingLink ( recordingSharingUrl , sessionId , region , tenant ) ;
// add the option to copy recording link
dialogProps . customActionNameKey = 'recording.copyLink' ;
dialogProps . customActionHandler = ( ) => copyText ( link ) ;
dialogProps . titleKey = 'recording.on' ;
dialogProps . descriptionKey = 'recording.linkGenerated' ;
dialogProps . isDismissAllowed = false ;
} catch ( err ) {
dispatch ( showErrorNotification ( {
titleKey : 'recording.errorFetchingLink'
} ) ) ;
return logger . error ( 'Could not fetch recording link' , err ) ;
}
}
}
dispatch ( showNotification ( dialogProps ) ) ;
} ;
}
/ * *