aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video-channel.ts14
-rw-r--r--server/models/video/video.ts72
2 files changed, 40 insertions, 46 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index 93a611fa0..183ff3436 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -1,7 +1,6 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2 2
3import { isVideoChannelNameValid, isVideoChannelDescriptionValid } from '../../helpers' 3import { isVideoChannelNameValid, isVideoChannelDescriptionValid } from '../../helpers'
4import { removeVideoChannelToFriends } from '../../lib'
5 4
6import { addMethodsToModel, getSort } from '../utils' 5import { addMethodsToModel, getSort } from '../utils'
7import { 6import {
@@ -143,12 +142,13 @@ toFormattedJSON = function (this: VideoChannelInstance) {
143 142
144toActivityPubObject = function (this: VideoChannelInstance) { 143toActivityPubObject = function (this: VideoChannelInstance) {
145 const json = { 144 const json = {
145 type: 'VideoChannel' as 'VideoChannel',
146 id: this.url,
146 uuid: this.uuid, 147 uuid: this.uuid,
148 content: this.description,
147 name: this.name, 149 name: this.name,
148 description: this.description, 150 published: this.createdAt,
149 createdAt: this.createdAt, 151 updated: this.updatedAt
150 updatedAt: this.updatedAt,
151 ownerUUID: this.Account.uuid
152 } 152 }
153 153
154 return json 154 return json
@@ -180,7 +180,7 @@ function afterDestroy (videoChannel: VideoChannelInstance) {
180 uuid: videoChannel.uuid 180 uuid: videoChannel.uuid
181 } 181 }
182 182
183 return removeVideoChannelToFriends(removeVideoChannelToFriendsParams) 183 // FIXME: send remove event to followers
184 } 184 }
185 185
186 return undefined 186 return undefined
@@ -277,7 +277,7 @@ loadByUUIDOrUrl = function (uuid: string, url: string, t?: Sequelize.Transaction
277 { uuid }, 277 { uuid },
278 { url } 278 { url }
279 ] 279 ]
280 }, 280 }
281 } 281 }
282 282
283 if (t !== undefined) query.transaction = t 283 if (t !== undefined) query.transaction = t
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index b5d333347..10ae5097c 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1,58 +1,52 @@
1import * as safeBuffer from 'safe-buffer'
2const Buffer = safeBuffer.Buffer
3import * as magnetUtil from 'magnet-uri'
4import { map, maxBy, truncate } from 'lodash' 1import { map, maxBy, truncate } from 'lodash'
2import * as magnetUtil from 'magnet-uri'
5import * as parseTorrent from 'parse-torrent' 3import * as parseTorrent from 'parse-torrent'
6import { join } from 'path' 4import { join } from 'path'
5import * as safeBuffer from 'safe-buffer'
7import * as Sequelize from 'sequelize' 6import * as Sequelize from 'sequelize'
8 7import { VideoPrivacy, VideoResolution } from '../../../shared'
9import { TagInstance } from './tag-interface' 8import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object'
10import { 9import {
11 logger, 10 createTorrentPromise,
12 isVideoNameValid, 11 generateImageFromVideoFile,
12 getActivityPubUrl,
13 getVideoFileHeight,
13 isVideoCategoryValid, 14 isVideoCategoryValid,
14 isVideoLicenceValid,
15 isVideoLanguageValid,
16 isVideoNSFWValid,
17 isVideoDescriptionValid, 15 isVideoDescriptionValid,
18 isVideoDurationValid, 16 isVideoDurationValid,
17 isVideoLanguageValid,
18 isVideoLicenceValid,
19 isVideoNameValid,
20 isVideoNSFWValid,
19 isVideoPrivacyValid, 21 isVideoPrivacyValid,
20 readFileBufferPromise, 22 logger,
21 unlinkPromise,
22 renamePromise, 23 renamePromise,
23 writeFilePromise,
24 createTorrentPromise,
25 statPromise, 24 statPromise,
26 generateImageFromVideoFile,
27 transcode, 25 transcode,
28 getVideoFileHeight, 26 unlinkPromise,
29 getActivityPubUrl 27 writeFilePromise
30} from '../../helpers' 28} from '../../helpers'
31import { 29import {
30 API_VERSION,
32 CONFIG, 31 CONFIG,
32 CONSTRAINTS_FIELDS,
33 PREVIEWS_SIZE,
33 REMOTE_SCHEME, 34 REMOTE_SCHEME,
34 STATIC_PATHS, 35 STATIC_PATHS,
36 THUMBNAILS_SIZE,
35 VIDEO_CATEGORIES, 37 VIDEO_CATEGORIES,
36 VIDEO_LICENCES,
37 VIDEO_LANGUAGES, 38 VIDEO_LANGUAGES,
38 THUMBNAILS_SIZE, 39 VIDEO_LICENCES,
39 PREVIEWS_SIZE,
40 CONSTRAINTS_FIELDS,
41 API_VERSION,
42 VIDEO_PRIVACIES 40 VIDEO_PRIVACIES
43} from '../../initializers' 41} from '../../initializers'
44import { removeVideoToFriends } from '../../lib'
45import { VideoResolution, VideoPrivacy } from '../../../shared'
46import { VideoFileInstance, VideoFileModel } from './video-file-interface'
47 42
48import { addMethodsToModel, getSort } from '../utils' 43import { addMethodsToModel, getSort } from '../utils'
49import {
50 VideoInstance,
51 VideoAttributes,
52 44
53 VideoMethods 45import { TagInstance } from './tag-interface'
54} from './video-interface' 46import { VideoFileInstance, VideoFileModel } from './video-file-interface'
55import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object' 47import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface'
48
49const Buffer = safeBuffer.Buffer
56 50
57let Video: Sequelize.Model<VideoInstance, VideoAttributes> 51let Video: Sequelize.Model<VideoInstance, VideoAttributes>
58let getOriginalFile: VideoMethods.GetOriginalFile 52let getOriginalFile: VideoMethods.GetOriginalFile
@@ -374,8 +368,8 @@ function afterDestroy (video: VideoInstance) {
374 } 368 }
375 369
376 tasks.push( 370 tasks.push(
377 video.removePreview(), 371 video.removePreview()
378 removeVideoToFriends(removeVideoToFriendsParams) 372 // FIXME: remove video for followers
379 ) 373 )
380 374
381 // Remove physical files and torrents 375 // Remove physical files and torrents
@@ -566,7 +560,7 @@ toActivityPubObject = function (this: VideoInstance) {
566 const { baseUrlHttp, baseUrlWs } = getBaseUrls(this) 560 const { baseUrlHttp, baseUrlWs } = getBaseUrls(this)
567 561
568 const tag = this.Tags.map(t => ({ 562 const tag = this.Tags.map(t => ({
569 type: 'Hashtag', 563 type: 'Hashtag' as 'Hashtag',
570 name: t.name 564 name: t.name
571 })) 565 }))
572 566
@@ -596,7 +590,7 @@ toActivityPubObject = function (this: VideoInstance) {
596 } 590 }
597 591
598 const videoObject: VideoTorrentObject = { 592 const videoObject: VideoTorrentObject = {
599 type: 'Video', 593 type: 'Video' as 'Video',
600 id: getActivityPubUrl('video', this.uuid), 594 id: getActivityPubUrl('video', this.uuid),
601 name: this.name, 595 name: this.name,
602 // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration 596 // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
@@ -604,15 +598,15 @@ toActivityPubObject = function (this: VideoInstance) {
604 uuid: this.uuid, 598 uuid: this.uuid,
605 tag, 599 tag,
606 category: { 600 category: {
607 id: this.category, 601 identifier: this.category + '',
608 label: this.getCategoryLabel() 602 name: this.getCategoryLabel()
609 }, 603 },
610 licence: { 604 licence: {
611 id: this.licence, 605 identifier: this.licence + '',
612 name: this.getLicenceLabel() 606 name: this.getLicenceLabel()
613 }, 607 },
614 language: { 608 language: {
615 id: this.language, 609 identifier: this.language + '',
616 name: this.getLanguageLabel() 610 name: this.getLanguageLabel()
617 }, 611 },
618 views: this.views, 612 views: this.views,