diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-16 15:55:01 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | d7d5611c8a23de9b483f0437ad3469afef7b8805 (patch) | |
tree | 35f8f77e5f211a65f8be3c967e939f83c7e17d29 /server/models/video/video-share.ts | |
parent | 20494f122186bb1bfd82f4c598c4744acea27b0c (diff) | |
download | PeerTube-d7d5611c8a23de9b483f0437ad3469afef7b8805.tar.gz PeerTube-d7d5611c8a23de9b483f0437ad3469afef7b8805.tar.zst PeerTube-d7d5611c8a23de9b483f0437ad3469afef7b8805.zip |
Federate video update
Diffstat (limited to 'server/models/video/video-share.ts')
-rw-r--r-- | server/models/video/video-share.ts | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index 358491fd2..22ac31a4a 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts | |||
@@ -1,9 +1,10 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { addMethodsToModel } from '../utils' | 3 | import { addMethodsToModel } from '../utils' |
4 | import { VideoShareAttributes, VideoShareInstance } from './video-share-interface' | 4 | import { VideoShareAttributes, VideoShareInstance, VideoShareMethods } from './video-share-interface' |
5 | 5 | ||
6 | let VideoShare: Sequelize.Model<VideoShareInstance, VideoShareAttributes> | 6 | let VideoShare: Sequelize.Model<VideoShareInstance, VideoShareAttributes> |
7 | let loadAccountsByShare: VideoShareMethods.LoadAccountsByShare | ||
7 | 8 | ||
8 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { | 9 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { |
9 | VideoShare = sequelize.define<VideoShareInstance, VideoShareAttributes>('VideoShare', | 10 | VideoShare = sequelize.define<VideoShareInstance, VideoShareAttributes>('VideoShare', |
@@ -21,7 +22,8 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
21 | ) | 22 | ) |
22 | 23 | ||
23 | const classMethods = [ | 24 | const classMethods = [ |
24 | associate | 25 | associate, |
26 | loadAccountsByShare | ||
25 | ] | 27 | ] |
26 | addMethodsToModel(VideoShare, classMethods) | 28 | addMethodsToModel(VideoShare, classMethods) |
27 | 29 | ||
@@ -47,3 +49,20 @@ function associate (models) { | |||
47 | onDelete: 'cascade' | 49 | onDelete: 'cascade' |
48 | }) | 50 | }) |
49 | } | 51 | } |
52 | |||
53 | loadAccountsByShare = function (videoId: number) { | ||
54 | const query = { | ||
55 | where: { | ||
56 | videoId | ||
57 | }, | ||
58 | include: [ | ||
59 | { | ||
60 | model: VideoShare['sequelize'].models.Account, | ||
61 | required: true | ||
62 | } | ||
63 | ] | ||
64 | } | ||
65 | |||
66 | return VideoShare.findAll(query) | ||
67 | .then(res => res.map(r => r.Account)) | ||
68 | } | ||