diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-22 15:40:13 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | 93cae47925e4dd68b7d34a41927b2740b4fab1b4 (patch) | |
tree | f649ab49fab1886b434e164591990cc99b234466 /shared/models | |
parent | 587568e1cc0e33c023c1ac62dd28fef313285250 (diff) | |
download | PeerTube-93cae47925e4dd68b7d34a41927b2740b4fab1b4.tar.gz PeerTube-93cae47925e4dd68b7d34a41927b2740b4fab1b4.tar.zst PeerTube-93cae47925e4dd68b7d34a41927b2740b4fab1b4.zip |
Add client hooks
Diffstat (limited to 'shared/models')
-rw-r--r-- | shared/models/plugins/client-hook.model.ts | 39 | ||||
-rw-r--r-- | shared/models/plugins/plugin-client-scope.type.ts | 1 | ||||
-rw-r--r-- | shared/models/plugins/plugin-scope.type.ts | 1 | ||||
-rw-r--r-- | shared/models/plugins/server-hook.model.ts | 2 | ||||
-rw-r--r-- | shared/models/server/server-config.model.ts | 3 |
5 files changed, 43 insertions, 3 deletions
diff --git a/shared/models/plugins/client-hook.model.ts b/shared/models/plugins/client-hook.model.ts new file mode 100644 index 000000000..89400003e --- /dev/null +++ b/shared/models/plugins/client-hook.model.ts | |||
@@ -0,0 +1,39 @@ | |||
1 | export type ClientFilterHookName = | ||
2 | 'filter:api.videos.list.trending.params' | | ||
3 | 'filter:api.videos.list.trending.result' | | ||
4 | |||
5 | 'filter:api.videos.list.local.params' | | ||
6 | 'filter:api.videos.list.local.result' | | ||
7 | |||
8 | 'filter:api.videos.list.recently-added.params' | | ||
9 | 'filter:api.videos.list.recently-added.result' | | ||
10 | |||
11 | 'filter:api.videos.list.user-subscriptions.params' | | ||
12 | 'filter:api.videos.list.user-subscriptions.result' | | ||
13 | |||
14 | 'filter:api.video-watch.video.get.params' | | ||
15 | 'filter:api.video-watch.video.get.result' | | ||
16 | |||
17 | 'filter:api.video-watch.video-threads.list.params' | | ||
18 | 'filter:api.video-watch.video-threads.list.result' | | ||
19 | |||
20 | 'filter:api.video-watch.video-thread-replies.list.params' | | ||
21 | 'filter:api.video-watch.video-thread-replies.list.result' | | ||
22 | |||
23 | 'filter:api.search.videos.list.params' | | ||
24 | 'filter:api.search.videos.list.result' | | ||
25 | 'filter:api.search.video-channels.list.params' | | ||
26 | 'filter:api.search.video-channels.list.result' | ||
27 | |||
28 | export type ClientActionHookName = | ||
29 | 'action:application.init' | | ||
30 | |||
31 | 'action:video-watch.init' | | ||
32 | |||
33 | 'action:video-watch.video.loaded' | ||
34 | |||
35 | export type ClientHookName = ClientActionHookName | ClientFilterHookName | ||
36 | |||
37 | export interface ClientHook { | ||
38 | runHook <T> (hookName: ClientHookName, result?: T, params?: any): Promise<T> | ||
39 | } | ||
diff --git a/shared/models/plugins/plugin-client-scope.type.ts b/shared/models/plugins/plugin-client-scope.type.ts new file mode 100644 index 000000000..a2112eed7 --- /dev/null +++ b/shared/models/plugins/plugin-client-scope.type.ts | |||
@@ -0,0 +1 @@ | |||
export type PluginClientScope = 'common' | 'video-watch' | |||
diff --git a/shared/models/plugins/plugin-scope.type.ts b/shared/models/plugins/plugin-scope.type.ts deleted file mode 100644 index b63ae43ec..000000000 --- a/shared/models/plugins/plugin-scope.type.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | export type PluginScope = 'common' | 'video-watch' | ||
diff --git a/shared/models/plugins/server-hook.model.ts b/shared/models/plugins/server-hook.model.ts index a7f88f3c4..6729e2dab 100644 --- a/shared/models/plugins/server-hook.model.ts +++ b/shared/models/plugins/server-hook.model.ts | |||
@@ -30,5 +30,5 @@ export type ServerActionHookName = | |||
30 | export type ServerHookName = ServerFilterHookName | ServerActionHookName | 30 | export type ServerHookName = ServerFilterHookName | ServerActionHookName |
31 | 31 | ||
32 | export interface ServerHook { | 32 | export interface ServerHook { |
33 | runHook (hookName: ServerHookName, params?: any) | 33 | runHook <T> (hookName: ServerHookName, result?: T, params?: any): Promise<T> |
34 | } | 34 | } |
diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts index 3498f86d7..49bb01708 100644 --- a/shared/models/server/server-config.model.ts +++ b/shared/models/server/server-config.model.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import { NSFWPolicyType } from '../videos/nsfw-policy.type' | 1 | import { NSFWPolicyType } from '../videos/nsfw-policy.type' |
2 | import { ClientScript } from '../plugins/plugin-package-json.model' | 2 | import { ClientScript } from '../plugins/plugin-package-json.model' |
3 | import { PluginClientScope } from '../plugins/plugin-scope.type' | ||
3 | 4 | ||
4 | export interface ServerConfigPlugin { | 5 | export interface ServerConfigPlugin { |
5 | name: string | 6 | name: string |
6 | version: string | 7 | version: string |
7 | description: string | 8 | description: string |
8 | clientScripts: { [name: string]: ClientScript } | 9 | clientScripts: { [name in PluginClientScope]: ClientScript } |
9 | } | 10 | } |
10 | 11 | ||
11 | export interface ServerConfigTheme extends ServerConfigPlugin { | 12 | export interface ServerConfigTheme extends ServerConfigPlugin { |