X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo.ts;h=1a10d2da229ec59d4d8484fc582cea90dbbc07e3;hb=32fde390f465b9ceef9e49c4037acdacbe176d65;hp=2ff92cbf1679dc47bffcb805aab5422c009d1f2e;hpb=aa887096f9a305568dc3a846d0c9cdf7e45f1c67;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 2ff92cbf1..1a10d2da2 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, @@ -1458,6 +1457,12 @@ export class VideoModel extends Model>> { const query = 'SELECT 1 FROM "videoShare" ' + 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "videoShare"."actorId" ' + 'WHERE "actorFollow"."actorId" = $followerActorId AND "actorFollow"."state" = \'accepted\' AND "videoShare"."videoId" = $videoId ' + + 'UNION ' + + 'SELECT 1 FROM "video" ' + + 'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' + + 'INNER JOIN "account" ON "account"."id" = "videoChannel"."accountId" ' + + 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "account"."actorId" ' + + 'WHERE "actorFollow"."actorId" = $followerActorId AND "actorFollow"."state" = \'accepted\' AND "video"."id" = $videoId ' + 'LIMIT 1' const options = { @@ -1745,9 +1750,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) } @@ -1863,7 +1870,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 }) } // ---------------------------------------------------------------------------