-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ov-components: Moved recording and broadcasting middleware logic
- Loading branch information
Showing
5 changed files
with
60 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Request, Response, NextFunction } from 'express'; | ||
import { GlobalPreferencesService } from '../services/global-preferences.service.js'; | ||
import { RoomPreferences } from '@openvidu/call-common-types'; | ||
import { LoggerService } from '../services/logger.service.js'; | ||
|
||
export const withBroadcastingEnabled = async (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
const preferences = await GlobalPreferencesService.getInstance().getRoomPreferences(); | ||
|
||
if (preferences) { | ||
const { broadcastingPreferences } = preferences.value as RoomPreferences; | ||
|
||
if (!broadcastingPreferences.enabled) { | ||
return res.status(403).json({ message: 'Broadcasting is disabled in this room.' }); | ||
} | ||
|
||
return next(); | ||
} | ||
|
||
LoggerService.getInstance().error( | ||
'No room preferences found checking broadcasting preferences. Refusing access.' | ||
); | ||
return res.status(403).json({ message: 'Broadcasting is disabled in this room.' }); | ||
} catch (error) { | ||
LoggerService.getInstance().error('Error checking broadcasting preferences:' + error); | ||
return res.status(403).json({ message: 'Broadcasting is disabled in this room.' }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './auth.middleware.js'; | ||
export * from './auth.middleware.js'; | ||
export * from './recording.middleware.js'; | ||
export * from './broadcasting.middleware.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Request, Response, NextFunction } from 'express'; | ||
import { GlobalPreferencesService } from '../services/global-preferences.service.js'; | ||
import { RoomPreferences } from '@openvidu/call-common-types'; | ||
import { LoggerService } from '../services/logger.service.js'; | ||
|
||
export const withRecordingEnabled = async (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
const preferences = await GlobalPreferencesService.getInstance().getRoomPreferences(); | ||
|
||
if (preferences) { | ||
const { recordingPreferences } = preferences.value as RoomPreferences; | ||
|
||
if (!recordingPreferences.enabled) { | ||
return res.status(403).json({ message: 'Recording is disabled in this room.' }); | ||
} | ||
|
||
return next(); | ||
} | ||
|
||
LoggerService.getInstance().error('No room preferences found checking recording preferences. Refusing access.'); | ||
return res.status(403).json({ message: 'Recording is disabled in this room.' }); | ||
} catch (error) { | ||
LoggerService.getInstance().error('Error checking recording preferences:' + error); | ||
return res.status(403).json({ message: 'Recording is disabled in this room.' }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters