X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-channel.ts;h=5598d80f615fe53f4ede030caf28b251ab55c42c;hb=88108880bbdba473cfe36ecbebc1c3c4f972e102;hp=e70e525153c0351bf40bfd7bc6f2ff89d2402132;hpb=c3c2ab1c8b52945df567c59118a7c77fdd6a1d4d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index e70e52515..5598d80f6 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -71,7 +71,7 @@ type AvailableForListOptions = { const inQueryInstanceFollow = '(' + 'SELECT "actor"."serverId" FROM "actorFollow" ' + 'INNER JOIN "actor" ON actor.id= "actorFollow"."targetActorId" ' + - 'WHERE "actor"."id" = ' + actorIdNumber + + 'WHERE "actorFollow"."actorId" = ' + actorIdNumber + ')' return { @@ -233,6 +233,27 @@ export class VideoChannelModel extends Model { }) } + static listLocalsForSitemap (sort: string) { + const query = { + attributes: [ ], + offset: 0, + order: getSort(sort), + include: [ + { + attributes: [ 'preferredUsername', 'serverId' ], + model: ActorModel.unscoped(), + where: { + serverId: null + } + } + ] + } + + return VideoChannelModel + .unscoped() + .findAll(query) + } + static searchForApi (options: { actorId: number search: string @@ -296,6 +317,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 +331,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 +392,7 @@ export class VideoChannelModel extends Model { ] } - return VideoChannelModel + return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) .findOne(query) } @@ -390,7 +417,7 @@ export class VideoChannelModel extends Model { ] } - return VideoChannelModel + return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) .findOne(query) } @@ -402,7 +429,7 @@ export class VideoChannelModel extends Model { ] } - return VideoChannelModel + return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEOS ]) .findById(id, options) } @@ -443,4 +470,8 @@ export class VideoChannelModel extends Model { getDisplayName () { return this.name } + + isOutdated () { + return this.Actor.isOutdated() + } }