MChannelActorAccountDefault,
MThumbnail,
MUser,
+ MVideoTag,
MVideoThumbnailAccountDefault,
MVideoWithBlacklistLight
} from '@server/typings/models'
const sequelizeOptions = { transaction: t }
// Save video object in database
- const videoCreated = await video.save(sequelizeOptions) as (MVideoThumbnailAccountDefault & MVideoWithBlacklistLight)
+ const videoCreated = await video.save(sequelizeOptions) as (MVideoThumbnailAccountDefault & MVideoWithBlacklistLight & MVideoTag)
videoCreated.VideoChannel = videoChannel
if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t)
const tagInstances = await TagModel.findOrCreateTags(tags, t)
await videoCreated.$set('Tags', tagInstances, sequelizeOptions)
+ videoCreated.Tags = tagInstances
+ } else {
+ videoCreated.Tags = []
}
// Create video import object in database
import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type'
import { VideoTranscodingPayload } from '../../../lib/job-queue/handlers/video-transcoding'
import { Hooks } from '../../../lib/plugins/hooks'
-import { MVideoFullLight } from '@server/typings/models'
+import { MVideoDetails, MVideoFullLight } from '@server/typings/models'
const auditLogger = auditLoggerFactory('videos')
const videosRouter = express.Router()
originallyPublishedAt: videoInfo.originallyPublishedAt
}
- const video = new VideoModel(videoData)
+ const video = new VideoModel(videoData) as MVideoDetails
video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object
const videoFile = new VideoFileModel({
MVideoFile,
MVideoFullLight,
MVideoId,
- MVideoTag,
- MVideoThumbnail,
- MVideoWithAllFiles
+ MVideoThumbnail
} from '../../typings/models'
import { MThumbnail } from '../../typings/models/video/thumbnail'
import { VideoModel } from './video'
import { VideoTagModel } from './video-tag'
import { VideoPrivacy, VideoState } from '../../../shared/models/videos'
+import { MTag } from '@server/typings/models'
@Table({
tableName: 'tag',
})
Videos: VideoModel[]
- static findOrCreateTags (tags: string[], transaction: Transaction) {
- if (tags === null) return []
+ static findOrCreateTags (tags: string[], transaction: Transaction): Promise<MTag[]> {
+ if (tags === null) return Promise.resolve([])
- const tasks: Bluebird<TagModel>[] = []
+ const tasks: Bluebird<MTag>[] = []
tags.forEach(tag => {
const query = {
where: {
transaction
}
- const promise = TagModel.findOrCreate(query)
+ const promise = TagModel.findOrCreate<MTag>(query)
.then(([ tagInstance ]) => tagInstance)
tasks.push(promise)
})