aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-20 10:22:05 +0200
committerChocobozzz <me@florianbigard.com>2019-08-20 10:22:05 +0200
commit96ca24f00e5ae5471dee9ee596489fe50af2b46f (patch)
tree64b7091518d802cc6e812bbe0787e11eeed2fcd5 /server
parent453e83ea5d81d203ba34bc43cd5c2c750ba40568 (diff)
downloadPeerTube-96ca24f00e5ae5471dee9ee596489fe50af2b46f.tar.gz
PeerTube-96ca24f00e5ae5471dee9ee596489fe50af2b46f.tar.zst
PeerTube-96ca24f00e5ae5471dee9ee596489fe50af2b46f.zip
Fix tests
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/videos/import.ts6
-rw-r--r--server/controllers/api/videos/index.ts4
-rw-r--r--server/lib/activitypub/videos.ts4
-rw-r--r--server/models/video/tag.ts9
4 files changed, 13 insertions, 10 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index adc2f9aa2..a058b37ef 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -28,6 +28,7 @@ import {
28 MChannelActorAccountDefault, 28 MChannelActorAccountDefault,
29 MThumbnail, 29 MThumbnail,
30 MUser, 30 MUser,
31 MVideoTag,
31 MVideoThumbnailAccountDefault, 32 MVideoThumbnailAccountDefault,
32 MVideoWithBlacklistLight 33 MVideoWithBlacklistLight
33} from '@server/typings/models' 34} from '@server/typings/models'
@@ -244,7 +245,7 @@ function insertIntoDB (parameters: {
244 const sequelizeOptions = { transaction: t } 245 const sequelizeOptions = { transaction: t }
245 246
246 // Save video object in database 247 // Save video object in database
247 const videoCreated = await video.save(sequelizeOptions) as (MVideoThumbnailAccountDefault & MVideoWithBlacklistLight) 248 const videoCreated = await video.save(sequelizeOptions) as (MVideoThumbnailAccountDefault & MVideoWithBlacklistLight & MVideoTag)
248 videoCreated.VideoChannel = videoChannel 249 videoCreated.VideoChannel = videoChannel
249 250
250 if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t) 251 if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t)
@@ -264,6 +265,9 @@ function insertIntoDB (parameters: {
264 const tagInstances = await TagModel.findOrCreateTags(tags, t) 265 const tagInstances = await TagModel.findOrCreateTags(tags, t)
265 266
266 await videoCreated.$set('Tags', tagInstances, sequelizeOptions) 267 await videoCreated.$set('Tags', tagInstances, sequelizeOptions)
268 videoCreated.Tags = tagInstances
269 } else {
270 videoCreated.Tags = []
267 } 271 }
268 272
269 // Create video import object in database 273 // Create video import object in database
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 9af71d276..b4f656575 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -63,7 +63,7 @@ import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../
63import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' 63import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type'
64import { VideoTranscodingPayload } from '../../../lib/job-queue/handlers/video-transcoding' 64import { VideoTranscodingPayload } from '../../../lib/job-queue/handlers/video-transcoding'
65import { Hooks } from '../../../lib/plugins/hooks' 65import { Hooks } from '../../../lib/plugins/hooks'
66import { MVideoFullLight } from '@server/typings/models' 66import { MVideoDetails, MVideoFullLight } from '@server/typings/models'
67 67
68const auditLogger = auditLoggerFactory('videos') 68const auditLogger = auditLoggerFactory('videos')
69const videosRouter = express.Router() 69const videosRouter = express.Router()
@@ -198,7 +198,7 @@ async function addVideo (req: express.Request, res: express.Response) {
198 originallyPublishedAt: videoInfo.originallyPublishedAt 198 originallyPublishedAt: videoInfo.originallyPublishedAt
199 } 199 }
200 200
201 const video = new VideoModel(videoData) 201 const video = new VideoModel(videoData) as MVideoDetails
202 video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object 202 video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object
203 203
204 const videoFile = new VideoFileModel({ 204 const videoFile = new VideoFileModel({
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index 5c10f9764..035994da8 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -65,9 +65,7 @@ import {
65 MVideoFile, 65 MVideoFile,
66 MVideoFullLight, 66 MVideoFullLight,
67 MVideoId, 67 MVideoId,
68 MVideoTag, 68 MVideoThumbnail
69 MVideoThumbnail,
70 MVideoWithAllFiles
71} from '../../typings/models' 69} from '../../typings/models'
72import { MThumbnail } from '../../typings/models/video/thumbnail' 70import { MThumbnail } from '../../typings/models/video/thumbnail'
73 71
diff --git a/server/models/video/tag.ts b/server/models/video/tag.ts
index 0fc3cfd4c..b110f2a43 100644
--- a/server/models/video/tag.ts
+++ b/server/models/video/tag.ts
@@ -6,6 +6,7 @@ import { throwIfNotValid } from '../utils'
6import { VideoModel } from './video' 6import { VideoModel } from './video'
7import { VideoTagModel } from './video-tag' 7import { VideoTagModel } from './video-tag'
8import { VideoPrivacy, VideoState } from '../../../shared/models/videos' 8import { VideoPrivacy, VideoState } from '../../../shared/models/videos'
9import { MTag } from '@server/typings/models'
9 10
10@Table({ 11@Table({
11 tableName: 'tag', 12 tableName: 'tag',
@@ -37,10 +38,10 @@ export class TagModel extends Model<TagModel> {
37 }) 38 })
38 Videos: VideoModel[] 39 Videos: VideoModel[]
39 40
40 static findOrCreateTags (tags: string[], transaction: Transaction) { 41 static findOrCreateTags (tags: string[], transaction: Transaction): Promise<MTag[]> {
41 if (tags === null) return [] 42 if (tags === null) return Promise.resolve([])
42 43
43 const tasks: Bluebird<TagModel>[] = [] 44 const tasks: Bluebird<MTag>[] = []
44 tags.forEach(tag => { 45 tags.forEach(tag => {
45 const query = { 46 const query = {
46 where: { 47 where: {
@@ -52,7 +53,7 @@ export class TagModel extends Model<TagModel> {
52 transaction 53 transaction
53 } 54 }
54 55
55 const promise = TagModel.findOrCreate(query) 56 const promise = TagModel.findOrCreate<MTag>(query)
56 .then(([ tagInstance ]) => tagInstance) 57 .then(([ tagInstance ]) => tagInstance)
57 tasks.push(promise) 58 tasks.push(promise)
58 }) 59 })