diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-23 17:36:15 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:53 +0100 |
commit | 39445ead45aaaea801ec09991b8dd2464f722e47 (patch) | |
tree | 9306c6b89115dabdd4a7c31a59784134a0e1c804 /server/models/video | |
parent | 16b90975941b78d01d7202d441bf731a10048c16 (diff) | |
download | PeerTube-39445ead45aaaea801ec09991b8dd2464f722e47.tar.gz PeerTube-39445ead45aaaea801ec09991b8dd2464f722e47.tar.zst PeerTube-39445ead45aaaea801ec09991b8dd2464f722e47.zip |
Cleanup models
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video-blacklist-interface.ts | 11 | ||||
-rw-r--r-- | server/models/video/video-blacklist.ts | 18 | ||||
-rw-r--r-- | server/models/video/video-channel-interface.ts | 12 | ||||
-rw-r--r-- | server/models/video/video-channel.ts | 13 | ||||
-rw-r--r-- | server/models/video/video-interface.ts | 17 | ||||
-rw-r--r-- | server/models/video/video.ts | 137 |
6 files changed, 7 insertions, 201 deletions
diff --git a/server/models/video/video-blacklist-interface.ts b/server/models/video/video-blacklist-interface.ts index 9d167c037..be2483d4c 100644 --- a/server/models/video/video-blacklist-interface.ts +++ b/server/models/video/video-blacklist-interface.ts | |||
@@ -10,24 +10,13 @@ import { BlacklistedVideo as FormattedBlacklistedVideo } from '../../../shared/m | |||
10 | 10 | ||
11 | export namespace BlacklistedVideoMethods { | 11 | export namespace BlacklistedVideoMethods { |
12 | export type ToFormattedJSON = (this: BlacklistedVideoInstance) => FormattedBlacklistedVideo | 12 | export type ToFormattedJSON = (this: BlacklistedVideoInstance) => FormattedBlacklistedVideo |
13 | |||
14 | export type CountTotal = () => Promise<number> | ||
15 | |||
16 | export type List = () => Promise<BlacklistedVideoInstance[]> | ||
17 | |||
18 | export type ListForApi = (start: number, count: number, sort: SortType) => Promise< ResultList<BlacklistedVideoInstance> > | 13 | export type ListForApi = (start: number, count: number, sort: SortType) => Promise< ResultList<BlacklistedVideoInstance> > |
19 | |||
20 | export type LoadById = (id: number) => Promise<BlacklistedVideoInstance> | ||
21 | |||
22 | export type LoadByVideoId = (id: number) => Promise<BlacklistedVideoInstance> | 14 | export type LoadByVideoId = (id: number) => Promise<BlacklistedVideoInstance> |
23 | } | 15 | } |
24 | 16 | ||
25 | export interface BlacklistedVideoClass { | 17 | export interface BlacklistedVideoClass { |
26 | toFormattedJSON: BlacklistedVideoMethods.ToFormattedJSON | 18 | toFormattedJSON: BlacklistedVideoMethods.ToFormattedJSON |
27 | countTotal: BlacklistedVideoMethods.CountTotal | ||
28 | list: BlacklistedVideoMethods.List | ||
29 | listForApi: BlacklistedVideoMethods.ListForApi | 19 | listForApi: BlacklistedVideoMethods.ListForApi |
30 | loadById: BlacklistedVideoMethods.LoadById | ||
31 | loadByVideoId: BlacklistedVideoMethods.LoadByVideoId | 20 | loadByVideoId: BlacklistedVideoMethods.LoadByVideoId |
32 | } | 21 | } |
33 | 22 | ||
diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.ts index 1c279b1ba..ae8286285 100644 --- a/server/models/video/video-blacklist.ts +++ b/server/models/video/video-blacklist.ts | |||
@@ -12,10 +12,7 @@ import { | |||
12 | 12 | ||
13 | let BlacklistedVideo: Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes> | 13 | let BlacklistedVideo: Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes> |
14 | let toFormattedJSON: BlacklistedVideoMethods.ToFormattedJSON | 14 | let toFormattedJSON: BlacklistedVideoMethods.ToFormattedJSON |
15 | let countTotal: BlacklistedVideoMethods.CountTotal | ||
16 | let list: BlacklistedVideoMethods.List | ||
17 | let listForApi: BlacklistedVideoMethods.ListForApi | 15 | let listForApi: BlacklistedVideoMethods.ListForApi |
18 | let loadById: BlacklistedVideoMethods.LoadById | ||
19 | let loadByVideoId: BlacklistedVideoMethods.LoadByVideoId | 16 | let loadByVideoId: BlacklistedVideoMethods.LoadByVideoId |
20 | 17 | ||
21 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { | 18 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { |
@@ -34,10 +31,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
34 | const classMethods = [ | 31 | const classMethods = [ |
35 | associate, | 32 | associate, |
36 | 33 | ||
37 | countTotal, | ||
38 | list, | ||
39 | listForApi, | 34 | listForApi, |
40 | loadById, | ||
41 | loadByVideoId | 35 | loadByVideoId |
42 | ] | 36 | ] |
43 | const instanceMethods = [ | 37 | const instanceMethods = [ |
@@ -83,14 +77,6 @@ function associate (models) { | |||
83 | }) | 77 | }) |
84 | } | 78 | } |
85 | 79 | ||
86 | countTotal = function () { | ||
87 | return BlacklistedVideo.count() | ||
88 | } | ||
89 | |||
90 | list = function () { | ||
91 | return BlacklistedVideo.findAll() | ||
92 | } | ||
93 | |||
94 | listForApi = function (start: number, count: number, sort: SortType) { | 80 | listForApi = function (start: number, count: number, sort: SortType) { |
95 | const query = { | 81 | const query = { |
96 | offset: start, | 82 | offset: start, |
@@ -107,10 +93,6 @@ listForApi = function (start: number, count: number, sort: SortType) { | |||
107 | }) | 93 | }) |
108 | } | 94 | } |
109 | 95 | ||
110 | loadById = function (id: number) { | ||
111 | return BlacklistedVideo.findById(id) | ||
112 | } | ||
113 | |||
114 | loadByVideoId = function (id: number) { | 96 | loadByVideoId = function (id: number) { |
115 | const query = { | 97 | const query = { |
116 | where: { | 98 | where: { |
diff --git a/server/models/video/video-channel-interface.ts b/server/models/video/video-channel-interface.ts index 8ad3e5cb7..b409d1db3 100644 --- a/server/models/video/video-channel-interface.ts +++ b/server/models/video/video-channel-interface.ts | |||
@@ -1,13 +1,11 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import * as Promise from 'bluebird' | 1 | import * as Promise from 'bluebird' |
2 | import * as Sequelize from 'sequelize' | ||
3 | 3 | ||
4 | import { ResultList } from '../../../shared' | 4 | import { ResultList } from '../../../shared' |
5 | 5 | import { VideoChannelObject } from '../../../shared/models/activitypub/objects/video-channel-object' | |
6 | // Don't use barrel, import just what we need | ||
7 | import { VideoChannel as FormattedVideoChannel } from '../../../shared/models/videos/video-channel.model' | 6 | import { VideoChannel as FormattedVideoChannel } from '../../../shared/models/videos/video-channel.model' |
8 | import { VideoInstance } from './video-interface' | ||
9 | import { AccountInstance } from '../account/account-interface' | 7 | import { AccountInstance } from '../account/account-interface' |
10 | import { VideoChannelObject } from '../../../shared/models/activitypub/objects/video-channel-object' | 8 | import { VideoInstance } from './video-interface' |
11 | 9 | ||
12 | export namespace VideoChannelMethods { | 10 | export namespace VideoChannelMethods { |
13 | export type ToFormattedJSON = (this: VideoChannelInstance) => FormattedVideoChannel | 11 | export type ToFormattedJSON = (this: VideoChannelInstance) => FormattedVideoChannel |
@@ -15,7 +13,6 @@ export namespace VideoChannelMethods { | |||
15 | export type IsOwned = (this: VideoChannelInstance) => boolean | 13 | export type IsOwned = (this: VideoChannelInstance) => boolean |
16 | 14 | ||
17 | export type CountByAccount = (accountId: number) => Promise<number> | 15 | export type CountByAccount = (accountId: number) => Promise<number> |
18 | export type ListOwned = () => Promise<VideoChannelInstance[]> | ||
19 | export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoChannelInstance> > | 16 | export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoChannelInstance> > |
20 | export type LoadByIdAndAccount = (id: number, accountId: number) => Promise<VideoChannelInstance> | 17 | export type LoadByIdAndAccount = (id: number, accountId: number) => Promise<VideoChannelInstance> |
21 | export type ListByAccount = (accountId: number) => Promise< ResultList<VideoChannelInstance> > | 18 | export type ListByAccount = (accountId: number) => Promise< ResultList<VideoChannelInstance> > |
@@ -32,10 +29,7 @@ export interface VideoChannelClass { | |||
32 | countByAccount: VideoChannelMethods.CountByAccount | 29 | countByAccount: VideoChannelMethods.CountByAccount |
33 | listForApi: VideoChannelMethods.ListForApi | 30 | listForApi: VideoChannelMethods.ListForApi |
34 | listByAccount: VideoChannelMethods.ListByAccount | 31 | listByAccount: VideoChannelMethods.ListByAccount |
35 | listOwned: VideoChannelMethods.ListOwned | ||
36 | loadByIdAndAccount: VideoChannelMethods.LoadByIdAndAccount | 32 | loadByIdAndAccount: VideoChannelMethods.LoadByIdAndAccount |
37 | loadByUUID: VideoChannelMethods.LoadByUUID | ||
38 | loadByHostAndUUID: VideoChannelMethods.LoadByHostAndUUID | ||
39 | loadAndPopulateAccount: VideoChannelMethods.LoadAndPopulateAccount | 33 | loadAndPopulateAccount: VideoChannelMethods.LoadAndPopulateAccount |
40 | loadByUUIDAndPopulateAccount: VideoChannelMethods.LoadByUUIDAndPopulateAccount | 34 | loadByUUIDAndPopulateAccount: VideoChannelMethods.LoadByUUIDAndPopulateAccount |
41 | loadAndPopulateAccountAndVideos: VideoChannelMethods.LoadAndPopulateAccountAndVideos | 35 | loadAndPopulateAccountAndVideos: VideoChannelMethods.LoadAndPopulateAccountAndVideos |
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 93566a5c6..64130310d 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -12,7 +12,6 @@ let toFormattedJSON: VideoChannelMethods.ToFormattedJSON | |||
12 | let toActivityPubObject: VideoChannelMethods.ToActivityPubObject | 12 | let toActivityPubObject: VideoChannelMethods.ToActivityPubObject |
13 | let isOwned: VideoChannelMethods.IsOwned | 13 | let isOwned: VideoChannelMethods.IsOwned |
14 | let countByAccount: VideoChannelMethods.CountByAccount | 14 | let countByAccount: VideoChannelMethods.CountByAccount |
15 | let listOwned: VideoChannelMethods.ListOwned | ||
16 | let listForApi: VideoChannelMethods.ListForApi | 15 | let listForApi: VideoChannelMethods.ListForApi |
17 | let listByAccount: VideoChannelMethods.ListByAccount | 16 | let listByAccount: VideoChannelMethods.ListByAccount |
18 | let loadByIdAndAccount: VideoChannelMethods.LoadByIdAndAccount | 17 | let loadByIdAndAccount: VideoChannelMethods.LoadByIdAndAccount |
@@ -88,7 +87,6 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
88 | 87 | ||
89 | listForApi, | 88 | listForApi, |
90 | listByAccount, | 89 | listByAccount, |
91 | listOwned, | ||
92 | loadByIdAndAccount, | 90 | loadByIdAndAccount, |
93 | loadAndPopulateAccount, | 91 | loadAndPopulateAccount, |
94 | loadByUUIDAndPopulateAccount, | 92 | loadByUUIDAndPopulateAccount, |
@@ -192,17 +190,6 @@ countByAccount = function (accountId: number) { | |||
192 | return VideoChannel.count(query) | 190 | return VideoChannel.count(query) |
193 | } | 191 | } |
194 | 192 | ||
195 | listOwned = function () { | ||
196 | const query = { | ||
197 | where: { | ||
198 | remote: false | ||
199 | }, | ||
200 | include: [ VideoChannel['sequelize'].models.Account ] | ||
201 | } | ||
202 | |||
203 | return VideoChannel.findAll(query) | ||
204 | } | ||
205 | |||
206 | listForApi = function (start: number, count: number, sort: string) { | 193 | listForApi = function (start: number, count: number, sort: string) { |
207 | const query = { | 194 | const query = { |
208 | offset: start, | 195 | offset: start, |
diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts index 89e528acf..be140de86 100644 --- a/server/models/video/video-interface.ts +++ b/server/models/video/video-interface.ts | |||
@@ -3,13 +3,12 @@ import * as Sequelize from 'sequelize' | |||
3 | import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object' | 3 | import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object' |
4 | import { ResultList } from '../../../shared/models/result-list.model' | 4 | import { ResultList } from '../../../shared/models/result-list.model' |
5 | import { Video as FormattedVideo, VideoDetails as FormattedDetailsVideo } from '../../../shared/models/videos/video.model' | 5 | import { Video as FormattedVideo, VideoDetails as FormattedDetailsVideo } from '../../../shared/models/videos/video.model' |
6 | import { AccountVideoRateInstance } from '../account/account-video-rate-interface' | ||
6 | 7 | ||
7 | import { TagAttributes, TagInstance } from './tag-interface' | 8 | import { TagAttributes, TagInstance } from './tag-interface' |
8 | import { VideoChannelInstance } from './video-channel-interface' | 9 | import { VideoChannelInstance } from './video-channel-interface' |
9 | import { VideoFileAttributes, VideoFileInstance } from './video-file-interface' | 10 | import { VideoFileAttributes, VideoFileInstance } from './video-file-interface' |
10 | import { VideoShareInstance } from './video-share-interface' | 11 | import { VideoShareInstance } from './video-share-interface' |
11 | import { UserVideoRate } from '../../../shared/models/videos/user-video-rate.model' | ||
12 | import { AccountVideoRateInstance } from '../account/account-video-rate-interface' | ||
13 | 12 | ||
14 | export namespace VideoMethods { | 13 | export namespace VideoMethods { |
15 | export type GetThumbnailName = (this: VideoInstance) => string | 14 | export type GetThumbnailName = (this: VideoInstance) => string |
@@ -40,12 +39,7 @@ export namespace VideoMethods { | |||
40 | export type GetLicenceLabel = (this: VideoInstance) => string | 39 | export type GetLicenceLabel = (this: VideoInstance) => string |
41 | export type GetLanguageLabel = (this: VideoInstance) => string | 40 | export type GetLanguageLabel = (this: VideoInstance) => string |
42 | 41 | ||
43 | // Return thumbnail name | ||
44 | export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string> | ||
45 | |||
46 | export type List = () => Bluebird<VideoInstance[]> | 42 | export type List = () => Bluebird<VideoInstance[]> |
47 | export type ListOwnedAndPopulateAccountAndTags = () => Bluebird<VideoInstance[]> | ||
48 | export type ListOwnedByAccount = (account: string) => Bluebird<VideoInstance[]> | ||
49 | 43 | ||
50 | export type ListAllAndSharedByAccountForOutbox = ( | 44 | export type ListAllAndSharedByAccountForOutbox = ( |
51 | accountId: number, | 45 | accountId: number, |
@@ -65,9 +59,6 @@ export namespace VideoMethods { | |||
65 | export type Load = (id: number) => Bluebird<VideoInstance> | 59 | export type Load = (id: number) => Bluebird<VideoInstance> |
66 | export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> | 60 | export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> |
67 | export type LoadByUrlAndPopulateAccount = (url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> | 61 | export type LoadByUrlAndPopulateAccount = (url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> |
68 | export type LoadLocalVideoByUUID = (uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> | ||
69 | export type LoadByHostAndUUID = (fromHost: string, uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> | ||
70 | export type LoadAndPopulateAccount = (id: number) => Bluebird<VideoInstance> | ||
71 | export type LoadAndPopulateAccountAndServerAndTags = (id: number) => Bluebird<VideoInstance> | 62 | export type LoadAndPopulateAccountAndServerAndTags = (id: number) => Bluebird<VideoInstance> |
72 | export type LoadByUUIDAndPopulateAccountAndServerAndTags = (uuid: string) => Bluebird<VideoInstance> | 63 | export type LoadByUUIDAndPopulateAccountAndServerAndTags = (uuid: string) => Bluebird<VideoInstance> |
73 | export type LoadByUUIDOrURL = (uuid: string, url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> | 64 | export type LoadByUUIDOrURL = (uuid: string, url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> |
@@ -79,21 +70,15 @@ export namespace VideoMethods { | |||
79 | } | 70 | } |
80 | 71 | ||
81 | export interface VideoClass { | 72 | export interface VideoClass { |
82 | generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData | ||
83 | list: VideoMethods.List | 73 | list: VideoMethods.List |
84 | listAllAndSharedByAccountForOutbox: VideoMethods.ListAllAndSharedByAccountForOutbox | 74 | listAllAndSharedByAccountForOutbox: VideoMethods.ListAllAndSharedByAccountForOutbox |
85 | listForApi: VideoMethods.ListForApi | 75 | listForApi: VideoMethods.ListForApi |
86 | listUserVideosForApi: VideoMethods.ListUserVideosForApi | 76 | listUserVideosForApi: VideoMethods.ListUserVideosForApi |
87 | listOwnedAndPopulateAccountAndTags: VideoMethods.ListOwnedAndPopulateAccountAndTags | ||
88 | listOwnedByAccount: VideoMethods.ListOwnedByAccount | ||
89 | load: VideoMethods.Load | 77 | load: VideoMethods.Load |
90 | loadAndPopulateAccount: VideoMethods.LoadAndPopulateAccount | ||
91 | loadAndPopulateAccountAndServerAndTags: VideoMethods.LoadAndPopulateAccountAndServerAndTags | 78 | loadAndPopulateAccountAndServerAndTags: VideoMethods.LoadAndPopulateAccountAndServerAndTags |
92 | loadByHostAndUUID: VideoMethods.LoadByHostAndUUID | ||
93 | loadByUUID: VideoMethods.LoadByUUID | 79 | loadByUUID: VideoMethods.LoadByUUID |
94 | loadByUrlAndPopulateAccount: VideoMethods.LoadByUrlAndPopulateAccount | 80 | loadByUrlAndPopulateAccount: VideoMethods.LoadByUrlAndPopulateAccount |
95 | loadByUUIDOrURL: VideoMethods.LoadByUUIDOrURL | 81 | loadByUUIDOrURL: VideoMethods.LoadByUUIDOrURL |
96 | loadLocalVideoByUUID: VideoMethods.LoadLocalVideoByUUID | ||
97 | loadByUUIDAndPopulateAccountAndServerAndTags: VideoMethods.LoadByUUIDAndPopulateAccountAndServerAndTags | 82 | loadByUUIDAndPopulateAccountAndServerAndTags: VideoMethods.LoadByUUIDAndPopulateAccountAndServerAndTags |
98 | searchAndPopulateAccountAndServerAndTags: VideoMethods.SearchAndPopulateAccountAndServerAndTags | 83 | searchAndPopulateAccountAndServerAndTags: VideoMethods.SearchAndPopulateAccountAndServerAndTags |
99 | } | 84 | } |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 592fc2d59..e5fd92549 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import * as Bluebird from 'bluebird' | ||
1 | import { map, maxBy, truncate } from 'lodash' | 2 | import { map, maxBy, truncate } from 'lodash' |
2 | import * as magnetUtil from 'magnet-uri' | 3 | import * as magnetUtil from 'magnet-uri' |
3 | import * as parseTorrent from 'parse-torrent' | 4 | import * as parseTorrent from 'parse-torrent' |
4 | import { join } from 'path' | 5 | import { join } from 'path' |
5 | import * as safeBuffer from 'safe-buffer' | ||
6 | import * as Sequelize from 'sequelize' | 6 | import * as Sequelize from 'sequelize' |
7 | import { VideoPrivacy, VideoResolution } from '../../../shared' | 7 | import { VideoPrivacy, VideoResolution } from '../../../shared' |
8 | import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object' | 8 | import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object' |
@@ -25,6 +25,7 @@ import { | |||
25 | unlinkPromise, | 25 | unlinkPromise, |
26 | writeFilePromise | 26 | writeFilePromise |
27 | } from '../../helpers' | 27 | } from '../../helpers' |
28 | import { activityPubCollection } from '../../helpers/activitypub' | ||
28 | import { isVideoUrlValid } from '../../helpers/custom-validators/videos' | 29 | import { isVideoUrlValid } from '../../helpers/custom-validators/videos' |
29 | import { | 30 | import { |
30 | API_VERSION, | 31 | API_VERSION, |
@@ -39,17 +40,13 @@ import { | |||
39 | VIDEO_LICENCES, | 40 | VIDEO_LICENCES, |
40 | VIDEO_PRIVACIES | 41 | VIDEO_PRIVACIES |
41 | } from '../../initializers' | 42 | } from '../../initializers' |
43 | import { sendDeleteVideo } from '../../lib/index' | ||
42 | 44 | ||
43 | import { addMethodsToModel, getSort } from '../utils' | 45 | import { addMethodsToModel, getSort } from '../utils' |
44 | 46 | ||
45 | import { TagInstance } from './tag-interface' | 47 | import { TagInstance } from './tag-interface' |
46 | import { VideoFileInstance, VideoFileModel } from './video-file-interface' | 48 | import { VideoFileInstance, VideoFileModel } from './video-file-interface' |
47 | import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface' | 49 | import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface' |
48 | import { sendDeleteVideo } from '../../lib/index' | ||
49 | import * as Bluebird from 'bluebird' | ||
50 | import { activityPubCollection } from '../../helpers/activitypub' | ||
51 | |||
52 | const Buffer = safeBuffer.Buffer | ||
53 | 50 | ||
54 | let Video: Sequelize.Model<VideoInstance, VideoAttributes> | 51 | let Video: Sequelize.Model<VideoInstance, VideoAttributes> |
55 | let getOriginalFile: VideoMethods.GetOriginalFile | 52 | let getOriginalFile: VideoMethods.GetOriginalFile |
@@ -77,20 +74,14 @@ let getCategoryLabel: VideoMethods.GetCategoryLabel | |||
77 | let getLicenceLabel: VideoMethods.GetLicenceLabel | 74 | let getLicenceLabel: VideoMethods.GetLicenceLabel |
78 | let getLanguageLabel: VideoMethods.GetLanguageLabel | 75 | let getLanguageLabel: VideoMethods.GetLanguageLabel |
79 | 76 | ||
80 | let generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData | ||
81 | let list: VideoMethods.List | 77 | let list: VideoMethods.List |
82 | let listForApi: VideoMethods.ListForApi | 78 | let listForApi: VideoMethods.ListForApi |
83 | let listAllAndSharedByAccountForOutbox: VideoMethods.ListAllAndSharedByAccountForOutbox | 79 | let listAllAndSharedByAccountForOutbox: VideoMethods.ListAllAndSharedByAccountForOutbox |
84 | let listUserVideosForApi: VideoMethods.ListUserVideosForApi | 80 | let listUserVideosForApi: VideoMethods.ListUserVideosForApi |
85 | let loadByHostAndUUID: VideoMethods.LoadByHostAndUUID | ||
86 | let listOwnedAndPopulateAccountAndTags: VideoMethods.ListOwnedAndPopulateAccountAndTags | ||
87 | let listOwnedByAccount: VideoMethods.ListOwnedByAccount | ||
88 | let load: VideoMethods.Load | 81 | let load: VideoMethods.Load |
89 | let loadByUrlAndPopulateAccount: VideoMethods.LoadByUrlAndPopulateAccount | 82 | let loadByUrlAndPopulateAccount: VideoMethods.LoadByUrlAndPopulateAccount |
90 | let loadByUUID: VideoMethods.LoadByUUID | 83 | let loadByUUID: VideoMethods.LoadByUUID |
91 | let loadByUUIDOrURL: VideoMethods.LoadByUUIDOrURL | 84 | let loadByUUIDOrURL: VideoMethods.LoadByUUIDOrURL |
92 | let loadLocalVideoByUUID: VideoMethods.LoadLocalVideoByUUID | ||
93 | let loadAndPopulateAccount: VideoMethods.LoadAndPopulateAccount | ||
94 | let loadAndPopulateAccountAndServerAndTags: VideoMethods.LoadAndPopulateAccountAndServerAndTags | 85 | let loadAndPopulateAccountAndServerAndTags: VideoMethods.LoadAndPopulateAccountAndServerAndTags |
95 | let loadByUUIDAndPopulateAccountAndServerAndTags: VideoMethods.LoadByUUIDAndPopulateAccountAndServerAndTags | 86 | let loadByUUIDAndPopulateAccountAndServerAndTags: VideoMethods.LoadByUUIDAndPopulateAccountAndServerAndTags |
96 | let searchAndPopulateAccountAndServerAndTags: VideoMethods.SearchAndPopulateAccountAndServerAndTags | 87 | let searchAndPopulateAccountAndServerAndTags: VideoMethods.SearchAndPopulateAccountAndServerAndTags |
@@ -267,21 +258,15 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
267 | const classMethods = [ | 258 | const classMethods = [ |
268 | associate, | 259 | associate, |
269 | 260 | ||
270 | generateThumbnailFromData, | ||
271 | list, | 261 | list, |
272 | listAllAndSharedByAccountForOutbox, | 262 | listAllAndSharedByAccountForOutbox, |
273 | listForApi, | 263 | listForApi, |
274 | listUserVideosForApi, | 264 | listUserVideosForApi, |
275 | listOwnedAndPopulateAccountAndTags, | ||
276 | listOwnedByAccount, | ||
277 | load, | 265 | load, |
278 | loadByUrlAndPopulateAccount, | 266 | loadByUrlAndPopulateAccount, |
279 | loadAndPopulateAccount, | ||
280 | loadAndPopulateAccountAndServerAndTags, | 267 | loadAndPopulateAccountAndServerAndTags, |
281 | loadByHostAndUUID, | ||
282 | loadByUUIDOrURL, | 268 | loadByUUIDOrURL, |
283 | loadByUUID, | 269 | loadByUUID, |
284 | loadLocalVideoByUUID, | ||
285 | loadByUUIDAndPopulateAccountAndServerAndTags, | 270 | loadByUUIDAndPopulateAccountAndServerAndTags, |
286 | searchAndPopulateAccountAndServerAndTags | 271 | searchAndPopulateAccountAndServerAndTags |
287 | ] | 272 | ] |
@@ -803,16 +788,6 @@ removeTorrent = function (this: VideoInstance, videoFile: VideoFileInstance) { | |||
803 | 788 | ||
804 | // ------------------------------ STATICS ------------------------------ | 789 | // ------------------------------ STATICS ------------------------------ |
805 | 790 | ||
806 | generateThumbnailFromData = function (video: VideoInstance, thumbnailData: string) { | ||
807 | // Creating the thumbnail for a remote video | ||
808 | |||
809 | const thumbnailName = video.getThumbnailName() | ||
810 | const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, thumbnailName) | ||
811 | return writeFilePromise(thumbnailPath, Buffer.from(thumbnailData, 'binary')).then(() => { | ||
812 | return thumbnailName | ||
813 | }) | ||
814 | } | ||
815 | |||
816 | list = function () { | 791 | list = function () { |
817 | const query = { | 792 | const query = { |
818 | include: [ Video['sequelize'].models.VideoFile ] | 793 | include: [ Video['sequelize'].models.VideoFile ] |
@@ -970,84 +945,6 @@ listForApi = function (start: number, count: number, sort: string) { | |||
970 | }) | 945 | }) |
971 | } | 946 | } |
972 | 947 | ||
973 | loadByHostAndUUID = function (fromHost: string, uuid: string, t?: Sequelize.Transaction) { | ||
974 | const query: Sequelize.FindOptions<VideoAttributes> = { | ||
975 | where: { | ||
976 | uuid | ||
977 | }, | ||
978 | include: [ | ||
979 | { | ||
980 | model: Video['sequelize'].models.VideoFile | ||
981 | }, | ||
982 | { | ||
983 | model: Video['sequelize'].models.VideoChannel, | ||
984 | include: [ | ||
985 | { | ||
986 | model: Video['sequelize'].models.Account, | ||
987 | include: [ | ||
988 | { | ||
989 | model: Video['sequelize'].models.Server, | ||
990 | required: true, | ||
991 | where: { | ||
992 | host: fromHost | ||
993 | } | ||
994 | } | ||
995 | ] | ||
996 | } | ||
997 | ] | ||
998 | } | ||
999 | ] | ||
1000 | } | ||
1001 | |||
1002 | if (t !== undefined) query.transaction = t | ||
1003 | |||
1004 | return Video.findOne(query) | ||
1005 | } | ||
1006 | |||
1007 | listOwnedAndPopulateAccountAndTags = function () { | ||
1008 | const query = { | ||
1009 | where: { | ||
1010 | remote: false | ||
1011 | }, | ||
1012 | include: [ | ||
1013 | Video['sequelize'].models.VideoFile, | ||
1014 | { | ||
1015 | model: Video['sequelize'].models.VideoChannel, | ||
1016 | include: [ Video['sequelize'].models.Account ] | ||
1017 | }, | ||
1018 | Video['sequelize'].models.Tag | ||
1019 | ] | ||
1020 | } | ||
1021 | |||
1022 | return Video.findAll(query) | ||
1023 | } | ||
1024 | |||
1025 | listOwnedByAccount = function (account: string) { | ||
1026 | const query = { | ||
1027 | where: { | ||
1028 | remote: false | ||
1029 | }, | ||
1030 | include: [ | ||
1031 | { | ||
1032 | model: Video['sequelize'].models.VideoFile | ||
1033 | }, | ||
1034 | { | ||
1035 | model: Video['sequelize'].models.VideoChannel, | ||
1036 | include: [ | ||
1037 | { | ||
1038 | model: Video['sequelize'].models.Account, | ||
1039 | where: { | ||
1040 | name: account | ||
1041 | } | ||
1042 | } | ||
1043 | ] | ||
1044 | } | ||
1045 | ] | ||
1046 | } | ||
1047 | |||
1048 | return Video.findAll(query) | ||
1049 | } | ||
1050 | |||
1051 | load = function (id: number) { | 948 | load = function (id: number) { |
1052 | return Video.findById(id) | 949 | return Video.findById(id) |
1053 | } | 950 | } |
@@ -1100,34 +997,6 @@ loadByUUIDOrURL = function (uuid: string, url: string, t?: Sequelize.Transaction | |||
1100 | return Video.findOne(query) | 997 | return Video.findOne(query) |
1101 | } | 998 | } |
1102 | 999 | ||
1103 | loadLocalVideoByUUID = function (uuid: string, t?: Sequelize.Transaction) { | ||
1104 | const query: Sequelize.FindOptions<VideoAttributes> = { | ||
1105 | where: { | ||
1106 | uuid, | ||
1107 | remote: false | ||
1108 | }, | ||
1109 | include: [ Video['sequelize'].models.VideoFile ] | ||
1110 | } | ||
1111 | |||
1112 | if (t !== undefined) query.transaction = t | ||
1113 | |||
1114 | return Video.findOne(query) | ||
1115 | } | ||
1116 | |||
1117 | loadAndPopulateAccount = function (id: number) { | ||
1118 | const options = { | ||
1119 | include: [ | ||
1120 | Video['sequelize'].models.VideoFile, | ||
1121 | { | ||
1122 | model: Video['sequelize'].models.VideoChannel, | ||
1123 | include: [ Video['sequelize'].models.Account ] | ||
1124 | } | ||
1125 | ] | ||
1126 | } | ||
1127 | |||
1128 | return Video.findById(id, options) | ||
1129 | } | ||
1130 | |||
1131 | loadAndPopulateAccountAndServerAndTags = function (id: number) { | 1000 | loadAndPopulateAccountAndServerAndTags = function (id: number) { |
1132 | const options = { | 1001 | const options = { |
1133 | include: [ | 1002 | include: [ |