ActivityPub-federated video streaming platform using P2P directly in your web browser
Merge branch 'develop' into pr/1285
Chocobozzzb718fd22374d
diff --cc client/src/app/shared/video-import/video-import.service.tsindex 11a7694c89,2163eb905e..7ae13154de--- 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 VideoImportServicensfw: 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.tsindex 9078bb5d28,18c62a1f92..c5d5bb406a--- 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 Videouuid?: stringid?: numberscheduleUpdate?: 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.idthis.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 updatediff --cc client/src/app/shared/video/video.service.tsindex 5d258891f8,565aad93b7..960846e21c--- 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 Vinsfw: 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.htmlindex 2cdbc7aa68,1875230d84..6e18ab6a69--- 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 @@@<span i18n class="video-attribute-label">Privacy</span><span class="video-attribute-value">{{ video.privacy.label }}</span></div>+- <div class="video-attribute">- <span i18n class="video-attribute-label">Originally published on</span>- <span *ngIf="!video.originallyPublishedAt" class="video-attribute-value">Unknown</span>- <span *ngIf="video.originallyPublishedAt" class="video-attribute-value">- {{ video.originallyPublishedAt | date: 'dd MMMM yyyy' }}- </span>++ <div *ngIf="!!video.originallyPublishedAt" class="video-attribute">++ <span i18n class="video-attribute-label">Originally published</span>++ <span class="video-attribute-value">{{ video.originallyPublishedAt | date: 'dd MMMM yyyy' }}</span>+ </div><div class="video-attribute"><span i18n class="video-attribute-label">Category</span>diff --cc client/src/app/videos/+video-watch/video-watch.component.scssindex f96ce8b8f9,b03ed197d3..cfe3533b66--- 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: 260pxmargin-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.tsindex b26dcabe17,76a318d13b..6ac13e6a44--- a/server/controllers/api/videos/index.ts+++ b/server/controllers/api/videos/index.ts@@@ -326,11 -327,7 +328,12 @@@ async function updateVideo (req: expresif (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.tsindex 4a88aef871,639493d737..3656a23f96--- 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.tsindex e02cca4800,0000000000..ab8d668541mode 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<void> {++ {+ 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.tsindex 194d12c6e5,d9626929c6..159727e285--- 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.tsindex 7a9513cbe5,76d0445d4b..c63285e25a--- a/server/models/video/video-format-utils.ts+++ b/server/models/video/video-format-utils.ts@@@ -264,10 -321,8 +322,11 @@@ function videoModelToActivityPubObjectwaitTranscoding: 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.tsindex 392bd10258,f153a1d00b..53631bf790--- a/shared/models/videos/video-create.model.ts+++ b/shared/models/videos/video-create.model.ts@@@ -13,7 -13,7 +13,8 @@@ export interface VideoCreatename: stringtags?: string[]commentsEnabled?: boolean+ downloadEnabled?: booleanprivacy: VideoPrivacyscheduleUpdate?: VideoScheduleUpdate+ originallyPublishedAt: Date | string}