import { ReplaySubject } from 'rxjs'
import { first, shareReplay } from 'rxjs/operators'
import { getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks'
-import { ClientHook, ClientHookName } from '@shared/models/plugins/client-hook.model'
+import { ClientHook, ClientHookName, clientHookObject } from '@shared/models/plugins/client-hook.model'
import { PluginClientScope } from '@shared/models/plugins/plugin-client-scope.type'
interface HookStructValue extends RegisterHookOptions {
const { plugin, clientScript } = pluginInfo
const registerHook = (options: RegisterHookOptions) => {
+ if (clientHookObject[options.target] !== true) {
+ console.error('Unknown hook %s of plugin %s. Skipping.', options.target, plugin.name)
+ return
+ }
+
if (!this.hooks[options.target]) this.hooks[options.target] = []
this.hooks[options.target].push({
err => this.notifier.error(err.text)
)
+
+ this.hooks.runAction('action:search.init')
}
ngOnDestroy () {
this.videoService.getVideos.bind(this.videoService),
params,
'common',
- 'filter:api.videos.list.local.params',
- 'filter:api.videos.list.local.result'
+ 'filter:api.local-videos.videos.list.params',
+ 'filter:api.local-videos.videos.list.result'
)
}
this.videoService.getVideos.bind(this.videoService),
params,
'common',
- 'filter:api.videos.list.recently-added.params',
- 'filter:api.videos.list.recently-added.result'
+ 'filter:api.recently-added-videos.videos.list.params',
+ 'filter:api.recently-added-videos.videos.list.result'
)
}
this.videoService.getVideos.bind(this.videoService),
params,
'common',
- 'filter:api.videos.list.trending.params',
- 'filter:api.videos.list.trending.result'
+ 'filter:api.trending-videos.videos.list.params',
+ 'filter:api.trending-videos.videos.list.result'
)
}
this.videoService.getUserSubscriptionVideos.bind(this.videoService),
params,
'common',
- 'filter:api.videos.list.user-subscriptions.params',
- 'filter:api.videos.list.user-subscriptions.result'
+ 'filter:api.user-subscriptions-videos.videos.list.params',
+ 'filter:api.user-subscriptions-videos.videos.list.result'
)
}
import { RegisterHookOptions } from '../../../shared/models/plugins/register-hook.model'
import { PluginSettingsManager } from '../../../shared/models/plugins/plugin-settings-manager.model'
import { PluginStorageManager } from '../../../shared/models/plugins/plugin-storage-manager.model'
-import { ServerHook, ServerHookName } from '../../../shared/models/plugins/server-hook.model'
+import { ServerHook, ServerHookName, serverHookObject } from '../../../shared/models/plugins/server-hook.model'
import { getHookType, internalRunHook } from '../../../shared/core-utils/plugins/hooks'
import { RegisterOptions } from '../../typings/plugins/register-options.model'
import { PluginLibrary } from '../../typings/plugins'
private getRegisterHelpers (npmName: string, plugin: PluginModel): RegisterOptions {
const registerHook = (options: RegisterHookOptions) => {
+ if (serverHookObject[options.target] !== true) {
+ logger.warn('Unknown hook %s of plugin %s. Skipping.', options.target, npmName)
+ return
+ }
+
if (!this.hooks[options.target]) this.hooks[options.target] = []
this.hooks[options.target].push({
-export type ClientFilterHookName =
- 'filter:api.videos.list.trending.params' |
- 'filter:api.videos.list.trending.result' |
+// Data from API hooks: {hookType}:api.{location}.{elementType}.{actionType}.{target}
- 'filter:api.videos.list.local.params' |
- 'filter:api.videos.list.local.result' |
+export const clientFilterHookObject = {
+ 'filter:api.trending-videos.videos.list.params': true,
+ 'filter:api.trending-videos.videos.list.result': true,
- 'filter:api.videos.list.recently-added.params' |
- 'filter:api.videos.list.recently-added.result' |
+ 'filter:api.local-videos.videos.list.params': true,
+ 'filter:api.local-videos.videos.list.result': true,
- 'filter:api.videos.list.user-subscriptions.params' |
- 'filter:api.videos.list.user-subscriptions.result' |
+ 'filter:api.recently-added-videos.videos.list.params': true,
+ 'filter:api.recently-added-videos.videos.list.result': true,
- 'filter:api.video-watch.video.get.params' |
- 'filter:api.video-watch.video.get.result' |
+ 'filter:api.user-subscriptions-videos.videos.list.params': true,
+ 'filter:api.user-subscriptions-videos.videos.list.result': true,
- 'filter:api.video-watch.video-threads.list.params' |
- 'filter:api.video-watch.video-threads.list.result' |
+ 'filter:api.video-watch.video.get.params': true,
+ 'filter:api.video-watch.video.get.result': true,
- 'filter:api.video-watch.video-thread-replies.list.params' |
- 'filter:api.video-watch.video-thread-replies.list.result' |
+ 'filter:api.video-watch.video-threads.list.params': true,
+ 'filter:api.video-watch.video-threads.list.result': true,
- 'filter:api.search.videos.list.params' |
- 'filter:api.search.videos.list.result' |
- 'filter:api.search.video-channels.list.params' |
- 'filter:api.search.video-channels.list.result'
+ 'filter:api.video-watch.video-thread-replies.list.params': true,
+ 'filter:api.video-watch.video-thread-replies.list.result': true,
-export type ClientActionHookName =
- 'action:application.init' |
+ 'filter:api.search.videos.list.params': true,
+ 'filter:api.search.videos.list.result': true,
+ 'filter:api.search.video-channels.list.params': true,
+ 'filter:api.search.video-channels.list.result': true
+}
+
+export type ClientFilterHookName = keyof typeof clientFilterHookObject
+
+export const clientActionHookObject = {
+ 'action:application.init': true,
- 'action:video-watch.init' |
+ 'action:video-watch.init': true,
+ 'action:video-watch.video.loaded': true,
+
+ 'action:search.init': true
+}
- 'action:video-watch.video.loaded'
+export type ClientActionHookName = keyof typeof clientActionHookObject
-export type ClientHookName = ClientActionHookName | ClientFilterHookName
+export const clientHookObject = Object.assign({}, clientFilterHookObject, clientActionHookObject)
+export type ClientHookName = keyof typeof clientHookObject
export interface ClientHook {
runHook <T> (hookName: ClientHookName, result?: T, params?: any): Promise<T>
-export type ServerFilterHookName =
- 'filter:api.videos.list.params' |
- 'filter:api.videos.list.result' |
- 'filter:api.video.get.result' |
+export const serverFilterHookObject = {
+ 'filter:api.videos.list.params': true,
+ 'filter:api.videos.list.result': true,
+ 'filter:api.video.get.result': true,
- 'filter:api.video.upload.accept.result' |
- 'filter:api.video-thread.create.accept.result' |
- 'filter:api.video-comment-reply.create.accept.result' |
+ 'filter:api.video.upload.accept.result': true,
+ 'filter:api.video-thread.create.accept.result': true,
+ 'filter:api.video-comment-reply.create.accept.result': true,
- 'filter:api.video-threads.list.params' |
- 'filter:api.video-threads.list.result' |
+ 'filter:api.video-threads.list.params': true,
+ 'filter:api.video-threads.list.result': true,
- 'filter:api.video-thread-comments.list.params' |
- 'filter:api.video-thread-comments.list.result' |
+ 'filter:api.video-thread-comments.list.params': true,
+ 'filter:api.video-thread-comments.list.result': true,
- 'filter:video.auto-blacklist.result'
+ 'filter:video.auto-blacklist.result': true
+}
+
+export type ServerFilterHookName = keyof typeof serverFilterHookObject
-export type ServerActionHookName =
- 'action:application.listening' |
+export const serverActionHookObject = {
+ 'action:application.listening': true,
- 'action:api.video.updated' |
- 'action:api.video.deleted' |
- 'action:api.video.uploaded' |
- 'action:api.video.viewed' |
+ 'action:api.video.updated': true,
+ 'action:api.video.deleted': true,
+ 'action:api.video.uploaded': true,
+ 'action:api.video.viewed': true,
+
+ 'action:api.video-thread.created': true,
+ 'action:api.video-comment-reply.created': true,
+ 'action:api.video-comment.deleted': true
+}
- 'action:api.video-thread.created' |
- 'action:api.video-comment-reply.created' |
- 'action:api.video-comment.deleted'
+export type ServerActionHookName = keyof typeof serverActionHookObject
-export type ServerHookName = ServerFilterHookName | ServerActionHookName
+export const serverHookObject = Object.assign({}, serverFilterHookObject, serverActionHookObject)
+export type ServerHookName = keyof typeof serverHookObject
export interface ServerHook {
runHook <T> (hookName: ServerHookName, result?: T, params?: any): Promise<T>