X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Fmodels%2Faccount%2Faccount-video-rate.ts;h=d5c214ecbc69b1a9e82395404b88b5c680642aab;hb=970ceac0a6bf4990b8924738591df4949491ec9b;hp=85af9e3782c38535cab1ed01b53e2df1d7606031;hpb=bfbd912886eba17b4aa9a40dcef2fddc685d85bf;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts index 85af9e378..d5c214ecb 100644 --- a/server/models/account/account-video-rate.ts +++ b/server/models/account/account-video-rate.ts @@ -89,6 +89,25 @@ export class AccountVideoRateModel extends Model { return AccountVideoRateModel.findOne(options) } + static loadByAccountAndVideoOrUrl (accountId: number, videoId: number, url: string, transaction?: Transaction) { + const options: FindOptions = { + where: { + [ Op.or]: [ + { + accountId, + videoId + }, + { + url + } + ] + } + } + if (transaction) options.transaction = transaction + + return AccountVideoRateModel.findOne(options) + } + static listByAccountForApi (options: { start: number, count: number, @@ -202,6 +221,23 @@ export class AccountVideoRateModel extends Model { videoId, type }, + include: [ + { + model: AccountModel.unscoped(), + required: true, + include: [ + { + model: ActorModel.unscoped(), + required: true, + where: { + serverId: { + [Op.ne]: null + } + } + } + ] + } + ], transaction: t }