diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-15 14:46:26 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-15 15:29:07 +0100 |
commit | 2422c46b27790d94fd29a7092170cee5a1b56008 (patch) | |
tree | d5c1942ce20cadb27a551d87c789edfe92f5b105 /server/models/video/video-share.ts | |
parent | 34cbef8c6cc912143a421413bdd832c4adcc556a (diff) | |
download | PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.gz PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.zst PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.zip |
Implement support field in video and video channel
Diffstat (limited to 'server/models/video/video-share.ts')
-rw-r--r-- | server/models/video/video-share.ts | 28 |
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 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import * as Bluebird from 'bluebird' | ||
2 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' | 3 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' |
3 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 4 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
4 | import { CONSTRAINTS_FIELDS } from '../../initializers' | 5 | import { 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 | } |