diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/models/pod/pod-interface.ts | 2 | ||||
-rw-r--r-- | server/models/pod/pod.ts | 4 | ||||
-rw-r--r-- | server/models/user/user-interface.ts | 6 | ||||
-rw-r--r-- | server/models/user/user.ts | 4 | ||||
-rw-r--r-- | server/models/video/video-abuse-interface.ts | 5 | ||||
-rw-r--r-- | server/models/video/video-abuse.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-blacklist-interface.ts | 3 | ||||
-rw-r--r-- | server/models/video/video-blacklist.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-interface.ts | 20 | ||||
-rw-r--r-- | server/models/video/video.ts | 22 |
10 files changed, 38 insertions, 32 deletions
diff --git a/server/models/pod/pod-interface.ts b/server/models/pod/pod-interface.ts index 01ccda64c..d88847c45 100644 --- a/server/models/pod/pod-interface.ts +++ b/server/models/pod/pod-interface.ts | |||
@@ -4,7 +4,7 @@ import * as Sequelize from 'sequelize' | |||
4 | import { Pod as FormatedPod } from '../../../shared/models/pod.model' | 4 | import { Pod as FormatedPod } from '../../../shared/models/pod.model' |
5 | 5 | ||
6 | export namespace PodMethods { | 6 | export namespace PodMethods { |
7 | export type ToFormatedJSON = () => FormatedPod | 7 | export type ToFormatedJSON = (this: PodInstance) => FormatedPod |
8 | 8 | ||
9 | export type CountAllCallback = (err: Error, total: number) => void | 9 | export type CountAllCallback = (err: Error, total: number) => void |
10 | export type CountAll = (callback) => void | 10 | export type CountAll = (callback) => void |
diff --git a/server/models/pod/pod.ts b/server/models/pod/pod.ts index 4c6e63024..4fe7fda1c 100644 --- a/server/models/pod/pod.ts +++ b/server/models/pod/pod.ts | |||
@@ -96,12 +96,12 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
96 | 96 | ||
97 | // ------------------------------ METHODS ------------------------------ | 97 | // ------------------------------ METHODS ------------------------------ |
98 | 98 | ||
99 | toFormatedJSON = function () { | 99 | toFormatedJSON = function (this: PodInstance) { |
100 | const json = { | 100 | const json = { |
101 | id: this.id, | 101 | id: this.id, |
102 | host: this.host, | 102 | host: this.host, |
103 | email: this.email, | 103 | email: this.email, |
104 | score: this.score, | 104 | score: this.score as number, |
105 | createdAt: this.createdAt | 105 | createdAt: this.createdAt |
106 | } | 106 | } |
107 | 107 | ||
diff --git a/server/models/user/user-interface.ts b/server/models/user/user-interface.ts index 1ba4bd800..6726e8ab5 100644 --- a/server/models/user/user-interface.ts +++ b/server/models/user/user-interface.ts | |||
@@ -6,10 +6,10 @@ import { User as FormatedUser } from '../../../shared/models/user.model' | |||
6 | 6 | ||
7 | export namespace UserMethods { | 7 | export namespace UserMethods { |
8 | export type IsPasswordMatchCallback = (err: Error, same: boolean) => void | 8 | export type IsPasswordMatchCallback = (err: Error, same: boolean) => void |
9 | export type IsPasswordMatch = (password: string, callback: IsPasswordMatchCallback) => void | 9 | export type IsPasswordMatch = (this: UserInstance, password: string, callback: IsPasswordMatchCallback) => void |
10 | 10 | ||
11 | export type ToFormatedJSON = () => FormatedUser | 11 | export type ToFormatedJSON = (this: UserInstance) => FormatedUser |
12 | export type IsAdmin = () => boolean | 12 | export type IsAdmin = (this: UserInstance) => boolean |
13 | 13 | ||
14 | export type CountTotalCallback = (err: Error, total: number) => void | 14 | export type CountTotalCallback = (err: Error, total: number) => void |
15 | export type CountTotal = (callback: CountTotalCallback) => void | 15 | export type CountTotal = (callback: CountTotalCallback) => void |
diff --git a/server/models/user/user.ts b/server/models/user/user.ts index d78f5f845..6b2410259 100644 --- a/server/models/user/user.ts +++ b/server/models/user/user.ts | |||
@@ -131,7 +131,7 @@ function beforeCreateOrUpdate (user: UserInstance) { | |||
131 | 131 | ||
132 | // ------------------------------ METHODS ------------------------------ | 132 | // ------------------------------ METHODS ------------------------------ |
133 | 133 | ||
134 | isPasswordMatch = function (password: string, callback: UserMethods.IsPasswordMatchCallback) { | 134 | isPasswordMatch = function (this: UserInstance, password: string, callback: UserMethods.IsPasswordMatchCallback) { |
135 | return comparePassword(password, this.password, callback) | 135 | return comparePassword(password, this.password, callback) |
136 | } | 136 | } |
137 | 137 | ||
@@ -146,7 +146,7 @@ toFormatedJSON = function (this: UserInstance) { | |||
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | isAdmin = function () { | 149 | isAdmin = function (this: UserInstance) { |
150 | return this.role === USER_ROLES.ADMIN | 150 | return this.role === USER_ROLES.ADMIN |
151 | } | 151 | } |
152 | 152 | ||
diff --git a/server/models/video/video-abuse-interface.ts b/server/models/video/video-abuse-interface.ts index 4b7f2a2ec..f3e32f79c 100644 --- a/server/models/video/video-abuse-interface.ts +++ b/server/models/video/video-abuse-interface.ts | |||
@@ -1,5 +1,7 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { PodInstance } from '../pod' | ||
4 | |||
3 | // Don't use barrel, import just what we need | 5 | // Don't use barrel, import just what we need |
4 | import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/video-abuse.model' | 6 | import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/video-abuse.model' |
5 | 7 | ||
@@ -17,12 +19,15 @@ export interface VideoAbuseClass { | |||
17 | export interface VideoAbuseAttributes { | 19 | export interface VideoAbuseAttributes { |
18 | reporterUsername: string | 20 | reporterUsername: string |
19 | reason: string | 21 | reason: string |
22 | videoId: string | ||
20 | } | 23 | } |
21 | 24 | ||
22 | export interface VideoAbuseInstance extends VideoAbuseClass, VideoAbuseAttributes, Sequelize.Instance<VideoAbuseAttributes> { | 25 | export interface VideoAbuseInstance extends VideoAbuseClass, VideoAbuseAttributes, Sequelize.Instance<VideoAbuseAttributes> { |
23 | id: number | 26 | id: number |
24 | createdAt: Date | 27 | createdAt: Date |
25 | updatedAt: Date | 28 | updatedAt: Date |
29 | |||
30 | Pod: PodInstance | ||
26 | } | 31 | } |
27 | 32 | ||
28 | export interface VideoAbuseModel extends VideoAbuseClass, Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> {} | 33 | 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 e0e0bcfe6..f5b4debe6 100644 --- a/server/models/video/video-abuse.ts +++ b/server/models/video/video-abuse.ts | |||
@@ -66,7 +66,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
66 | 66 | ||
67 | // ------------------------------ METHODS ------------------------------ | 67 | // ------------------------------ METHODS ------------------------------ |
68 | 68 | ||
69 | function toFormatedJSON () { | 69 | function toFormatedJSON (this: VideoAbuseInstance) { |
70 | let reporterPodHost | 70 | let reporterPodHost |
71 | 71 | ||
72 | if (this.Pod) { | 72 | if (this.Pod) { |
diff --git a/server/models/video/video-blacklist-interface.ts b/server/models/video/video-blacklist-interface.ts index 37f579422..c34e7fb09 100644 --- a/server/models/video/video-blacklist-interface.ts +++ b/server/models/video/video-blacklist-interface.ts | |||
@@ -4,7 +4,7 @@ import * as Sequelize from 'sequelize' | |||
4 | import { BlacklistedVideo as FormatedBlacklistedVideo } from '../../../shared/models/video-blacklist.model' | 4 | import { BlacklistedVideo as FormatedBlacklistedVideo } from '../../../shared/models/video-blacklist.model' |
5 | 5 | ||
6 | export namespace BlacklistedVideoMethods { | 6 | export namespace BlacklistedVideoMethods { |
7 | export type ToFormatedJSON = () => FormatedBlacklistedVideo | 7 | export type ToFormatedJSON = (this: BlacklistedVideoInstance) => FormatedBlacklistedVideo |
8 | 8 | ||
9 | export type CountTotalCallback = (err: Error, total: number) => void | 9 | export type CountTotalCallback = (err: Error, total: number) => void |
10 | export type CountTotal = (callback: CountTotalCallback) => void | 10 | export type CountTotal = (callback: CountTotalCallback) => void |
@@ -32,6 +32,7 @@ export interface BlacklistedVideoClass { | |||
32 | } | 32 | } |
33 | 33 | ||
34 | export interface BlacklistedVideoAttributes { | 34 | export interface BlacklistedVideoAttributes { |
35 | videoId: string | ||
35 | } | 36 | } |
36 | 37 | ||
37 | export interface BlacklistedVideoInstance extends BlacklistedVideoClass, BlacklistedVideoAttributes, Sequelize.Instance<BlacklistedVideoAttributes> { | 38 | export interface BlacklistedVideoInstance extends BlacklistedVideoClass, BlacklistedVideoAttributes, Sequelize.Instance<BlacklistedVideoAttributes> { |
diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.ts index f4479986c..3576c96f6 100644 --- a/server/models/video/video-blacklist.ts +++ b/server/models/video/video-blacklist.ts | |||
@@ -49,7 +49,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
49 | 49 | ||
50 | // ------------------------------ METHODS ------------------------------ | 50 | // ------------------------------ METHODS ------------------------------ |
51 | 51 | ||
52 | toFormatedJSON = function () { | 52 | toFormatedJSON = function (this: BlacklistedVideoInstance) { |
53 | return { | 53 | return { |
54 | id: this.id, | 54 | id: this.id, |
55 | videoId: this.videoId, | 55 | videoId: this.videoId, |
diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts index 71b9b0a69..5fefc2bb1 100644 --- a/server/models/video/video-interface.ts +++ b/server/models/video/video-interface.ts | |||
@@ -48,21 +48,21 @@ export type FormatedUpdateRemoteVideo = { | |||
48 | } | 48 | } |
49 | 49 | ||
50 | export namespace VideoMethods { | 50 | export namespace VideoMethods { |
51 | export type GenerateMagnetUri = () => string | 51 | export type GenerateMagnetUri = (this: VideoInstance) => string |
52 | export type GetVideoFilename = () => string | 52 | export type GetVideoFilename = (this: VideoInstance) => string |
53 | export type GetThumbnailName = () => string | 53 | export type GetThumbnailName = (this: VideoInstance) => string |
54 | export type GetPreviewName = () => string | 54 | export type GetPreviewName = (this: VideoInstance) => string |
55 | export type GetTorrentName = () => string | 55 | export type GetTorrentName = (this: VideoInstance) => string |
56 | export type IsOwned = () => boolean | 56 | export type IsOwned = (this: VideoInstance) => boolean |
57 | export type ToFormatedJSON = () => FormatedVideo | 57 | export type ToFormatedJSON = (this: VideoInstance) => FormatedVideo |
58 | 58 | ||
59 | export type ToAddRemoteJSONCallback = (err: Error, videoFormated?: FormatedAddRemoteVideo) => void | 59 | export type ToAddRemoteJSONCallback = (err: Error, videoFormated?: FormatedAddRemoteVideo) => void |
60 | export type ToAddRemoteJSON = (callback: ToAddRemoteJSONCallback) => void | 60 | export type ToAddRemoteJSON = (this: VideoInstance, callback: ToAddRemoteJSONCallback) => void |
61 | 61 | ||
62 | export type ToUpdateRemoteJSON = () => FormatedUpdateRemoteVideo | 62 | export type ToUpdateRemoteJSON = (this: VideoInstance) => FormatedUpdateRemoteVideo |
63 | 63 | ||
64 | export type TranscodeVideofileCallback = (err: Error) => void | 64 | export type TranscodeVideofileCallback = (err: Error) => void |
65 | export type TranscodeVideofile = (callback: TranscodeVideofileCallback) => void | 65 | export type TranscodeVideofile = (this: VideoInstance, callback: TranscodeVideofileCallback) => void |
66 | 66 | ||
67 | export type GenerateThumbnailFromDataCallback = (err: Error, thumbnailName?: string) => void | 67 | export type GenerateThumbnailFromDataCallback = (err: Error, thumbnailName?: string) => void |
68 | export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string, callback: GenerateThumbnailFromDataCallback) => void | 68 | export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string, callback: GenerateThumbnailFromDataCallback) => void |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 866b380cc..e66ebee2d 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -247,7 +247,8 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
247 | loadByHostAndRemoteId, | 247 | loadByHostAndRemoteId, |
248 | loadAndPopulateAuthor, | 248 | loadAndPopulateAuthor, |
249 | loadAndPopulateAuthorAndPodAndTags, | 249 | loadAndPopulateAuthorAndPodAndTags, |
250 | searchAndPopulateAuthorAndPodAndTags | 250 | searchAndPopulateAuthorAndPodAndTags, |
251 | removeFromBlacklist | ||
251 | ] | 252 | ] |
252 | const instanceMethods = [ | 253 | const instanceMethods = [ |
253 | generateMagnetUri, | 254 | generateMagnetUri, |
@@ -260,7 +261,6 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
260 | toAddRemoteJSON, | 261 | toAddRemoteJSON, |
261 | toUpdateRemoteJSON, | 262 | toUpdateRemoteJSON, |
262 | transcodeVideofile, | 263 | transcodeVideofile, |
263 | removeFromBlacklist | ||
264 | ] | 264 | ] |
265 | addMethodsToModel(Video, classMethods, instanceMethods) | 265 | addMethodsToModel(Video, classMethods, instanceMethods) |
266 | 266 | ||
@@ -389,7 +389,7 @@ function associate (models) { | |||
389 | }) | 389 | }) |
390 | } | 390 | } |
391 | 391 | ||
392 | generateMagnetUri = function () { | 392 | generateMagnetUri = function (this: VideoInstance) { |
393 | let baseUrlHttp | 393 | let baseUrlHttp |
394 | let baseUrlWs | 394 | let baseUrlWs |
395 | 395 | ||
@@ -416,18 +416,18 @@ generateMagnetUri = function () { | |||
416 | return magnetUtil.encode(magnetHash) | 416 | return magnetUtil.encode(magnetHash) |
417 | } | 417 | } |
418 | 418 | ||
419 | getVideoFilename = function () { | 419 | getVideoFilename = function (this: VideoInstance) { |
420 | if (this.isOwned()) return this.id + this.extname | 420 | if (this.isOwned()) return this.id + this.extname |
421 | 421 | ||
422 | return this.remoteId + this.extname | 422 | return this.remoteId + this.extname |
423 | } | 423 | } |
424 | 424 | ||
425 | getThumbnailName = function () { | 425 | getThumbnailName = function (this: VideoInstance) { |
426 | // We always have a copy of the thumbnail | 426 | // We always have a copy of the thumbnail |
427 | return this.id + '.jpg' | 427 | return this.id + '.jpg' |
428 | } | 428 | } |
429 | 429 | ||
430 | getPreviewName = function () { | 430 | getPreviewName = function (this: VideoInstance) { |
431 | const extension = '.jpg' | 431 | const extension = '.jpg' |
432 | 432 | ||
433 | if (this.isOwned()) return this.id + extension | 433 | if (this.isOwned()) return this.id + extension |
@@ -435,7 +435,7 @@ getPreviewName = function () { | |||
435 | return this.remoteId + extension | 435 | return this.remoteId + extension |
436 | } | 436 | } |
437 | 437 | ||
438 | getTorrentName = function () { | 438 | getTorrentName = function (this: VideoInstance) { |
439 | const extension = '.torrent' | 439 | const extension = '.torrent' |
440 | 440 | ||
441 | if (this.isOwned()) return this.id + extension | 441 | if (this.isOwned()) return this.id + extension |
@@ -443,7 +443,7 @@ getTorrentName = function () { | |||
443 | return this.remoteId + extension | 443 | return this.remoteId + extension |
444 | } | 444 | } |
445 | 445 | ||
446 | isOwned = function () { | 446 | isOwned = function (this: VideoInstance) { |
447 | return this.remoteId === null | 447 | return this.remoteId === null |
448 | } | 448 | } |
449 | 449 | ||
@@ -497,7 +497,7 @@ toFormatedJSON = function (this: VideoInstance) { | |||
497 | return json | 497 | return json |
498 | } | 498 | } |
499 | 499 | ||
500 | toAddRemoteJSON = function (callback: VideoMethods.ToAddRemoteJSONCallback) { | 500 | toAddRemoteJSON = function (this: VideoInstance, callback: VideoMethods.ToAddRemoteJSONCallback) { |
501 | // Get thumbnail data to send to the other pod | 501 | // Get thumbnail data to send to the other pod |
502 | const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, this.getThumbnailName()) | 502 | const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, this.getThumbnailName()) |
503 | fs.readFile(thumbnailPath, (err, thumbnailData) => { | 503 | fs.readFile(thumbnailPath, (err, thumbnailData) => { |
@@ -531,7 +531,7 @@ toAddRemoteJSON = function (callback: VideoMethods.ToAddRemoteJSONCallback) { | |||
531 | }) | 531 | }) |
532 | } | 532 | } |
533 | 533 | ||
534 | toUpdateRemoteJSON = function () { | 534 | toUpdateRemoteJSON = function (this: VideoInstance) { |
535 | const json = { | 535 | const json = { |
536 | name: this.name, | 536 | name: this.name, |
537 | category: this.category, | 537 | category: this.category, |
@@ -555,7 +555,7 @@ toUpdateRemoteJSON = function () { | |||
555 | return json | 555 | return json |
556 | } | 556 | } |
557 | 557 | ||
558 | transcodeVideofile = function (finalCallback: VideoMethods.TranscodeVideofileCallback) { | 558 | transcodeVideofile = function (this: VideoInstance, finalCallback: VideoMethods.TranscodeVideofileCallback) { |
559 | const video = this | 559 | const video = this |
560 | 560 | ||
561 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR | 561 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR |