diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 14:44:51 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:53 +0100 |
commit | 4e50b6a1c9a3eb261e04ede73241648e6edf21d6 (patch) | |
tree | e1c6c121d561ffc1cf2996daec03a1e7f27f0a25 /server/models/video/video-share.ts | |
parent | 74bb2cb8348d6794ed3a0e2ec94c8c9abdde82cf (diff) | |
download | PeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.tar.gz PeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.tar.zst PeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.zip |
Add shares forward and collection on videos/video channels
Diffstat (limited to 'server/models/video/video-share.ts')
-rw-r--r-- | server/models/video/video-share.ts | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index 22ac31a4a..fe5d56d42 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts | |||
@@ -5,6 +5,7 @@ import { VideoShareAttributes, VideoShareInstance, VideoShareMethods } from './v | |||
5 | 5 | ||
6 | let VideoShare: Sequelize.Model<VideoShareInstance, VideoShareAttributes> | 6 | let VideoShare: Sequelize.Model<VideoShareInstance, VideoShareAttributes> |
7 | let loadAccountsByShare: VideoShareMethods.LoadAccountsByShare | 7 | let loadAccountsByShare: VideoShareMethods.LoadAccountsByShare |
8 | let load: VideoShareMethods.Load | ||
8 | 9 | ||
9 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { | 10 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { |
10 | VideoShare = sequelize.define<VideoShareInstance, VideoShareAttributes>('VideoShare', | 11 | VideoShare = sequelize.define<VideoShareInstance, VideoShareAttributes>('VideoShare', |
@@ -23,7 +24,8 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
23 | 24 | ||
24 | const classMethods = [ | 25 | const classMethods = [ |
25 | associate, | 26 | associate, |
26 | loadAccountsByShare | 27 | loadAccountsByShare, |
28 | load | ||
27 | ] | 29 | ] |
28 | addMethodsToModel(VideoShare, classMethods) | 30 | addMethodsToModel(VideoShare, classMethods) |
29 | 31 | ||
@@ -50,6 +52,18 @@ function associate (models) { | |||
50 | }) | 52 | }) |
51 | } | 53 | } |
52 | 54 | ||
55 | load = function (accountId: number, videoId: number) { | ||
56 | return VideoShare.findOne({ | ||
57 | where: { | ||
58 | accountId, | ||
59 | videoId | ||
60 | }, | ||
61 | include: [ | ||
62 | VideoShare['sequelize'].models.Account | ||
63 | ] | ||
64 | }) | ||
65 | } | ||
66 | |||
53 | loadAccountsByShare = function (videoId: number) { | 67 | loadAccountsByShare = function (videoId: number) { |
54 | const query = { | 68 | const query = { |
55 | where: { | 69 | where: { |