aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-share.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-share.ts')
-rw-r--r--server/models/video/video-share.ts28
1 files changed, 27 insertions, 1 deletions
diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts
index 48ba68a4a..6f770957f 100644
--- a/server/models/video/video-share.ts
+++ b/server/models/video/video-share.ts
@@ -1,4 +1,5 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as Bluebird from 'bluebird'
2import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' 3import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript'
3import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' 4import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
4import { CONSTRAINTS_FIELDS } from '../../initializers' 5import { CONSTRAINTS_FIELDS } from '../../initializers'
@@ -115,7 +116,7 @@ export class VideoShareModel extends Model<VideoShareModel> {
115 .then(res => res.map(r => r.Actor)) 116 .then(res => res.map(r => r.Actor))
116 } 117 }
117 118
118 static loadActorsByVideoOwner (actorOwnerId: number, t: Sequelize.Transaction) { 119 static loadActorsByVideoOwner (actorOwnerId: number, t: Sequelize.Transaction): Bluebird<ActorModel[]> {
119 const query = { 120 const query = {
120 attributes: [], 121 attributes: [],
121 include: [ 122 include: [
@@ -152,4 +153,29 @@ export class VideoShareModel extends Model<VideoShareModel> {
152 return VideoShareModel.scope(ScopeNames.FULL).findAll(query) 153 return VideoShareModel.scope(ScopeNames.FULL).findAll(query)
153 .then(res => res.map(r => r.Actor)) 154 .then(res => res.map(r => r.Actor))
154 } 155 }
156
157 static loadActorsByVideoChannel (videoChannelId: number, t: Sequelize.Transaction): Bluebird<ActorModel[]> {
158 const query = {
159 attributes: [],
160 include: [
161 {
162 model: ActorModel,
163 required: true
164 },
165 {
166 attributes: [],
167 model: VideoModel,
168 required: true,
169 where: {
170 channelId: videoChannelId
171 }
172 }
173 ],
174 transaction: t
175 }
176
177 return VideoShareModel.scope(ScopeNames.FULL)
178 .findAll(query)
179 .then(res => res.map(r => r.Actor))
180 }
155} 181}