import { AccountModel } from '../../models/account/account'
import { VideoPlaylistModel } from '../../models/video/video-playlist'
import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
+import { Hooks } from '@server/lib/plugins/hooks'
const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR })
logger.info('Video added in playlist %s at position %d.', videoPlaylist.uuid, playlistElement.position)
+ Hooks.runAction('action:api.video-playlist-element.created', { playlistElement })
+
return res.json({
videoPlaylistElement: {
id: playlistElement.id
'action:api.user.created',
'action:api.user.deleted',
'action:api.user.updated',
- 'action:api.user.oauth2-got-token'
+ 'action:api.user.oauth2-got-token',
+
+ 'action:api.video-playlist-element.created'
]
for (const h of actionHooks) {
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { ServerHookName, VideoPrivacy } from '@shared/models'
+import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
import {
addVideoCommentReply,
addVideoCommentThread,
+ addVideoInPlaylist,
blockUser,
createLive,
createUser,
+ createVideoPlaylist,
deleteVideoComment,
getPluginTestPath,
installPlugin,
})
describe('Videos hooks', function () {
+
it('Should run action:api.video.uploaded', async function () {
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' })
videoUUID = res.body.video.uuid
})
})
+ describe('Playlist hooks', function () {
+ let playlistId: number
+ let videoId: number
+
+ before(async function () {
+ {
+ const res = await createVideoPlaylist({
+ url: servers[0].url,
+ token: servers[0].accessToken,
+ playlistAttrs: {
+ displayName: 'My playlist',
+ privacy: VideoPlaylistPrivacy.PRIVATE
+ }
+ })
+ playlistId = res.body.videoPlaylist.id
+ }
+
+ {
+ const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'my super name' })
+ videoId = res.body.video.id
+ }
+ })
+
+ it('Should run action:api.video-playlist-element.created', async function () {
+ await addVideoInPlaylist({
+ url: servers[0].url,
+ token: servers[0].accessToken,
+ playlistId,
+ elementAttrs: { videoId }
+ })
+
+ await checkHook('action:api.video-playlist-element.created')
+ })
+ })
+
after(async function () {
await cleanupTests(servers)
})
'action:api.user.updated': true,
// Fired when a user got a new oauth2 token
- 'action:api.user.oauth2-got-token': true
+ 'action:api.user.oauth2-got-token': true,
+
+ // Fired when a video is added to a playlist
+ 'action:api.video-playlist-element.created': true
}
export type ServerActionHookName = keyof typeof serverActionHookObject