X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo.ts;h=0c5ed64ec0e4c67c0cdc494a4a9f52a8bdaebf83;hb=05a60d85997c108d39bcfb14f1ffd4c74f8b1e93;hp=f3907bed46dab70ee20d1790bc9a01028d7a433b;hpb=11ae7e2917ddf6e3c8e53d0855fd786163112d59;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video.ts b/server/models/video/video.ts index f3907bed4..0c5ed64ec 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -32,9 +32,9 @@ import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFil import { VideoPathManager } from '@server/lib/video-path-manager' import { isVideoInPrivateDirectory } from '@server/lib/video-privacy' import { getServerActor } from '@server/models/application/application' -import { ModelCache } from '@server/models/model-cache' +import { ModelCache } from '@server/models/shared/model-cache' import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils' -import { ffprobePromise, getAudioStream, uuidToShort } from '@shared/extra-utils' +import { ffprobePromise, getAudioStream, hasAudioStream, uuidToShort } from '@shared/extra-utils' import { ResultList, ThumbnailType, @@ -103,10 +103,9 @@ import { VideoRedundancyModel } from '../redundancy/video-redundancy' import { ServerModel } from '../server/server' import { TrackerModel } from '../server/tracker' import { VideoTrackerModel } from '../server/video-tracker' -import { setAsUpdated } from '../shared' +import { buildTrigramSearchIndex, buildWhereIdOrUUID, getVideoSort, isOutdated, setAsUpdated, throwIfNotValid } from '../shared' import { UserModel } from '../user/user' import { UserVideoHistoryModel } from '../user/user-video-history' -import { buildTrigramSearchIndex, buildWhereIdOrUUID, getVideoSort, isOutdated, throwIfNotValid } from '../utils' import { VideoViewModel } from '../view/video-view' import { videoFilesModelToFormattedJSON, @@ -138,6 +137,7 @@ import { VideoShareModel } from './video-share' import { VideoSourceModel } from './video-source' import { VideoStreamingPlaylistModel } from './video-streaming-playlist' import { VideoTagModel } from './video-tag' +import { Hooks } from '@server/lib/plugins/hooks' export enum ScopeNames { FOR_API = 'FOR_API', @@ -706,6 +706,7 @@ export class VideoModel extends Model>> { name: 'videoId', allowNull: false }, + hooks: true, onDelete: 'cascade' }) VideoLive: VideoLiveModel @@ -1714,8 +1715,12 @@ export class VideoModel extends Model>> { return files } - toActivityPubObject (this: MVideoAP): VideoObject { - return videoModelToActivityPubObject(this) + toActivityPubObject (this: MVideoAP): Promise { + return Hooks.wrapObject( + videoModelToActivityPubObject(this), + 'filter:activity-pub.video.json-ld.build.result', + { video: this } + ) } getTruncatedDescription () { @@ -1751,9 +1756,11 @@ export class VideoModel extends Model>> { const probe = await ffprobePromise(originalFilePath) const { audioStream } = await getAudioStream(originalFilePath, probe) + const hasAudio = await hasAudioStream(originalFilePath, probe) return { audioStream, + hasAudio, ...await getVideoStreamDimensionsInfo(originalFilePath, probe) } @@ -1869,7 +1876,7 @@ export class VideoModel extends Model>> { } setAsRefreshed (transaction?: Transaction) { - return setAsUpdated('video', this.id, transaction) + return setAsUpdated({ sequelize: this.sequelize, table: 'video', id: this.id, transaction }) } // ---------------------------------------------------------------------------