1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Merge branch 'release/7.2.0' into develop

This commit is contained in:
Chocobozzz 2025-07-22 11:01:12 +02:00
commit eadbf4e001
No known key found for this signature in database
GPG key ID: 583A612D890159BE
7 changed files with 92 additions and 29 deletions

View file

@ -208,18 +208,44 @@ export class VideoImportModel extends SequelizeModel<VideoImportModel> {
]).then(([ total, data ]) => ({ total, data }))
}
static async urlAlreadyImported (channelId: number, targetUrl: string): Promise<boolean> {
const element = await VideoImportModel.unscoped().findOne({
where: {
targetUrl,
state: {
[Op.in]: [ VideoImportState.PENDING, VideoImportState.PROCESSING, VideoImportState.SUCCESS ]
},
videoChannelSyncId: channelId
static async urlAlreadyImported (options: {
targetUrl: string
channelId: number
channelSyncId?: number
}): Promise<boolean> {
const { channelSyncId, channelId, targetUrl } = options
const baseWhere = {
targetUrl,
state: {
[Op.in]: [ VideoImportState.PENDING, VideoImportState.PROCESSING, VideoImportState.SUCCESS ]
}
}
const bySyncId = channelSyncId
? VideoImportModel.unscoped().findOne({
where: {
...baseWhere,
videoChannelSyncId: channelSyncId
}
})
: Promise.resolve(undefined)
const byChannelId = VideoImportModel.unscoped().findOne({
where: baseWhere,
include: [
{
model: VideoModel.unscoped(),
required: true,
where: {
channelId
}
}
]
})
return !!element
return (await Promise.all([ bySyncId, byChannelId ])).some(e => !!e)
}
getTargetIdentifier () {