From 2ccaeeb341ffe8c2609039bf4c6d8835b4650316 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 10 Jan 2018 17:18:12 +0100 Subject: Fetch remote AP objects --- server/models/video/video.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'server/models/video/video.ts') diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 918892938..6b825bf93 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -178,6 +178,10 @@ enum ScopeNames { }, { fields: [ 'id', 'privacy' ] + }, + { + fields: [ 'url'], + unique: true } ] }) @@ -535,7 +539,7 @@ export class VideoModel extends Model { return VideoModel.scope([ ScopeNames.WITH_ACCOUNT_DETAILS, ScopeNames.WITH_FILES ]).findOne(query) } - static loadByUUIDOrURL (uuid: string, url: string, t?: Sequelize.Transaction) { + static loadByUUIDOrURLAndPopulateAccount (uuid: string, url: string, t?: Sequelize.Transaction) { const query: IFindOptions = { where: { [Sequelize.Op.or]: [ @@ -547,7 +551,7 @@ export class VideoModel extends Model { if (t !== undefined) query.transaction = t - return VideoModel.scope(ScopeNames.WITH_FILES).findOne(query) + return VideoModel.scope([ ScopeNames.WITH_ACCOUNT_DETAILS, ScopeNames.WITH_FILES ]).findOne(query) } static loadAndPopulateAccountAndServerAndTags (id: number) { @@ -983,6 +987,10 @@ export class VideoModel extends Model { { type: 'Group', id: this.VideoChannel.Actor.url + }, + { + type: 'Person', + id: this.VideoChannel.Account.Actor.url } ] } -- cgit v1.2.3