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.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts
index c252fd646..56576f98c 100644
--- a/server/models/video/video-share.ts
+++ b/server/models/video/video-share.ts
@@ -1,7 +1,9 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' 2import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript'
3import { AccountModel } from '../account/account'
3import { ActorModel } from '../activitypub/actor' 4import { ActorModel } from '../activitypub/actor'
4import { VideoModel } from './video' 5import { VideoModel } from './video'
6import { VideoChannelModel } from './video-channel'
5 7
6enum ScopeNames { 8enum ScopeNames {
7 FULL = 'FULL', 9 FULL = 'FULL',
@@ -99,4 +101,42 @@ export class VideoShareModel extends Model<VideoShareModel> {
99 return VideoShareModel.scope(ScopeNames.FULL).findAll(query) 101 return VideoShareModel.scope(ScopeNames.FULL).findAll(query)
100 .then(res => res.map(r => r.Actor)) 102 .then(res => res.map(r => r.Actor))
101 } 103 }
104
105 static loadActorsByVideoOwner (actorOwnerId: number, t: Sequelize.Transaction) {
106 const query = {
107 attributes: [],
108 include: [
109 {
110 model: ActorModel,
111 required: true
112 },
113 {
114 attributes: [],
115 model: VideoModel,
116 required: true,
117 include: [
118 {
119 attributes: [],
120 model: VideoChannelModel.unscoped(),
121 required: true,
122 include: [
123 {
124 attributes: [],
125 model: AccountModel.unscoped(),
126 required: true,
127 where: {
128 actorId: actorOwnerId
129 }
130 }
131 ]
132 }
133 ]
134 }
135 ],
136 transaction: t
137 }
138
139 return VideoShareModel.scope(ScopeNames.FULL).findAll(query)
140 .then(res => res.map(r => r.Actor))
141 }
102} 142}