From 5cf84858d49f4231cc4efec5e3132f17f65f6cf6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 4 Sep 2018 10:22:10 +0200 Subject: Add federation to ownership change --- server/models/video/video-change-ownership.ts | 12 ++++++++---- server/models/video/video-channel.ts | 16 +++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) (limited to 'server/models/video') 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 { { model: () => VideoModel, required: true, - include: [{ model: () => VideoFileModel }] + include: [ + { model: () => VideoFileModel } + ] } ] } @@ -94,15 +96,17 @@ export class VideoChangeOwnershipModel extends Model Video: VideoModel static listForApi (nextOwnerId: number, start: number, count: number, sort: string) { - return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findAndCountAll({ + const query = { offset: start, limit: count, order: getSort(sort), where: { nextOwnerAccountId: nextOwnerId } - }) - .then(({ rows, count }) => ({ total: count, data: rows })) + } + + return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findAndCountAll(query) + .then(({ rows, count }) => ({ total: count, data: rows })) } 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 { }) } + static loadByIdAndPopulateAccount (id: number) { + return VideoChannelModel.unscoped() + .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) + .findById(id) + } + static loadByIdAndAccount (id: number, accountId: number) { const query = { where: { @@ -304,13 +310,13 @@ export class VideoChannelModel extends Model { } } - return VideoChannelModel + return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) .findOne(query) } static loadAndPopulateAccount (id: number) { - return VideoChannelModel + return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) .findById(id) } @@ -365,7 +371,7 @@ export class VideoChannelModel extends Model { ] } - return VideoChannelModel + return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) .findOne(query) } @@ -390,7 +396,7 @@ export class VideoChannelModel extends Model { ] } - return VideoChannelModel + return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) .findOne(query) } @@ -402,7 +408,7 @@ export class VideoChannelModel extends Model { ] } - return VideoChannelModel + return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEOS ]) .findById(id, options) } -- cgit v1.2.3