From: Chocobozzz Date: Mon, 11 Feb 2019 13:09:23 +0000 (+0100) Subject: Merge branch 'develop' into pr/1285 X-Git-Tag: v1.3.0-rc.1~205 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=b718fd22374d64534bcfe69932cf562894abed6a;p=github%2FChocobozzz%2FPeerTube.git Merge branch 'develop' into pr/1285 --- b718fd22374d64534bcfe69932cf562894abed6a diff --cc client/src/app/shared/video-import/video-import.service.ts index 11a7694c8,2163eb905..7ae13154d --- a/client/src/app/shared/video-import/video-import.service.ts +++ b/client/src/app/shared/video-import/video-import.service.ts @@@ -82,10 -81,10 +82,11 @@@ export class VideoImportService nsfw: video.nsfw, waitTranscoding: video.waitTranscoding, commentsEnabled: video.commentsEnabled, + downloadEnabled: video.downloadEnabled, thumbnailfile: video.thumbnailfile, previewfile: video.previewfile, - scheduleUpdate + scheduleUpdate, + originallyPublishedAt } } diff --cc client/src/app/shared/video/video-edit.model.ts index 9078bb5d2,18c62a1f9..c5d5bb406 --- a/client/src/app/shared/video/video-edit.model.ts +++ b/client/src/app/shared/video/video-edit.model.ts @@@ -25,9 -26,16 +26,17 @@@ export class VideoEdit implements Video uuid?: string id?: number scheduleUpdate?: VideoScheduleUpdate + originallyPublishedAt?: Date | string - constructor (video?: Video & { tags: string[], commentsEnabled: boolean, support: string, thumbnailUrl: string, previewUrl: string }) { + constructor ( + video?: Video & { + tags: string[], + commentsEnabled: boolean, + downloadEnabled: boolean, + support: string, + thumbnailUrl: string, + previewUrl: string + }) { if (video) { this.id = video.id this.uuid = video.uuid @@@ -88,10 -90,10 +98,11 @@@ tags: this.tags, nsfw: this.nsfw, commentsEnabled: this.commentsEnabled, + downloadEnabled: this.downloadEnabled, waitTranscoding: this.waitTranscoding, channelId: this.channelId, - privacy: this.privacy + privacy: this.privacy, + originallyPublishedAt: this.originallyPublishedAt } // Special case if we scheduled an update diff --cc client/src/app/shared/video/video.service.ts index 5d258891f,565aad93b..960846e21 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts @@@ -96,10 -95,10 +96,11 @@@ export class VideoService implements Vi nsfw: video.nsfw, waitTranscoding: video.waitTranscoding, commentsEnabled: video.commentsEnabled, + downloadEnabled: video.downloadEnabled, thumbnailfile: video.thumbnailfile, previewfile: video.previewfile, - scheduleUpdate + scheduleUpdate, + originallyPublishedAt } const data = objectToFormData(body) diff --cc client/src/app/videos/+video-watch/video-watch.component.html index 2cdbc7aa6,1875230d8..6e18ab6a6 --- a/client/src/app/videos/+video-watch/video-watch.component.html +++ b/client/src/app/videos/+video-watch/video-watch.component.html @@@ -158,14 -161,6 +160,11 @@@ Privacy {{ video.privacy.label }} + -
- Originally published on - Unknown - - {{ video.originallyPublishedAt | date: 'dd MMMM yyyy' }} - ++
++ Originally published ++ {{ video.originallyPublishedAt | date: 'dd MMMM yyyy' }} +
Category diff --cc client/src/app/videos/+video-watch/video-watch.component.scss index f96ce8b8f,b03ed197d..cfe3533b6 --- a/client/src/app/videos/+video-watch/video-watch.component.scss +++ b/client/src/app/videos/+video-watch/video-watch.component.scss @@@ -336,10 -286,10 +286,10 @@@ $other-videos-width: 260px margin-bottom: 12px; .video-attribute-label { - min-width: 91px; + min-width: 142px; padding-right: 5px; display: inline-block; - color: #585858; + color: $grey-foreground-color; font-weight: $font-bold; } diff --cc server/controllers/api/videos/index.ts index b26dcabe1,76a318d13..6ac13e6a4 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@@ -326,11 -327,7 +328,12 @@@ async function updateVideo (req: expres if (videoInfoToUpdate.support !== undefined) videoInstance.set('support', videoInfoToUpdate.support) if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description) if (videoInfoToUpdate.commentsEnabled !== undefined) videoInstance.set('commentsEnabled', videoInfoToUpdate.commentsEnabled) - if (videoInfoToUpdate.originallyPublishedAt !== undefined && - videoInfoToUpdate.originallyPublishedAt !== null) { + if (videoInfoToUpdate.downloadEnabled !== undefined) videoInstance.set('downloadEnabled', videoInfoToUpdate.downloadEnabled) ++ ++ if (videoInfoToUpdate.originallyPublishedAt !== undefined && videoInfoToUpdate.originallyPublishedAt !== null) { + videoInstance.set('originallyPublishedAt', videoInfoToUpdate.originallyPublishedAt) + } + if (videoInfoToUpdate.privacy !== undefined) { const newPrivacy = parseInt(videoInfoToUpdate.privacy.toString(), 10) videoInstance.set('privacy', newPrivacy) diff --cc server/initializers/constants.ts index 4a88aef87,639493d73..3656a23f9 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@@ -16,7 -16,7 +16,7 @@@ let config: IConfig = require('config' // --------------------------------------------------------------------------- - const LAST_MIGRATION_VERSION = 315 -const LAST_MIGRATION_VERSION = 335 ++const LAST_MIGRATION_VERSION = 340 // --------------------------------------------------------------------------- diff --cc server/initializers/migrations/0340-add-originally-published-at.ts index e02cca480,000000000..ab8d66854 mode 100644,000000..100644 --- a/server/initializers/migrations/0340-add-originally-published-at.ts +++ b/server/initializers/migrations/0340-add-originally-published-at.ts @@@ -1,42 -1,0 +1,31 @@@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction, + queryInterface: Sequelize.QueryInterface, + sequelize: Sequelize.Sequelize +}): Promise { + + { + const data = { + type: Sequelize.DATE, + allowNull: true, + defaultValue: Sequelize.NOW + } + await utils.queryInterface.addColumn('video', 'originallyPublishedAt', data) + } + + { + const query = 'UPDATE video SET "originallyPublishedAt" = video."publishedAt"' + await utils.sequelize.query(query) + } - - // Sequelize does not alter the column with NOW as default value - { - const data = { - type: Sequelize.DATE, - allowNull: false, - defaultValue: Sequelize.NOW - } - await utils.queryInterface.changeColumn('video', 'originallyPublishedAt', data) - } - +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} diff --cc server/middlewares/validators/videos/videos.ts index 194d12c6e,d9626929c..159727e28 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts @@@ -341,11 -340,11 +341,14 @@@ function getCommonVideoAttributes () .optional() .toBoolean() .custom(isBooleanValid).withMessage('Should have comments enabled boolean'), - body('originallyPublishedAt') + body('downloadEnabled') .optional() - .customSanitizer(toValueOrNull) - .custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'), - + .toBoolean() + .custom(isBooleanValid).withMessage('Should have downloading enabled boolean'), - ++ body('originallyPublishedAt') ++ .optional() ++ .customSanitizer(toValueOrNull) ++ .custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'), body('scheduleUpdate') .optional() .customSanitizer(toValueOrNull), diff --cc server/models/video/video-format-utils.ts index 7a9513cbe,76d0445d4..c63285e25 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts @@@ -264,10 -321,8 +322,11 @@@ function videoModelToActivityPubObject waitTranscoding: video.waitTranscoding, state: video.state, commentsEnabled: video.commentsEnabled, + downloadEnabled: video.downloadEnabled, published: video.publishedAt.toISOString(), + originallyPublishedAt: video.originallyPublishedAt ? + video.originallyPublishedAt.toISOString() : + null, updated: video.updatedAt.toISOString(), mediaType: 'text/markdown', content: video.getTruncatedDescription(), diff --cc shared/models/videos/video-create.model.ts index 392bd1025,f153a1d00..53631bf79 --- a/shared/models/videos/video-create.model.ts +++ b/shared/models/videos/video-create.model.ts @@@ -13,7 -13,7 +13,8 @@@ export interface VideoCreate name: string tags?: string[] commentsEnabled?: boolean + downloadEnabled?: boolean privacy: VideoPrivacy scheduleUpdate?: VideoScheduleUpdate + originallyPublishedAt: Date | string }