From 7663e55a2cc46a413bceee2787d48902b15ae642 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 22 Jul 2019 16:31:47 +0200 Subject: Log error on unknown hook --- shared/models/plugins/client-hook.model.ts | 58 +++++++++++++++++------------- shared/models/plugins/server-hook.model.ts | 51 ++++++++++++++------------ 2 files changed, 63 insertions(+), 46 deletions(-) (limited to 'shared/models') diff --git a/shared/models/plugins/client-hook.model.ts b/shared/models/plugins/client-hook.model.ts index 89400003e..bf444fe5a 100644 --- a/shared/models/plugins/client-hook.model.ts +++ b/shared/models/plugins/client-hook.model.ts @@ -1,38 +1,48 @@ -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 (hookName: ClientHookName, result?: T, params?: any): Promise diff --git a/shared/models/plugins/server-hook.model.ts b/shared/models/plugins/server-hook.model.ts index 6729e2dab..f53e0ce59 100644 --- a/shared/models/plugins/server-hook.model.ts +++ b/shared/models/plugins/server-hook.model.ts @@ -1,33 +1,40 @@ -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 (hookName: ServerHookName, result?: T, params?: any): Promise -- cgit v1.2.3