X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fvideo-playlist.ts;h=2f81cf43c1d59bd013ad59f1ca94bc5c3ddf1cde;hb=5cf027bdc46f1bf214c4cf26eee17ebda228004f;hp=c25aed20b4e530bcf20570ec8926d598597722b9;hpb=37a44fc915eef2140e22ceb96aba6b6eb2509007;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index c25aed20b..2f81cf43c 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts @@ -1,9 +1,12 @@ -import * as express from 'express' +import express from 'express' import { join } from 'path' +import { uuidToShort } from '@server/helpers/uuid' import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists' +import { Hooks } from '@server/lib/plugins/hooks' import { getServerActor } from '@server/models/application/application' import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models' +import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model' import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model' import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' @@ -198,8 +201,9 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) { return res.json({ videoPlaylist: { id: videoPlaylistCreated.id, + shortUUID: uuidToShort(videoPlaylistCreated.uuid), uuid: videoPlaylistCreated.uuid - } + } as VideoPlaylistCreateResult }) } @@ -330,11 +334,13 @@ async function addVideoInPlaylist (req: express.Request, res: express.Response) 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 - } - }).end() + } as VideoPlaylistElementCreateResult + }) } async function updateVideoPlaylistElement (req: express.Request, res: express.Response) {