aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-17 11:28:11 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-17 11:28:11 +0200
commit154898b0b7bc1af41fc5a94974e338a3590c90f3 (patch)
tree5fb90f66da7587aed53c99ac1884c7acd0c1f7ca /server/models
parentdf98563e2104b82b119c00a3cd83cd0dc1242d25 (diff)
downloadPeerTube-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.ts4
-rw-r--r--server/models/user/user-video-rate.ts1
-rw-r--r--server/models/video/video-abuse-interface.ts4
-rw-r--r--server/models/video/video-abuse.ts5
-rw-r--r--server/models/video/video-blacklist-interface.ts2
-rw-r--r--server/models/video/video-interface.ts11
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
63export interface UserModel extends UserClass, Sequelize.Model<UserInstance, UserAttributes> {} 67export 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*/
5import { values } from 'lodash' 4import { values } from 'lodash'
6import * as Sequelize from 'sequelize' 5import * 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'
6import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/video-abuse.model' 6import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/video-abuse.model'
7 7
8export namespace VideoAbuseMethods { 8export 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
33export interface VideoAbuseModel extends VideoAbuseClass, Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> {} 35export 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
15let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> 15let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes>
16let toFormatedJSON: VideoAbuseMethods.ToFormatedJSON
16let listForApi: VideoAbuseMethods.ListForApi 17let listForApi: VideoAbuseMethods.ListForApi
17 18
18export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { 19export 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
69function toFormatedJSON (this: VideoAbuseInstance) { 70toFormatedJSON = 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
111listForApi = function (start, count, sort, callback) { 112listForApi = 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
44export interface BlacklistedVideoModel extends BlacklistedVideoClass, Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes> {} 46export 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
151export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} 162export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {}