mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-11-10 12:26:35 +03:00
Better isNewVideo variable/functions name
This commit is contained in:
parent
bd1dd8fd95
commit
af8a47125f
@ -269,7 +269,7 @@ export type NotifyPayload =
|
||||
|
||||
export interface FederateVideoPayload {
|
||||
videoUUID: string
|
||||
isNewVideo: boolean
|
||||
isNewVideoForFederation: boolean
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -165,7 +165,7 @@ async function addVideoJobsAfterUpload (video: MVideoFullLight, videoFile: MVide
|
||||
type: 'federate-video' as 'federate-video',
|
||||
payload: {
|
||||
videoUUID: video.uuid,
|
||||
isNewVideo: false
|
||||
isNewVideoForFederation: false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -64,7 +64,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
|
||||
const videoFileLockReleaser = await VideoPathManager.Instance.lockFiles(videoFromReq.uuid)
|
||||
|
||||
try {
|
||||
const { videoInstanceUpdated, isNewVideo } = await sequelizeTypescript.transaction(async t => {
|
||||
const { videoInstanceUpdated, isNewVideoForFederation } = await sequelizeTypescript.transaction(async t => {
|
||||
// Refresh video since thumbnails to prevent concurrent updates
|
||||
const video = await VideoModel.loadFull(videoFromReq.id, t)
|
||||
|
||||
@ -95,9 +95,15 @@ async function updateVideo (req: express.Request, res: express.Response) {
|
||||
}
|
||||
|
||||
// Privacy update?
|
||||
let isNewVideo = false
|
||||
let isNewVideoForFederation = false
|
||||
|
||||
if (videoInfoToUpdate.privacy !== undefined) {
|
||||
isNewVideo = await updateVideoPrivacy({ videoInstance: video, videoInfoToUpdate, hadPrivacyForFederation, transaction: t })
|
||||
isNewVideoForFederation = await updateVideoPrivacy({
|
||||
videoInstance: video,
|
||||
videoInfoToUpdate,
|
||||
hadPrivacyForFederation,
|
||||
transaction: t
|
||||
})
|
||||
}
|
||||
|
||||
// Force updatedAt attribute change
|
||||
@ -154,7 +160,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
|
||||
)
|
||||
logger.info('Video with name %s and uuid %s updated.', video.name, video.uuid, lTags(video.uuid))
|
||||
|
||||
return { videoInstanceUpdated, isNewVideo }
|
||||
return { videoInstanceUpdated, isNewVideoForFederation }
|
||||
})
|
||||
|
||||
Hooks.runAction('action:api.video.updated', { video: videoInstanceUpdated, body: req.body, req, res })
|
||||
@ -163,7 +169,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
|
||||
video: videoInstanceUpdated,
|
||||
nameChanged: !!videoInfoToUpdate.name,
|
||||
oldPrivacy,
|
||||
isNewVideo
|
||||
isNewVideoForFederation
|
||||
})
|
||||
} catch (err) {
|
||||
// If the transaction is retried, sequelize will think the object has not changed
|
||||
@ -180,6 +186,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
|
||||
.end()
|
||||
}
|
||||
|
||||
// Return a boolean indicating if the video is considered as "new" for remote instances in the federation
|
||||
async function updateVideoPrivacy (options: {
|
||||
videoInstance: MVideoFullLight
|
||||
videoInfoToUpdate: VideoUpdate
|
||||
@ -187,7 +194,7 @@ async function updateVideoPrivacy (options: {
|
||||
transaction: Transaction
|
||||
}) {
|
||||
const { videoInstance, videoInfoToUpdate, hadPrivacyForFederation, transaction } = options
|
||||
const isNewVideo = videoInstance.isNewVideo(videoInfoToUpdate.privacy)
|
||||
const isNewVideoForFederation = videoInstance.isNewVideoForFederation(videoInfoToUpdate.privacy)
|
||||
|
||||
const newPrivacy = forceNumber(videoInfoToUpdate.privacy) as VideoPrivacyType
|
||||
setVideoPrivacy(videoInstance, newPrivacy)
|
||||
@ -207,7 +214,7 @@ async function updateVideoPrivacy (options: {
|
||||
await VideoModel.sendDelete(videoInstance, { transaction })
|
||||
}
|
||||
|
||||
return isNewVideo
|
||||
return isNewVideoForFederation
|
||||
}
|
||||
|
||||
function updateSchedule (videoInstance: MVideoFullLight, videoInfoToUpdate: VideoUpdate, transaction: Transaction) {
|
||||
|
@ -269,7 +269,7 @@ async function addVideoJobsAfterUpload (video: MVideoFullLight, videoFile: MVide
|
||||
type: 'federate-video' as 'federate-video',
|
||||
payload: {
|
||||
videoUUID: video.uuid,
|
||||
isNewVideo: true
|
||||
isNewVideoForFederation: true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -16,7 +16,7 @@ function processFederateVideo (job: Job) {
|
||||
const video = await VideoModel.loadFull(payload.videoUUID, t)
|
||||
if (!video) return
|
||||
|
||||
return federateVideoIfNeeded(video, payload.isNewVideo, t)
|
||||
return federateVideoIfNeeded(video, payload.isNewVideoForFederation, t)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ export class UpdateVideosScheduler extends AbstractScheduler {
|
||||
logger.info('Executing scheduled video update on %s.', video.uuid)
|
||||
|
||||
if (schedule.privacy) {
|
||||
isNewVideo = video.isNewVideo(schedule.privacy)
|
||||
isNewVideo = video.isNewVideoForFederation(schedule.privacy)
|
||||
oldPrivacy = video.privacy
|
||||
|
||||
setVideoPrivacy(video, schedule.privacy)
|
||||
|
@ -118,7 +118,7 @@ export async function onVideoStudioEnded (options: {
|
||||
type: 'federate-video' as 'federate-video',
|
||||
payload: {
|
||||
videoUUID: video.uuid,
|
||||
isNewVideo: false
|
||||
isNewVideoForFederation: false
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -137,12 +137,12 @@ export const getCachedVideoDuration = memoizee(getVideoDuration, {
|
||||
|
||||
export async function addVideoJobsAfterUpdate (options: {
|
||||
video: MVideoFullLight
|
||||
isNewVideo: boolean
|
||||
isNewVideoForFederation: boolean
|
||||
|
||||
nameChanged: boolean
|
||||
oldPrivacy: VideoPrivacyType
|
||||
}) {
|
||||
const { video, nameChanged, oldPrivacy, isNewVideo } = options
|
||||
const { video, nameChanged, oldPrivacy, isNewVideoForFederation } = options
|
||||
const jobs: CreateJobArgument[] = []
|
||||
|
||||
const filePathChanged = await moveFilesIfPrivacyChanged(video, oldPrivacy)
|
||||
@ -167,7 +167,7 @@ export async function addVideoJobsAfterUpdate (options: {
|
||||
type: 'federate-video',
|
||||
payload: {
|
||||
videoUUID: video.uuid,
|
||||
isNewVideo
|
||||
isNewVideoForFederation
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -2004,7 +2004,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
||||
return isStateForFederation(this.state)
|
||||
}
|
||||
|
||||
isNewVideo (newPrivacy: VideoPrivacyType) {
|
||||
isNewVideoForFederation (newPrivacy: VideoPrivacyType) {
|
||||
return this.hasPrivacyForFederation() === false && isPrivacyForFederation(newPrivacy) === true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user