Shinobi/libs/extenders.js

106 lines
4.5 KiB
JavaScript
Raw Normal View History

2018-10-02 00:21:48 +00:00
module.exports = function(s,config){
s.cloudDiskUseStartupExtensions = {}
s.cloudDiskUseOnGetVideoDataExtensions = {}
2022-07-03 21:09:56 +00:00
function createExtension(nameOfExtension,nameOfExtensionContainer,objective){
2022-07-03 20:50:53 +00:00
nameOfExtensionContainer = nameOfExtensionContainer || `${nameOfExtension}Extensions`
2022-07-03 21:09:56 +00:00
if(objective){
s[nameOfExtensionContainer] = []
s[nameOfExtension] = function(nameOfCallback,callback){
s[nameOfExtensionContainer][nameOfCallback] = callback
}
}else{
s[nameOfExtensionContainer] = []
s[nameOfExtension] = function(callback){
s[nameOfExtensionContainer].push(callback)
}
2022-07-03 20:50:53 +00:00
}
2018-10-02 00:21:48 +00:00
}
2024-08-22 18:29:10 +00:00
s.runExtensionsForArray = (nameOfExtension, nameOfExtensionContainer, args) => {
nameOfExtensionContainer = nameOfExtensionContainer || `${nameOfExtension}Extensions`
const theExtenders = s[nameOfExtensionContainer];
for(extender of theExtenders){
extender(...args)
}
}
s.runExtensionsForArrayAwaited = async (nameOfExtension, nameOfExtensionContainer, args) => {
nameOfExtensionContainer = nameOfExtensionContainer || `${nameOfExtension}Extensions`
const theExtenders = s[nameOfExtensionContainer];
for(extender of theExtenders){
await extender(...args)
}
}
s.runExtensionsForObject = (nameOfExtension, nameOfExtensionContainer, args) => {
nameOfExtensionContainer = nameOfExtensionContainer || `${nameOfExtension}Extensions`
const theExtenders = s[nameOfExtensionContainer];
for(extender in theExtenders){
extender(...args)
}
}
s.runExtensionsForObjectAwaited = async (nameOfExtension, nameOfExtensionContainer, args) => {
nameOfExtensionContainer = nameOfExtensionContainer || `${nameOfExtension}Extensions`
const theExtenders = s[nameOfExtensionContainer];
for(extender in theExtenders){
await extender(...args)
}
}
2022-07-03 20:50:53 +00:00
////// USER //////
createExtension(`onSocketAuthentication`)
createExtension(`onUserLog`)
createExtension(`loadGroupExtender`,`loadGroupExtensions`)
createExtension(`loadGroupAppExtender`,`loadGroupAppExtensions`)
createExtension(`unloadGroupAppExtender`,`unloadGroupAppExtensions`)
createExtension(`onAccountSave`)
createExtension(`beforeAccountSave`)
createExtension(`onTwoFactorAuthCodeNotification`)
createExtension(`onStalePurgeLock`)
createExtension(`onVideoAccess`)
createExtension(`onLogout`)
2022-07-03 20:50:53 +00:00
////// EVENTS //////
createExtension(`onEventTrigger`)
createExtension(`onEventTriggerBeforeFilter`)
createExtension(`onFilterEvent`)
////// MONITOR //////
2022-07-03 20:50:53 +00:00
createExtension(`onMonitorInit`)
createExtension(`onMonitorStart`)
createExtension(`onMonitorStop`)
createExtension(`onMonitorSave`)
createExtension(`onMonitorUnexpectedExit`)
createExtension(`onDetectorNoTriggerTimeout`)
createExtension(`onFfmpegCameraStringCreation`)
createExtension(`onFfmpegBuildMainStream`)
createExtension(`onFfmpegBuildStreamChannel`)
createExtension(`onMonitorPingFailed`)
createExtension(`onMonitorDied`)
createExtension(`onMonitorCreateStreamPipe`)
2018-12-12 22:56:29 +00:00
///////// SYSTEM ////////
2022-07-03 20:50:53 +00:00
createExtension(`onProcessReady`)
createExtension(`onProcessExit`)
createExtension(`onBeforeDatabaseLoad`)
createExtension(`onFFmpegLoaded`)
createExtension(`beforeMonitorsLoadedOnStartup`)
createExtension(`onWebSocketConnection`)
createExtension(`onWebSocketDisconnection`)
createExtension(`onWebsocketMessageSend`)
createExtension(`onOtherWebSocketMessages`)
createExtension(`onGetCpuUsage`)
createExtension(`onGetRamUsage`)
createExtension(`onSubscriptionCheck`)
createExtension(`onDataPortMessage`)
2022-07-03 21:52:30 +00:00
createExtension(`onHttpRequestUpgrade`,null,true)
2024-09-28 16:55:50 +00:00
createExtension(`onPluginConnected`)
createExtension(`onPluginDisconnected`)
2024-08-22 18:29:10 +00:00
/////// CRON ////////
createExtension(`onCronGroupProcessed`)
createExtension(`onCronGroupProcessedAwaited`)
createExtension(`onCronGroupBeforeProcessed`)
createExtension(`onCronGroupBeforeProcessedAwaited`)
/////// VIDEOS ////////
2022-07-03 20:50:53 +00:00
createExtension(`insertCompletedVideoExtender`,`insertCompletedVideoExtensions`)
createExtension(`onEventBasedRecordingComplete`)
createExtension(`onEventBasedRecordingStart`)
2022-07-03 20:50:53 +00:00
createExtension(`onBeforeInsertCompletedVideo`)
createExtension(`onCloudVideoUploaded`)
/////// TIMELAPSE ////////
2022-07-03 20:50:53 +00:00
createExtension(`onInsertTimelapseFrame`)
2018-10-02 00:21:48 +00:00
}