diff options
author | Lucas Declercq <lucas.declercq@ineat-conseil.fr> | 2018-10-06 19:17:21 +0200 |
---|---|---|
committer | Lucas Declercq <lucas.declercq@ineat-conseil.fr> | 2018-10-06 19:17:39 +0200 |
commit | 156c50af3085468a47b8ae73fe8cfcae46b42398 (patch) | |
tree | f316355ebea2550c201a880cfc9f9b724bf0f7fd /server | |
parent | 35d50b7dd26b3cf646b8845784927bb1ef18dfb3 (diff) | |
download | PeerTube-156c50af3085468a47b8ae73fe8cfcae46b42398.tar.gz PeerTube-156c50af3085468a47b8ae73fe8cfcae46b42398.tar.zst PeerTube-156c50af3085468a47b8ae73fe8cfcae46b42398.zip |
Add downloadingEnabled property to video model
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/videos/import.ts | 1 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 2 | ||||
-rw-r--r-- | server/helpers/activitypub.ts | 1 | ||||
-rw-r--r-- | server/helpers/audit-logger.ts | 3 | ||||
-rw-r--r-- | server/helpers/custom-validators/activitypub/videos.ts | 1 | ||||
-rw-r--r-- | server/initializers/migrations/0280-video-downloading-enabled.ts | 27 | ||||
-rw-r--r-- | server/lib/activitypub/videos.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 4 | ||||
-rw-r--r-- | server/models/video/video-format-utils.ts | 2 | ||||
-rw-r--r-- | server/models/video/video.ts | 4 | ||||
-rw-r--r-- | server/tests/api/check-params/video-imports.ts | 1 | ||||
-rw-r--r-- | server/tests/api/check-params/videos.ts | 2 | ||||
-rw-r--r-- | server/tests/api/server/follows.ts | 1 | ||||
-rw-r--r-- | server/tests/api/server/handle-down.ts | 1 | ||||
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 6 | ||||
-rw-r--r-- | server/tests/api/videos/single-server.ts | 3 | ||||
-rw-r--r-- | server/tests/utils/videos/videos.ts | 6 | ||||
-rw-r--r-- | server/tools/peertube-import-videos.ts | 1 | ||||
-rw-r--r-- | server/tools/peertube-upload.ts | 2 |
19 files changed, 69 insertions, 1 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 398fd5a7f..a5cddba89 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -171,6 +171,7 @@ function buildVideo (channelId: number, body: VideoImportCreate, importData: You | |||
171 | licence: body.licence || importData.licence, | 171 | licence: body.licence || importData.licence, |
172 | language: body.language || undefined, | 172 | language: body.language || undefined, |
173 | commentsEnabled: body.commentsEnabled || true, | 173 | commentsEnabled: body.commentsEnabled || true, |
174 | downloadingEnabled: body.downloadingEnabled || true, | ||
174 | waitTranscoding: body.waitTranscoding || false, | 175 | waitTranscoding: body.waitTranscoding || false, |
175 | state: VideoState.TO_IMPORT, | 176 | state: VideoState.TO_IMPORT, |
176 | nsfw: body.nsfw || importData.nsfw || false, | 177 | nsfw: body.nsfw || importData.nsfw || false, |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 6a73e13d0..ec25006e8 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -179,6 +179,7 @@ async function addVideo (req: express.Request, res: express.Response) { | |||
179 | licence: videoInfo.licence, | 179 | licence: videoInfo.licence, |
180 | language: videoInfo.language, | 180 | language: videoInfo.language, |
181 | commentsEnabled: videoInfo.commentsEnabled || false, | 181 | commentsEnabled: videoInfo.commentsEnabled || false, |
182 | downloadingEnabled: videoInfo.downloadingEnabled || false, | ||
182 | waitTranscoding: videoInfo.waitTranscoding || false, | 183 | waitTranscoding: videoInfo.waitTranscoding || false, |
183 | state: CONFIG.TRANSCODING.ENABLED ? VideoState.TO_TRANSCODE : VideoState.PUBLISHED, | 184 | state: CONFIG.TRANSCODING.ENABLED ? VideoState.TO_TRANSCODE : VideoState.PUBLISHED, |
184 | nsfw: videoInfo.nsfw || false, | 185 | nsfw: videoInfo.nsfw || false, |
@@ -322,6 +323,7 @@ async function updateVideo (req: express.Request, res: express.Response) { | |||
322 | if (videoInfoToUpdate.support !== undefined) videoInstance.set('support', videoInfoToUpdate.support) | 323 | if (videoInfoToUpdate.support !== undefined) videoInstance.set('support', videoInfoToUpdate.support) |
323 | if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description) | 324 | if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description) |
324 | if (videoInfoToUpdate.commentsEnabled !== undefined) videoInstance.set('commentsEnabled', videoInfoToUpdate.commentsEnabled) | 325 | if (videoInfoToUpdate.commentsEnabled !== undefined) videoInstance.set('commentsEnabled', videoInfoToUpdate.commentsEnabled) |
326 | if (videoInfoToUpdate.downloadingEnabled !== undefined) videoInstance.set('downloadingEnabled', videoInfoToUpdate.downloadingEnabled) | ||
325 | if (videoInfoToUpdate.privacy !== undefined) { | 327 | if (videoInfoToUpdate.privacy !== undefined) { |
326 | const newPrivacy = parseInt(videoInfoToUpdate.privacy.toString(), 10) | 328 | const newPrivacy = parseInt(videoInfoToUpdate.privacy.toString(), 10) |
327 | videoInstance.set('privacy', newPrivacy) | 329 | videoInstance.set('privacy', newPrivacy) |
diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index 1304c7559..7f903e486 100644 --- a/server/helpers/activitypub.ts +++ b/server/helpers/activitypub.ts | |||
@@ -28,6 +28,7 @@ function activityPubContextify <T> (data: T) { | |||
28 | size: 'schema:Number', | 28 | size: 'schema:Number', |
29 | fps: 'schema:Number', | 29 | fps: 'schema:Number', |
30 | commentsEnabled: 'schema:Boolean', | 30 | commentsEnabled: 'schema:Boolean', |
31 | downloadingEnabled: 'schema:Boolean', | ||
31 | waitTranscoding: 'schema:Boolean', | 32 | waitTranscoding: 'schema:Boolean', |
32 | expires: 'schema:expires', | 33 | expires: 'schema:expires', |
33 | support: 'schema:Text', | 34 | support: 'schema:Text', |
diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts index 00311fce1..d2c9aee01 100644 --- a/server/helpers/audit-logger.ts +++ b/server/helpers/audit-logger.ts | |||
@@ -117,7 +117,8 @@ const videoKeysToKeep = [ | |||
117 | 'channel-uuid', | 117 | 'channel-uuid', |
118 | 'channel-name', | 118 | 'channel-name', |
119 | 'support', | 119 | 'support', |
120 | 'commentsEnabled' | 120 | 'commentsEnabled', |
121 | 'downloadingEnabled' | ||
121 | ] | 122 | ] |
122 | class VideoAuditView extends EntityAuditView { | 123 | class VideoAuditView extends EntityAuditView { |
123 | constructor (private video: VideoDetails) { | 124 | constructor (private video: VideoDetails) { |
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index f88d26561..34e4cdff9 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts | |||
@@ -67,6 +67,7 @@ function sanitizeAndCheckVideoTorrentObject (video: any) { | |||
67 | isVideoViewsValid(video.views) && | 67 | isVideoViewsValid(video.views) && |
68 | isBooleanValid(video.sensitive) && | 68 | isBooleanValid(video.sensitive) && |
69 | isBooleanValid(video.commentsEnabled) && | 69 | isBooleanValid(video.commentsEnabled) && |
70 | isBooleanValid(video.downloadingEnabled) && | ||
70 | isDateValid(video.published) && | 71 | isDateValid(video.published) && |
71 | isDateValid(video.updated) && | 72 | isDateValid(video.updated) && |
72 | (!video.content || isRemoteVideoContentValid(video.mediaType, video.content)) && | 73 | (!video.content || isRemoteVideoContentValid(video.mediaType, video.content)) && |
diff --git a/server/initializers/migrations/0280-video-downloading-enabled.ts b/server/initializers/migrations/0280-video-downloading-enabled.ts new file mode 100644 index 000000000..c0700108c --- /dev/null +++ b/server/initializers/migrations/0280-video-downloading-enabled.ts | |||
@@ -0,0 +1,27 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { Migration } from '../../models/migrations' | ||
3 | |||
4 | async function up (utils: { | ||
5 | transaction: Sequelize.Transaction, | ||
6 | queryInterface: Sequelize.QueryInterface, | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | }): Promise<void> { | ||
9 | const data = { | ||
10 | type: Sequelize.BOOLEAN, | ||
11 | allowNull: false, | ||
12 | defaultValue: true | ||
13 | } as Migration.Boolean | ||
14 | await utils.queryInterface.addColumn('video', 'downloadingEnabled', data) | ||
15 | |||
16 | data.defaultValue = null | ||
17 | return utils.queryInterface.changeColumn('video', 'downloadingEnabled', data) | ||
18 | } | ||
19 | |||
20 | function down (options) { | ||
21 | throw new Error('Not implemented.') | ||
22 | } | ||
23 | |||
24 | export { | ||
25 | up, | ||
26 | down | ||
27 | } | ||
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 54cea542f..dd02141ee 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -230,6 +230,7 @@ async function updateVideoFromAP (options: { | |||
230 | options.video.set('support', videoData.support) | 230 | options.video.set('support', videoData.support) |
231 | options.video.set('nsfw', videoData.nsfw) | 231 | options.video.set('nsfw', videoData.nsfw) |
232 | options.video.set('commentsEnabled', videoData.commentsEnabled) | 232 | options.video.set('commentsEnabled', videoData.commentsEnabled) |
233 | options.video.set('downloadingEnabled', videoData.downloadingEnabled) | ||
233 | options.video.set('waitTranscoding', videoData.waitTranscoding) | 234 | options.video.set('waitTranscoding', videoData.waitTranscoding) |
234 | options.video.set('state', videoData.state) | 235 | options.video.set('state', videoData.state) |
235 | options.video.set('duration', videoData.duration) | 236 | options.video.set('duration', videoData.duration) |
@@ -441,6 +442,7 @@ async function videoActivityObjectToDBAttributes ( | |||
441 | support, | 442 | support, |
442 | nsfw: videoObject.sensitive, | 443 | nsfw: videoObject.sensitive, |
443 | commentsEnabled: videoObject.commentsEnabled, | 444 | commentsEnabled: videoObject.commentsEnabled, |
445 | downloadingEnabled: videoObject.downloadingEnabled, | ||
444 | waitTranscoding: videoObject.waitTranscoding, | 446 | waitTranscoding: videoObject.waitTranscoding, |
445 | state: videoObject.state, | 447 | state: videoObject.state, |
446 | channelId: videoChannel.id, | 448 | channelId: videoChannel.id, |
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index d6b8aa725..bdba87496 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -349,6 +349,10 @@ function getCommonVideoAttributes () { | |||
349 | .optional() | 349 | .optional() |
350 | .toBoolean() | 350 | .toBoolean() |
351 | .custom(isBooleanValid).withMessage('Should have comments enabled boolean'), | 351 | .custom(isBooleanValid).withMessage('Should have comments enabled boolean'), |
352 | body('downloadingEnabled') | ||
353 | .optional() | ||
354 | .toBoolean() | ||
355 | .custom(isBooleanValid).withMessage('Should have downloading enabled boolean'), | ||
352 | 356 | ||
353 | body('scheduleUpdate') | 357 | body('scheduleUpdate') |
354 | .optional() | 358 | .optional() |
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index 905e84449..0b0da4181 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts | |||
@@ -128,6 +128,7 @@ function videoModelToFormattedDetailsJSON (video: VideoModel): VideoDetails { | |||
128 | account: video.VideoChannel.Account.toFormattedJSON(), | 128 | account: video.VideoChannel.Account.toFormattedJSON(), |
129 | tags, | 129 | tags, |
130 | commentsEnabled: video.commentsEnabled, | 130 | commentsEnabled: video.commentsEnabled, |
131 | downloadingEnabled: video.downloadingEnabled, | ||
131 | waitTranscoding: video.waitTranscoding, | 132 | waitTranscoding: video.waitTranscoding, |
132 | state: { | 133 | state: { |
133 | id: video.state, | 134 | id: video.state, |
@@ -259,6 +260,7 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject { | |||
259 | waitTranscoding: video.waitTranscoding, | 260 | waitTranscoding: video.waitTranscoding, |
260 | state: video.state, | 261 | state: video.state, |
261 | commentsEnabled: video.commentsEnabled, | 262 | commentsEnabled: video.commentsEnabled, |
263 | downloadingEnabled: video.downloadingEnabled, | ||
262 | published: video.publishedAt.toISOString(), | 264 | published: video.publishedAt.toISOString(), |
263 | updated: video.updatedAt.toISOString(), | 265 | updated: video.updatedAt.toISOString(), |
264 | mediaType: 'text/markdown', | 266 | mediaType: 'text/markdown', |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 46d823240..a2fe53fb9 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -600,6 +600,10 @@ export class VideoModel extends Model<VideoModel> { | |||
600 | 600 | ||
601 | @AllowNull(false) | 601 | @AllowNull(false) |
602 | @Column | 602 | @Column |
603 | downloadingEnabled: boolean | ||
604 | |||
605 | @AllowNull(false) | ||
606 | @Column | ||
603 | waitTranscoding: boolean | 607 | waitTranscoding: boolean |
604 | 608 | ||
605 | @AllowNull(false) | 609 | @AllowNull(false) |
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index 44645b0e2..8dd87b8ae 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts | |||
@@ -84,6 +84,7 @@ describe('Test video imports API validator', function () { | |||
84 | language: 'pt', | 84 | language: 'pt', |
85 | nsfw: false, | 85 | nsfw: false, |
86 | commentsEnabled: true, | 86 | commentsEnabled: true, |
87 | downloadingEnabled: true, | ||
87 | waitTranscoding: true, | 88 | waitTranscoding: true, |
88 | description: 'my super description', | 89 | description: 'my super description', |
89 | support: 'my super support text', | 90 | support: 'my super support text', |
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 904d22870..c5740087c 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -175,6 +175,7 @@ describe('Test videos API validator', function () { | |||
175 | language: 'pt', | 175 | language: 'pt', |
176 | nsfw: false, | 176 | nsfw: false, |
177 | commentsEnabled: true, | 177 | commentsEnabled: true, |
178 | downloadingEnabled: true, | ||
178 | waitTranscoding: true, | 179 | waitTranscoding: true, |
179 | description: 'my super description', | 180 | description: 'my super description', |
180 | support: 'my super support text', | 181 | support: 'my super support text', |
@@ -419,6 +420,7 @@ describe('Test videos API validator', function () { | |||
419 | language: 'pt', | 420 | language: 'pt', |
420 | nsfw: false, | 421 | nsfw: false, |
421 | commentsEnabled: false, | 422 | commentsEnabled: false, |
423 | downloadingEnabled: false, | ||
422 | description: 'my super description', | 424 | description: 'my super description', |
423 | privacy: VideoPrivacy.PUBLIC, | 425 | privacy: VideoPrivacy.PUBLIC, |
424 | tags: [ 'tag1', 'tag2' ] | 426 | tags: [ 'tag1', 'tag2' ] |
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index 310c291bf..5cad1d09d 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts | |||
@@ -305,6 +305,7 @@ describe('Test follows', function () { | |||
305 | }, | 305 | }, |
306 | isLocal, | 306 | isLocal, |
307 | commentsEnabled: true, | 307 | commentsEnabled: true, |
308 | downloadingEnabled: true, | ||
308 | duration: 5, | 309 | duration: 5, |
309 | tags: [ 'tag1', 'tag2', 'tag3' ], | 310 | tags: [ 'tag1', 'tag2', 'tag3' ], |
310 | privacy: VideoPrivacy.PUBLIC, | 311 | privacy: VideoPrivacy.PUBLIC, |
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index ed15c8090..971de4607 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts | |||
@@ -70,6 +70,7 @@ describe('Test handle downs', function () { | |||
70 | tags: [ 'tag1p1', 'tag2p1' ], | 70 | tags: [ 'tag1p1', 'tag2p1' ], |
71 | privacy: VideoPrivacy.PUBLIC, | 71 | privacy: VideoPrivacy.PUBLIC, |
72 | commentsEnabled: true, | 72 | commentsEnabled: true, |
73 | downloadingEnabled: true, | ||
73 | channel: { | 74 | channel: { |
74 | name: 'root_channel', | 75 | name: 'root_channel', |
75 | displayName: 'Main root channel', | 76 | displayName: 'Main root channel', |
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 4553ee855..83e391ccd 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -127,6 +127,7 @@ describe('Test multiple servers', function () { | |||
127 | tags: [ 'tag1p1', 'tag2p1' ], | 127 | tags: [ 'tag1p1', 'tag2p1' ], |
128 | privacy: VideoPrivacy.PUBLIC, | 128 | privacy: VideoPrivacy.PUBLIC, |
129 | commentsEnabled: true, | 129 | commentsEnabled: true, |
130 | downloadingEnabled: true, | ||
130 | channel: { | 131 | channel: { |
131 | displayName: 'my channel', | 132 | displayName: 'my channel', |
132 | name: 'super_channel_name', | 133 | name: 'super_channel_name', |
@@ -198,6 +199,7 @@ describe('Test multiple servers', function () { | |||
198 | }, | 199 | }, |
199 | isLocal, | 200 | isLocal, |
200 | commentsEnabled: true, | 201 | commentsEnabled: true, |
202 | downloadingEnabled: true, | ||
201 | duration: 5, | 203 | duration: 5, |
202 | tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], | 204 | tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], |
203 | privacy: VideoPrivacy.PUBLIC, | 205 | privacy: VideoPrivacy.PUBLIC, |
@@ -306,6 +308,7 @@ describe('Test multiple servers', function () { | |||
306 | isLocal, | 308 | isLocal, |
307 | duration: 5, | 309 | duration: 5, |
308 | commentsEnabled: true, | 310 | commentsEnabled: true, |
311 | downloadingEnabled: true, | ||
309 | tags: [ 'tag1p3' ], | 312 | tags: [ 'tag1p3' ], |
310 | privacy: VideoPrivacy.PUBLIC, | 313 | privacy: VideoPrivacy.PUBLIC, |
311 | channel: { | 314 | channel: { |
@@ -337,6 +340,7 @@ describe('Test multiple servers', function () { | |||
337 | host: 'localhost:9003' | 340 | host: 'localhost:9003' |
338 | }, | 341 | }, |
339 | commentsEnabled: true, | 342 | commentsEnabled: true, |
343 | downloadingEnabled: true, | ||
340 | isLocal, | 344 | isLocal, |
341 | duration: 5, | 345 | duration: 5, |
342 | tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], | 346 | tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], |
@@ -654,6 +658,7 @@ describe('Test multiple servers', function () { | |||
654 | isLocal, | 658 | isLocal, |
655 | duration: 5, | 659 | duration: 5, |
656 | commentsEnabled: true, | 660 | commentsEnabled: true, |
661 | downloadingEnabled: true, | ||
657 | tags: [ 'tag_up_1', 'tag_up_2' ], | 662 | tags: [ 'tag_up_1', 'tag_up_2' ], |
658 | privacy: VideoPrivacy.PUBLIC, | 663 | privacy: VideoPrivacy.PUBLIC, |
659 | channel: { | 664 | channel: { |
@@ -975,6 +980,7 @@ describe('Test multiple servers', function () { | |||
975 | isLocal, | 980 | isLocal, |
976 | duration: 5, | 981 | duration: 5, |
977 | commentsEnabled: false, | 982 | commentsEnabled: false, |
983 | downloadingEnabled: false, | ||
978 | tags: [ ], | 984 | tags: [ ], |
979 | privacy: VideoPrivacy.PUBLIC, | 985 | privacy: VideoPrivacy.PUBLIC, |
980 | channel: { | 986 | channel: { |
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index e3d62b7a0..8995a8525 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -55,6 +55,7 @@ describe('Test a single server', function () { | |||
55 | tags: [ 'tag1', 'tag2', 'tag3' ], | 55 | tags: [ 'tag1', 'tag2', 'tag3' ], |
56 | privacy: VideoPrivacy.PUBLIC, | 56 | privacy: VideoPrivacy.PUBLIC, |
57 | commentsEnabled: true, | 57 | commentsEnabled: true, |
58 | downloadingEnabled: true, | ||
58 | channel: { | 59 | channel: { |
59 | displayName: 'Main root channel', | 60 | displayName: 'Main root channel', |
60 | name: 'root_channel', | 61 | name: 'root_channel', |
@@ -87,6 +88,7 @@ describe('Test a single server', function () { | |||
87 | privacy: VideoPrivacy.PUBLIC, | 88 | privacy: VideoPrivacy.PUBLIC, |
88 | duration: 5, | 89 | duration: 5, |
89 | commentsEnabled: false, | 90 | commentsEnabled: false, |
91 | downloadingEnabled: false, | ||
90 | channel: { | 92 | channel: { |
91 | name: 'root_channel', | 93 | name: 'root_channel', |
92 | displayName: 'Main root channel', | 94 | displayName: 'Main root channel', |
@@ -356,6 +358,7 @@ describe('Test a single server', function () { | |||
356 | nsfw: false, | 358 | nsfw: false, |
357 | description: 'my super description updated', | 359 | description: 'my super description updated', |
358 | commentsEnabled: false, | 360 | commentsEnabled: false, |
361 | downloadingEnabled: false, | ||
359 | tags: [ 'tagup1', 'tagup2' ] | 362 | tags: [ 'tagup1', 'tagup2' ] |
360 | } | 363 | } |
361 | await updateVideo(server.url, server.accessToken, videoId, attributes) | 364 | await updateVideo(server.url, server.accessToken, videoId, attributes) |
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 87c385f38..a7fd4c8a6 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts | |||
@@ -27,6 +27,7 @@ type VideoAttributes = { | |||
27 | language?: string | 27 | language?: string |
28 | nsfw?: boolean | 28 | nsfw?: boolean |
29 | commentsEnabled?: boolean | 29 | commentsEnabled?: boolean |
30 | downloadingEnabled?: boolean | ||
30 | waitTranscoding?: boolean | 31 | waitTranscoding?: boolean |
31 | description?: string | 32 | description?: string |
32 | tags?: string[] | 33 | tags?: string[] |
@@ -310,6 +311,7 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg | |||
310 | tags: [ 'tag' ], | 311 | tags: [ 'tag' ], |
311 | privacy: VideoPrivacy.PUBLIC, | 312 | privacy: VideoPrivacy.PUBLIC, |
312 | commentsEnabled: true, | 313 | commentsEnabled: true, |
314 | downloadingEnabled: true, | ||
313 | fixture: 'video_short.webm' | 315 | fixture: 'video_short.webm' |
314 | }, videoAttributesArg) | 316 | }, videoAttributesArg) |
315 | 317 | ||
@@ -320,6 +322,7 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg | |||
320 | .field('name', attributes.name) | 322 | .field('name', attributes.name) |
321 | .field('nsfw', JSON.stringify(attributes.nsfw)) | 323 | .field('nsfw', JSON.stringify(attributes.nsfw)) |
322 | .field('commentsEnabled', JSON.stringify(attributes.commentsEnabled)) | 324 | .field('commentsEnabled', JSON.stringify(attributes.commentsEnabled)) |
325 | .field('downloadingEnabled', JSON.stringify(attributes.downloadingEnabled)) | ||
323 | .field('waitTranscoding', JSON.stringify(attributes.waitTranscoding)) | 326 | .field('waitTranscoding', JSON.stringify(attributes.waitTranscoding)) |
324 | .field('privacy', attributes.privacy.toString()) | 327 | .field('privacy', attributes.privacy.toString()) |
325 | .field('channelId', attributes.channelId) | 328 | .field('channelId', attributes.channelId) |
@@ -370,6 +373,7 @@ function updateVideo (url: string, accessToken: string, id: number | string, att | |||
370 | if (attributes.language) body['language'] = attributes.language | 373 | if (attributes.language) body['language'] = attributes.language |
371 | if (attributes.nsfw !== undefined) body['nsfw'] = JSON.stringify(attributes.nsfw) | 374 | if (attributes.nsfw !== undefined) body['nsfw'] = JSON.stringify(attributes.nsfw) |
372 | if (attributes.commentsEnabled !== undefined) body['commentsEnabled'] = JSON.stringify(attributes.commentsEnabled) | 375 | if (attributes.commentsEnabled !== undefined) body['commentsEnabled'] = JSON.stringify(attributes.commentsEnabled) |
376 | if (attributes.downloadingEnabled !== undefined) body['downloadingEnabled'] = JSON.stringify(attributes.downloadingEnabled) | ||
373 | if (attributes.description) body['description'] = attributes.description | 377 | if (attributes.description) body['description'] = attributes.description |
374 | if (attributes.tags) body['tags'] = attributes.tags | 378 | if (attributes.tags) body['tags'] = attributes.tags |
375 | if (attributes.privacy) body['privacy'] = attributes.privacy | 379 | if (attributes.privacy) body['privacy'] = attributes.privacy |
@@ -435,6 +439,7 @@ async function completeVideoCheck ( | |||
435 | language: string | 439 | language: string |
436 | nsfw: boolean | 440 | nsfw: boolean |
437 | commentsEnabled: boolean | 441 | commentsEnabled: boolean |
442 | downloadingEnabled: boolean | ||
438 | description: string | 443 | description: string |
439 | publishedAt?: string | 444 | publishedAt?: string |
440 | support: string | 445 | support: string |
@@ -509,6 +514,7 @@ async function completeVideoCheck ( | |||
509 | expect(dateIsValid(videoDetails.channel.createdAt.toString())).to.be.true | 514 | expect(dateIsValid(videoDetails.channel.createdAt.toString())).to.be.true |
510 | expect(dateIsValid(videoDetails.channel.updatedAt.toString())).to.be.true | 515 | expect(dateIsValid(videoDetails.channel.updatedAt.toString())).to.be.true |
511 | expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled) | 516 | expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled) |
517 | expect(videoDetails.downloadingEnabled).to.equal(attributes.downloadingEnabled) | ||
512 | 518 | ||
513 | for (const attributeFile of attributes.files) { | 519 | for (const attributeFile of attributes.files) { |
514 | const file = videoDetails.files.find(f => f.resolution.id === attributeFile.resolution) | 520 | const file = videoDetails.files.find(f => f.resolution.id === attributeFile.resolution) |
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 13090a028..675c621df 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts | |||
@@ -212,6 +212,7 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string, cwd: st | |||
212 | nsfw: isNSFW(videoInfo), | 212 | nsfw: isNSFW(videoInfo), |
213 | waitTranscoding: true, | 213 | waitTranscoding: true, |
214 | commentsEnabled: true, | 214 | commentsEnabled: true, |
215 | downloadingEnabled: true, | ||
215 | description: videoInfo.description || undefined, | 216 | description: videoInfo.description || undefined, |
216 | support: undefined, | 217 | support: undefined, |
217 | tags, | 218 | tags, |
diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts index 6248fb47d..e7b885a38 100644 --- a/server/tools/peertube-upload.ts +++ b/server/tools/peertube-upload.ts | |||
@@ -30,6 +30,7 @@ if (!program['tags']) program['tags'] = [] | |||
30 | if (!program['nsfw']) program['nsfw'] = false | 30 | if (!program['nsfw']) program['nsfw'] = false |
31 | if (!program['privacy']) program['privacy'] = VideoPrivacy.PUBLIC | 31 | if (!program['privacy']) program['privacy'] = VideoPrivacy.PUBLIC |
32 | if (!program['commentsEnabled']) program['commentsEnabled'] = false | 32 | if (!program['commentsEnabled']) program['commentsEnabled'] = false |
33 | if (!program['downloadingEnabled']) program['downloadingEnabled'] = false | ||
33 | 34 | ||
34 | getSettings() | 35 | getSettings() |
35 | .then(settings => { | 36 | .then(settings => { |
@@ -116,6 +117,7 @@ async function run () { | |||
116 | description: program['videoDescription'], | 117 | description: program['videoDescription'], |
117 | tags: program['tags'], | 118 | tags: program['tags'], |
118 | commentsEnabled: program['commentsEnabled'], | 119 | commentsEnabled: program['commentsEnabled'], |
120 | downloadingEnabled: program['downloadingEnabled'], | ||
119 | fixture: program['file'], | 121 | fixture: program['file'], |
120 | thumbnailfile: program['thumbnail'], | 122 | thumbnailfile: program['thumbnail'], |
121 | previewfile: program['preview'], | 123 | previewfile: program['preview'], |