-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
44 lines (36 loc) · 917 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
async function register ({
registerHook,
registerSetting,
settingsManager,
storageManager,
videoCategoryManager,
videoLicenceManager,
videoLanguageManager
peertubeHelpers
}) {
const fieldName = 'hello-world-field'
registerHook({
target: 'action:api.video.updated',
handler: ({ video, body }) => {
if (!body.pluginData) return
storageManager.storeData(fieldName + '-' + video.id, body.pluginData[fieldName])
}
})
registerHook({
target: 'filter:api.video.get.result',
handler: async (video) => {
if (!video) return video
if (!video.pluginData) video.pluginData = {}
const result = await storageManager.getData(fieldName + '-' + video.id)
video.pluginData[fieldName] = result
return video
}
})
}
async function unregister () {
return
}
module.exports = {
register,
unregister
}