diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-17 11:28:11 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-17 11:28:11 +0200 |
commit | 154898b0b7bc1af41fc5a94974e338a3590c90f3 (patch) | |
tree | 5fb90f66da7587aed53c99ac1884c7acd0c1f7ca /server/models | |
parent | df98563e2104b82b119c00a3cd83cd0dc1242d25 (diff) | |
download | PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.tar.gz PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.tar.zst PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.zip |
Share models between server and client
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/user/user-interface.ts | 4 | ||||
-rw-r--r-- | server/models/user/user-video-rate.ts | 1 | ||||
-rw-r--r-- | server/models/video/video-abuse-interface.ts | 4 | ||||
-rw-r--r-- | server/models/video/video-abuse.ts | 5 | ||||
-rw-r--r-- | server/models/video/video-blacklist-interface.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-interface.ts | 11 |
6 files changed, 23 insertions, 4 deletions
diff --git a/server/models/user/user-interface.ts b/server/models/user/user-interface.ts index fd98a042e..48c67678b 100644 --- a/server/models/user/user-interface.ts +++ b/server/models/user/user-interface.ts | |||
@@ -58,6 +58,10 @@ export interface UserInstance extends UserClass, UserAttributes, Sequelize.Insta | |||
58 | id: number | 58 | id: number |
59 | createdAt: Date | 59 | createdAt: Date |
60 | updatedAt: Date | 60 | updatedAt: Date |
61 | |||
62 | isPasswordMatch: UserMethods.IsPasswordMatch | ||
63 | toFormatedJSON: UserMethods.ToFormatedJSON | ||
64 | isAdmin: UserMethods.IsAdmin | ||
61 | } | 65 | } |
62 | 66 | ||
63 | export interface UserModel extends UserClass, Sequelize.Model<UserInstance, UserAttributes> {} | 67 | export interface UserModel extends UserClass, Sequelize.Model<UserInstance, UserAttributes> {} |
diff --git a/server/models/user/user-video-rate.ts b/server/models/user/user-video-rate.ts index 1094eb281..4bdd35bc9 100644 --- a/server/models/user/user-video-rate.ts +++ b/server/models/user/user-video-rate.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | User rates per video. | 2 | User rates per video. |
3 | |||
4 | */ | 3 | */ |
5 | import { values } from 'lodash' | 4 | import { values } from 'lodash' |
6 | import * as Sequelize from 'sequelize' | 5 | import * as Sequelize from 'sequelize' |
diff --git a/server/models/video/video-abuse-interface.ts b/server/models/video/video-abuse-interface.ts index f3e32f79c..c85d09091 100644 --- a/server/models/video/video-abuse-interface.ts +++ b/server/models/video/video-abuse-interface.ts | |||
@@ -6,7 +6,7 @@ import { PodInstance } from '../pod' | |||
6 | import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/video-abuse.model' | 6 | import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/video-abuse.model' |
7 | 7 | ||
8 | export namespace VideoAbuseMethods { | 8 | export namespace VideoAbuseMethods { |
9 | export type toFormatedJSON = () => FormatedVideoAbuse | 9 | export type ToFormatedJSON = (this: VideoAbuseInstance) => FormatedVideoAbuse |
10 | 10 | ||
11 | export type ListForApiCallback = (err: Error, videoAbuseInstances?: VideoAbuseInstance[], total?: number) => void | 11 | export type ListForApiCallback = (err: Error, videoAbuseInstances?: VideoAbuseInstance[], total?: number) => void |
12 | export type ListForApi = (start: number, count: number, sort: string, callback: ListForApiCallback) => void | 12 | export type ListForApi = (start: number, count: number, sort: string, callback: ListForApiCallback) => void |
@@ -28,6 +28,8 @@ export interface VideoAbuseInstance extends VideoAbuseClass, VideoAbuseAttribute | |||
28 | updatedAt: Date | 28 | updatedAt: Date |
29 | 29 | ||
30 | Pod: PodInstance | 30 | Pod: PodInstance |
31 | |||
32 | toFormatedJSON: VideoAbuseMethods.ToFormatedJSON | ||
31 | } | 33 | } |
32 | 34 | ||
33 | export interface VideoAbuseModel extends VideoAbuseClass, Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> {} | 35 | export interface VideoAbuseModel extends VideoAbuseClass, Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> {} |
diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts index f5b4debe6..bc5f01e21 100644 --- a/server/models/video/video-abuse.ts +++ b/server/models/video/video-abuse.ts | |||
@@ -13,6 +13,7 @@ import { | |||
13 | } from './video-abuse-interface' | 13 | } from './video-abuse-interface' |
14 | 14 | ||
15 | let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> | 15 | let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> |
16 | let toFormatedJSON: VideoAbuseMethods.ToFormatedJSON | ||
16 | let listForApi: VideoAbuseMethods.ListForApi | 17 | let listForApi: VideoAbuseMethods.ListForApi |
17 | 18 | ||
18 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { | 19 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { |
@@ -66,7 +67,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
66 | 67 | ||
67 | // ------------------------------ METHODS ------------------------------ | 68 | // ------------------------------ METHODS ------------------------------ |
68 | 69 | ||
69 | function toFormatedJSON (this: VideoAbuseInstance) { | 70 | toFormatedJSON = function (this: VideoAbuseInstance) { |
70 | let reporterPodHost | 71 | let reporterPodHost |
71 | 72 | ||
72 | if (this.Pod) { | 73 | if (this.Pod) { |
@@ -108,7 +109,7 @@ function associate (models) { | |||
108 | }) | 109 | }) |
109 | } | 110 | } |
110 | 111 | ||
111 | listForApi = function (start, count, sort, callback) { | 112 | listForApi = function (start: number, count: number, sort: string, callback: VideoAbuseMethods.ListForApiCallback) { |
112 | const query = { | 113 | const query = { |
113 | offset: start, | 114 | offset: start, |
114 | limit: count, | 115 | limit: count, |
diff --git a/server/models/video/video-blacklist-interface.ts b/server/models/video/video-blacklist-interface.ts index c34e7fb09..d4d6528d1 100644 --- a/server/models/video/video-blacklist-interface.ts +++ b/server/models/video/video-blacklist-interface.ts | |||
@@ -39,6 +39,8 @@ export interface BlacklistedVideoInstance extends BlacklistedVideoClass, Blackli | |||
39 | id: number | 39 | id: number |
40 | createdAt: Date | 40 | createdAt: Date |
41 | updatedAt: Date | 41 | updatedAt: Date |
42 | |||
43 | toFormatedJSON: BlacklistedVideoMethods.ToFormatedJSON | ||
42 | } | 44 | } |
43 | 45 | ||
44 | export interface BlacklistedVideoModel extends BlacklistedVideoClass, Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes> {} | 46 | export interface BlacklistedVideoModel extends BlacklistedVideoClass, Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes> {} |
diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts index 5fefc2bb1..4b591b9e7 100644 --- a/server/models/video/video-interface.ts +++ b/server/models/video/video-interface.ts | |||
@@ -146,6 +146,17 @@ export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.In | |||
146 | id: string | 146 | id: string |
147 | createdAt: Date | 147 | createdAt: Date |
148 | updatedAt: Date | 148 | updatedAt: Date |
149 | |||
150 | generateMagnetUri: VideoMethods.GenerateMagnetUri | ||
151 | getVideoFilename: VideoMethods.GetVideoFilename | ||
152 | getThumbnailName: VideoMethods.GetThumbnailName | ||
153 | getPreviewName: VideoMethods.GetPreviewName | ||
154 | getTorrentName: VideoMethods.GetTorrentName | ||
155 | isOwned: VideoMethods.IsOwned | ||
156 | toFormatedJSON: VideoMethods.ToFormatedJSON | ||
157 | toAddRemoteJSON: VideoMethods.ToAddRemoteJSON | ||
158 | toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON | ||
159 | transcodeVideofile: VideoMethods.TranscodeVideofile | ||
149 | } | 160 | } |
150 | 161 | ||
151 | export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} | 162 | export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} |