aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-04 10:22:10 +0200
committerChocobozzz <me@florianbigard.com>2018-09-04 10:49:53 +0200
commit5cf84858d49f4231cc4efec5e3132f17f65f6cf6 (patch)
treef1ff23476ff54c32c3fa34db79c11f242855d3b4 /server/models/video
parent0b74c74abe5a44e9f564ab6adb5177ab17d28e91 (diff)
downloadPeerTube-5cf84858d49f4231cc4efec5e3132f17f65f6cf6.tar.gz
PeerTube-5cf84858d49f4231cc4efec5e3132f17f65f6cf6.tar.zst
PeerTube-5cf84858d49f4231cc4efec5e3132f17f65f6cf6.zip
Add federation to ownership change
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video-change-ownership.ts12
-rw-r--r--server/models/video/video-channel.ts16
2 files changed, 19 insertions, 9 deletions
diff --git a/server/models/video/video-change-ownership.ts b/server/models/video/video-change-ownership.ts
index c9cff5054..48c07728f 100644
--- a/server/models/video/video-change-ownership.ts
+++ b/server/models/video/video-change-ownership.ts
@@ -39,7 +39,9 @@ enum ScopeNames {
39 { 39 {
40 model: () => VideoModel, 40 model: () => VideoModel,
41 required: true, 41 required: true,
42 include: [{ model: () => VideoFileModel }] 42 include: [
43 { model: () => VideoFileModel }
44 ]
43 } 45 }
44 ] 46 ]
45 } 47 }
@@ -94,15 +96,17 @@ export class VideoChangeOwnershipModel extends Model<VideoChangeOwnershipModel>
94 Video: VideoModel 96 Video: VideoModel
95 97
96 static listForApi (nextOwnerId: number, start: number, count: number, sort: string) { 98 static listForApi (nextOwnerId: number, start: number, count: number, sort: string) {
97 return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findAndCountAll({ 99 const query = {
98 offset: start, 100 offset: start,
99 limit: count, 101 limit: count,
100 order: getSort(sort), 102 order: getSort(sort),
101 where: { 103 where: {
102 nextOwnerAccountId: nextOwnerId 104 nextOwnerAccountId: nextOwnerId
103 } 105 }
104 }) 106 }
105 .then(({ rows, count }) => ({ total: count, data: rows })) 107
108 return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findAndCountAll(query)
109 .then(({ rows, count }) => ({ total: count, data: rows }))
106 } 110 }
107 111
108 static load (id: number) { 112 static load (id: number) {
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index 475530daf..f4586917e 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -296,6 +296,12 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
296 }) 296 })
297 } 297 }
298 298
299 static loadByIdAndPopulateAccount (id: number) {
300 return VideoChannelModel.unscoped()
301 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
302 .findById(id)
303 }
304
299 static loadByIdAndAccount (id: number, accountId: number) { 305 static loadByIdAndAccount (id: number, accountId: number) {
300 const query = { 306 const query = {
301 where: { 307 where: {
@@ -304,13 +310,13 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
304 } 310 }
305 } 311 }
306 312
307 return VideoChannelModel 313 return VideoChannelModel.unscoped()
308 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) 314 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
309 .findOne(query) 315 .findOne(query)
310 } 316 }
311 317
312 static loadAndPopulateAccount (id: number) { 318 static loadAndPopulateAccount (id: number) {
313 return VideoChannelModel 319 return VideoChannelModel.unscoped()
314 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) 320 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
315 .findById(id) 321 .findById(id)
316 } 322 }
@@ -365,7 +371,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
365 ] 371 ]
366 } 372 }
367 373
368 return VideoChannelModel 374 return VideoChannelModel.unscoped()
369 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) 375 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
370 .findOne(query) 376 .findOne(query)
371 } 377 }
@@ -390,7 +396,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
390 ] 396 ]
391 } 397 }
392 398
393 return VideoChannelModel 399 return VideoChannelModel.unscoped()
394 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) 400 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
395 .findOne(query) 401 .findOne(query)
396 } 402 }
@@ -402,7 +408,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
402 ] 408 ]
403 } 409 }
404 410
405 return VideoChannelModel 411 return VideoChannelModel.unscoped()
406 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEOS ]) 412 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEOS ])
407 .findById(id, options) 413 .findById(id, options)
408 } 414 }