X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-share.ts;h=fa9a70d509b42fccb99a59e8a10b9139a91f8b15;hb=5cf84858d49f4231cc4efec5e3132f17f65f6cf6;hp=6f770957faab736814a94baba94ed0e92a8d19fe;hpb=2422c46b27790d94fd29a7092170cee5a1b56008;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index 6f770957f..fa9a70d50 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts @@ -98,6 +98,15 @@ export class VideoShareModel extends Model { }) } + static loadByUrl (url: string, t: Sequelize.Transaction) { + return VideoShareModel.scope(ScopeNames.FULL).findOne({ + where: { + url + }, + transaction: t + }) + } + static loadActorsByShare (videoId: number, t: Sequelize.Transaction) { const query = { where: { @@ -178,4 +187,17 @@ export class VideoShareModel extends Model { .findAll(query) .then(res => res.map(r => r.Actor)) } + + static listAndCountByVideoId (videoId: number, start: number, count: number, t?: Sequelize.Transaction) { + const query = { + offset: start, + limit: count, + where: { + videoId + }, + transaction: t + } + + return VideoShareModel.findAndCountAll(query) + } }