diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/activitypub/context.ts | 3 | ||||
-rw-r--r-- | server/lib/activitypub/videos/shared/creator.ts | 1 | ||||
-rw-r--r-- | server/lib/activitypub/videos/shared/object-to-model-attributes.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/videos/updater.ts | 4 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-live-ending.ts | 20 | ||||
-rw-r--r-- | server/lib/moderation.ts | 4 | ||||
-rw-r--r-- | server/lib/server-config-manager.ts | 5 | ||||
-rw-r--r-- | server/lib/thumbnail.ts | 25 | ||||
-rw-r--r-- | server/lib/video-blacklist.ts | 10 | ||||
-rw-r--r-- | server/lib/video-pre-import.ts | 1 |
10 files changed, 52 insertions, 25 deletions
diff --git a/server/lib/activitypub/context.ts b/server/lib/activitypub/context.ts index 750276a11..eba6d636d 100644 --- a/server/lib/activitypub/context.ts +++ b/server/lib/activitypub/context.ts | |||
@@ -60,6 +60,9 @@ const contextStore: { [ id in ContextType ]: (string | { [ id: string ]: string | |||
60 | }, | 60 | }, |
61 | 61 | ||
62 | originallyPublishedAt: 'sc:datePublished', | 62 | originallyPublishedAt: 'sc:datePublished', |
63 | |||
64 | uploadDate: 'sc:uploadDate', | ||
65 | |||
63 | views: { | 66 | views: { |
64 | '@type': 'sc:Number', | 67 | '@type': 'sc:Number', |
65 | '@id': 'pt:views' | 68 | '@id': 'pt:views' |
diff --git a/server/lib/activitypub/videos/shared/creator.ts b/server/lib/activitypub/videos/shared/creator.ts index bc139e4fa..512d14d82 100644 --- a/server/lib/activitypub/videos/shared/creator.ts +++ b/server/lib/activitypub/videos/shared/creator.ts | |||
@@ -49,6 +49,7 @@ export class APVideoCreator extends APVideoAbstractBuilder { | |||
49 | user: undefined, | 49 | user: undefined, |
50 | isRemote: true, | 50 | isRemote: true, |
51 | isNew: true, | 51 | isNew: true, |
52 | isNewFile: true, | ||
52 | transaction: t | 53 | transaction: t |
53 | }) | 54 | }) |
54 | 55 | ||
diff --git a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts index a9e0bed97..6cbe72e27 100644 --- a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts +++ b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts | |||
@@ -231,6 +231,10 @@ function getVideoAttributesFromObject (videoChannel: MChannelId, videoObject: Vi | |||
231 | ? new Date(videoObject.originallyPublishedAt) | 231 | ? new Date(videoObject.originallyPublishedAt) |
232 | : null, | 232 | : null, |
233 | 233 | ||
234 | inputFileUpdatedAt: videoObject.uploadDate | ||
235 | ? new Date(videoObject.uploadDate) | ||
236 | : null, | ||
237 | |||
234 | updatedAt: new Date(videoObject.updated), | 238 | updatedAt: new Date(videoObject.updated), |
235 | views: videoObject.views, | 239 | views: videoObject.views, |
236 | remote: true, | 240 | remote: true, |
diff --git a/server/lib/activitypub/videos/updater.ts b/server/lib/activitypub/videos/updater.ts index 522d7b043..acb087895 100644 --- a/server/lib/activitypub/videos/updater.ts +++ b/server/lib/activitypub/videos/updater.ts | |||
@@ -38,6 +38,8 @@ export class APVideoUpdater extends APVideoAbstractBuilder { | |||
38 | { videoObject: this.videoObject, ...this.lTags() } | 38 | { videoObject: this.videoObject, ...this.lTags() } |
39 | ) | 39 | ) |
40 | 40 | ||
41 | const oldInputFileUpdatedAt = this.video.inputFileUpdatedAt | ||
42 | |||
41 | try { | 43 | try { |
42 | const channelActor = await this.getOrCreateVideoChannelFromVideoObject() | 44 | const channelActor = await this.getOrCreateVideoChannelFromVideoObject() |
43 | 45 | ||
@@ -74,6 +76,7 @@ export class APVideoUpdater extends APVideoAbstractBuilder { | |||
74 | user: undefined, | 76 | user: undefined, |
75 | isRemote: true, | 77 | isRemote: true, |
76 | isNew: false, | 78 | isNew: false, |
79 | isNewFile: oldInputFileUpdatedAt !== videoUpdated.inputFileUpdatedAt, | ||
77 | transaction: undefined | 80 | transaction: undefined |
78 | }) | 81 | }) |
79 | 82 | ||
@@ -129,6 +132,7 @@ export class APVideoUpdater extends APVideoAbstractBuilder { | |||
129 | this.video.createdAt = videoData.createdAt | 132 | this.video.createdAt = videoData.createdAt |
130 | this.video.publishedAt = videoData.publishedAt | 133 | this.video.publishedAt = videoData.publishedAt |
131 | this.video.originallyPublishedAt = videoData.originallyPublishedAt | 134 | this.video.originallyPublishedAt = videoData.originallyPublishedAt |
135 | this.video.inputFileUpdatedAt = videoData.inputFileUpdatedAt | ||
132 | this.video.privacy = videoData.privacy | 136 | this.video.privacy = videoData.privacy |
133 | this.video.channelId = videoData.channelId | 137 | this.video.channelId = videoData.channelId |
134 | this.video.views = videoData.views | 138 | this.video.views = videoData.views |
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index ae886de35..982280b55 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts | |||
@@ -7,7 +7,7 @@ import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' | |||
7 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' | 7 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' |
8 | import { cleanupAndDestroyPermanentLive, cleanupTMPLiveFiles, cleanupUnsavedNormalLive } from '@server/lib/live' | 8 | import { cleanupAndDestroyPermanentLive, cleanupTMPLiveFiles, cleanupUnsavedNormalLive } from '@server/lib/live' |
9 | import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getLiveReplayBaseDirectory } from '@server/lib/paths' | 9 | import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getLiveReplayBaseDirectory } from '@server/lib/paths' |
10 | import { generateLocalVideoMiniature } from '@server/lib/thumbnail' | 10 | import { generateLocalVideoMiniature, regenerateMiniaturesIfNeeded } from '@server/lib/thumbnail' |
11 | import { generateHlsPlaylistResolutionFromTS } from '@server/lib/transcoding/hls-transcoding' | 11 | import { generateHlsPlaylistResolutionFromTS } from '@server/lib/transcoding/hls-transcoding' |
12 | import { VideoPathManager } from '@server/lib/video-path-manager' | 12 | import { VideoPathManager } from '@server/lib/video-path-manager' |
13 | import { moveToNextState } from '@server/lib/video-state' | 13 | import { moveToNextState } from '@server/lib/video-state' |
@@ -197,23 +197,7 @@ async function replaceLiveByReplay (options: { | |||
197 | } | 197 | } |
198 | 198 | ||
199 | // Regenerate the thumbnail & preview? | 199 | // Regenerate the thumbnail & preview? |
200 | if (videoWithFiles.getMiniature().automaticallyGenerated === true) { | 200 | await regenerateMiniaturesIfNeeded(videoWithFiles) |
201 | const miniature = await generateLocalVideoMiniature({ | ||
202 | video: videoWithFiles, | ||
203 | videoFile: videoWithFiles.getMaxQualityFile(), | ||
204 | type: ThumbnailType.MINIATURE | ||
205 | }) | ||
206 | await videoWithFiles.addAndSaveThumbnail(miniature) | ||
207 | } | ||
208 | |||
209 | if (videoWithFiles.getPreview().automaticallyGenerated === true) { | ||
210 | const preview = await generateLocalVideoMiniature({ | ||
211 | video: videoWithFiles, | ||
212 | videoFile: videoWithFiles.getMaxQualityFile(), | ||
213 | type: ThumbnailType.PREVIEW | ||
214 | }) | ||
215 | await videoWithFiles.addAndSaveThumbnail(preview) | ||
216 | } | ||
217 | 201 | ||
218 | // We consider this is a new video | 202 | // We consider this is a new video |
219 | await moveToNextState({ video: videoWithFiles, isNewVideo: true }) | 203 | await moveToNextState({ video: videoWithFiles, isNewVideo: true }) |
diff --git a/server/lib/moderation.ts b/server/lib/moderation.ts index dc5d8c83c..db8284872 100644 --- a/server/lib/moderation.ts +++ b/server/lib/moderation.ts | |||
@@ -36,7 +36,7 @@ export type AcceptResult = { | |||
36 | // --------------------------------------------------------------------------- | 36 | // --------------------------------------------------------------------------- |
37 | 37 | ||
38 | // Stub function that can be filtered by plugins | 38 | // Stub function that can be filtered by plugins |
39 | function isLocalVideoAccepted (object: { | 39 | function isLocalVideoFileAccepted (object: { |
40 | videoBody: VideoCreate | 40 | videoBody: VideoCreate |
41 | videoFile: VideoUploadFile | 41 | videoFile: VideoUploadFile |
42 | user: UserModel | 42 | user: UserModel |
@@ -201,7 +201,7 @@ function createAccountAbuse (options: { | |||
201 | export { | 201 | export { |
202 | isLocalLiveVideoAccepted, | 202 | isLocalLiveVideoAccepted, |
203 | 203 | ||
204 | isLocalVideoAccepted, | 204 | isLocalVideoFileAccepted, |
205 | isLocalVideoThreadAccepted, | 205 | isLocalVideoThreadAccepted, |
206 | isRemoteVideoCommentAccepted, | 206 | isRemoteVideoCommentAccepted, |
207 | isLocalVideoCommentReplyAccepted, | 207 | isLocalVideoCommentReplyAccepted, |
diff --git a/server/lib/server-config-manager.ts b/server/lib/server-config-manager.ts index 5ce89b16d..beb5d4d82 100644 --- a/server/lib/server-config-manager.ts +++ b/server/lib/server-config-manager.ts | |||
@@ -171,6 +171,11 @@ class ServerConfigManager { | |||
171 | enabled: CONFIG.VIDEO_STUDIO.REMOTE_RUNNERS.ENABLED | 171 | enabled: CONFIG.VIDEO_STUDIO.REMOTE_RUNNERS.ENABLED |
172 | } | 172 | } |
173 | }, | 173 | }, |
174 | videoFile: { | ||
175 | update: { | ||
176 | enabled: CONFIG.VIDEO_FILE.UPDATE.ENABLED | ||
177 | } | ||
178 | }, | ||
174 | import: { | 179 | import: { |
175 | videos: { | 180 | videos: { |
176 | http: { | 181 | http: { |
diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts index d95442795..0b98da14f 100644 --- a/server/lib/thumbnail.ts +++ b/server/lib/thumbnail.ts | |||
@@ -4,7 +4,7 @@ import { generateImageFilename, generateImageFromVideoFile } from '../helpers/im | |||
4 | import { CONFIG } from '../initializers/config' | 4 | import { CONFIG } from '../initializers/config' |
5 | import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants' | 5 | import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants' |
6 | import { ThumbnailModel } from '../models/video/thumbnail' | 6 | import { ThumbnailModel } from '../models/video/thumbnail' |
7 | import { MVideoFile, MVideoThumbnail, MVideoUUID } from '../types/models' | 7 | import { MVideoFile, MVideoThumbnail, MVideoUUID, MVideoWithAllFiles } from '../types/models' |
8 | import { MThumbnail } from '../types/models/video/thumbnail' | 8 | import { MThumbnail } from '../types/models/video/thumbnail' |
9 | import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist' | 9 | import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist' |
10 | import { VideoPathManager } from './video-path-manager' | 10 | import { VideoPathManager } from './video-path-manager' |
@@ -187,8 +187,31 @@ function updateRemoteVideoThumbnail (options: { | |||
187 | 187 | ||
188 | // --------------------------------------------------------------------------- | 188 | // --------------------------------------------------------------------------- |
189 | 189 | ||
190 | async function regenerateMiniaturesIfNeeded (video: MVideoWithAllFiles) { | ||
191 | if (video.getMiniature().automaticallyGenerated === true) { | ||
192 | const miniature = await generateLocalVideoMiniature({ | ||
193 | video, | ||
194 | videoFile: video.getMaxQualityFile(), | ||
195 | type: ThumbnailType.MINIATURE | ||
196 | }) | ||
197 | await video.addAndSaveThumbnail(miniature) | ||
198 | } | ||
199 | |||
200 | if (video.getPreview().automaticallyGenerated === true) { | ||
201 | const preview = await generateLocalVideoMiniature({ | ||
202 | video, | ||
203 | videoFile: video.getMaxQualityFile(), | ||
204 | type: ThumbnailType.PREVIEW | ||
205 | }) | ||
206 | await video.addAndSaveThumbnail(preview) | ||
207 | } | ||
208 | } | ||
209 | |||
210 | // --------------------------------------------------------------------------- | ||
211 | |||
190 | export { | 212 | export { |
191 | generateLocalVideoMiniature, | 213 | generateLocalVideoMiniature, |
214 | regenerateMiniaturesIfNeeded, | ||
192 | updateLocalVideoMiniatureFromUrl, | 215 | updateLocalVideoMiniatureFromUrl, |
193 | updateLocalVideoMiniatureFromExisting, | 216 | updateLocalVideoMiniatureFromExisting, |
194 | updateRemoteVideoThumbnail, | 217 | updateRemoteVideoThumbnail, |
diff --git a/server/lib/video-blacklist.ts b/server/lib/video-blacklist.ts index cb1ea834c..d5664a1b9 100644 --- a/server/lib/video-blacklist.ts +++ b/server/lib/video-blacklist.ts | |||
@@ -27,13 +27,14 @@ async function autoBlacklistVideoIfNeeded (parameters: { | |||
27 | user?: MUser | 27 | user?: MUser |
28 | isRemote: boolean | 28 | isRemote: boolean |
29 | isNew: boolean | 29 | isNew: boolean |
30 | isNewFile: boolean | ||
30 | notify?: boolean | 31 | notify?: boolean |
31 | transaction?: Transaction | 32 | transaction?: Transaction |
32 | }) { | 33 | }) { |
33 | const { video, user, isRemote, isNew, notify = true, transaction } = parameters | 34 | const { video, user, isRemote, isNew, isNewFile, notify = true, transaction } = parameters |
34 | const doAutoBlacklist = await Hooks.wrapFun( | 35 | const doAutoBlacklist = await Hooks.wrapFun( |
35 | autoBlacklistNeeded, | 36 | autoBlacklistNeeded, |
36 | { video, user, isRemote, isNew }, | 37 | { video, user, isRemote, isNew, isNewFile }, |
37 | 'filter:video.auto-blacklist.result' | 38 | 'filter:video.auto-blacklist.result' |
38 | ) | 39 | ) |
39 | 40 | ||
@@ -128,14 +129,15 @@ function autoBlacklistNeeded (parameters: { | |||
128 | video: MVideoWithBlacklistLight | 129 | video: MVideoWithBlacklistLight |
129 | isRemote: boolean | 130 | isRemote: boolean |
130 | isNew: boolean | 131 | isNew: boolean |
132 | isNewFile: boolean | ||
131 | user?: MUser | 133 | user?: MUser |
132 | }) { | 134 | }) { |
133 | const { user, video, isRemote, isNew } = parameters | 135 | const { user, video, isRemote, isNew, isNewFile } = parameters |
134 | 136 | ||
135 | // Already blacklisted | 137 | // Already blacklisted |
136 | if (video.VideoBlacklist) return false | 138 | if (video.VideoBlacklist) return false |
137 | if (!CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED || !user) return false | 139 | if (!CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED || !user) return false |
138 | if (isRemote || isNew === false) return false | 140 | if (isRemote || (isNew === false && isNewFile === false)) return false |
139 | 141 | ||
140 | if (user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) || user.hasAdminFlag(UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST)) return false | 142 | if (user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) || user.hasAdminFlag(UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST)) return false |
141 | 143 | ||
diff --git a/server/lib/video-pre-import.ts b/server/lib/video-pre-import.ts index 381f1f535..fcb9f77d7 100644 --- a/server/lib/video-pre-import.ts +++ b/server/lib/video-pre-import.ts | |||
@@ -89,6 +89,7 @@ async function insertFromImportIntoDB (parameters: { | |||
89 | notify: false, | 89 | notify: false, |
90 | isRemote: false, | 90 | isRemote: false, |
91 | isNew: true, | 91 | isNew: true, |
92 | isNewFile: true, | ||
92 | transaction: t | 93 | transaction: t |
93 | }) | 94 | }) |
94 | 95 | ||