aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-import.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-01-19 14:58:16 +0100
committerChocobozzz <me@florianbigard.com>2022-01-19 14:58:16 +0100
commitd511df28906f84c7d25ecb24e41515ed549ff276 (patch)
treebc9caa33fae684e9971068011dd10243c7d0fe60 /server/models/video/video-import.ts
parent419b520ca4434d17f3505013174e195c3a316716 (diff)
downloadPeerTube-d511df28906f84c7d25ecb24e41515ed549ff276.tar.gz
PeerTube-d511df28906f84c7d25ecb24e41515ed549ff276.tar.zst
PeerTube-d511df28906f84c7d25ecb24e41515ed549ff276.zip
Add ability to filter my imports by target URL
Diffstat (limited to 'server/models/video/video-import.ts')
-rw-r--r--server/models/video/video-import.ts20
1 files changed, 16 insertions, 4 deletions
diff --git a/server/models/video/video-import.ts b/server/models/video/video-import.ts
index c5c1a10f4..5d2b230e8 100644
--- a/server/models/video/video-import.ts
+++ b/server/models/video/video-import.ts
@@ -1,3 +1,4 @@
1import { WhereOptions } from 'sequelize'
1import { 2import {
2 AfterUpdate, 3 AfterUpdate,
3 AllowNull, 4 AllowNull,
@@ -125,7 +126,20 @@ export class VideoImportModel extends Model<Partial<AttributesOnly<VideoImportMo
125 return VideoImportModel.findByPk(id) 126 return VideoImportModel.findByPk(id)
126 } 127 }
127 128
128 static listUserVideoImportsForApi (userId: number, start: number, count: number, sort: string) { 129 static listUserVideoImportsForApi (options: {
130 userId: number
131 start: number
132 count: number
133 sort: string
134
135 targetUrl?: string
136 }) {
137 const { userId, start, count, sort, targetUrl } = options
138
139 const where: WhereOptions = { userId }
140
141 if (targetUrl) where['targetUrl'] = targetUrl
142
129 const query = { 143 const query = {
130 distinct: true, 144 distinct: true,
131 include: [ 145 include: [
@@ -138,9 +152,7 @@ export class VideoImportModel extends Model<Partial<AttributesOnly<VideoImportMo
138 offset: start, 152 offset: start,
139 limit: count, 153 limit: count,
140 order: getSort(sort), 154 order: getSort(sort),
141 where: { 155 where
142 userId
143 }
144 } 156 }
145 157
146 return VideoImportModel.findAndCountAll<MVideoImportDefault>(query) 158 return VideoImportModel.findAndCountAll<MVideoImportDefault>(query)