diff options
20 files changed, 111 insertions, 10 deletions
diff --git a/client/src/app/shared/forms/form-validators/video-validators.service.ts b/client/src/app/shared/forms/form-validators/video-validators.service.ts index 81ed0666f..e3f7a0969 100644 --- a/client/src/app/shared/forms/form-validators/video-validators.service.ts +++ b/client/src/app/shared/forms/form-validators/video-validators.service.ts | |||
@@ -16,6 +16,7 @@ export class VideoValidatorsService { | |||
16 | readonly VIDEO_TAGS: BuildFormValidator | 16 | readonly VIDEO_TAGS: BuildFormValidator |
17 | readonly VIDEO_SUPPORT: BuildFormValidator | 17 | readonly VIDEO_SUPPORT: BuildFormValidator |
18 | readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator | 18 | readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator |
19 | readonly VIDEO_ORIGINALLY_PUBLISHED_AT: BuildFormValidator | ||
19 | 20 | ||
20 | constructor (private i18n: I18n) { | 21 | constructor (private i18n: I18n) { |
21 | 22 | ||
@@ -92,5 +93,10 @@ export class VideoValidatorsService { | |||
92 | 'required': this.i18n('A date is required to schedule video update.') | 93 | 'required': this.i18n('A date is required to schedule video update.') |
93 | } | 94 | } |
94 | } | 95 | } |
96 | |||
97 | this.VIDEO_ORIGINALLY_PUBLISHED_AT = { | ||
98 | VALIDATORS: [ ], | ||
99 | MESSAGES: {} | ||
100 | } | ||
95 | } | 101 | } |
96 | } | 102 | } |
diff --git a/client/src/app/shared/video-import/video-import.service.ts b/client/src/app/shared/video-import/video-import.service.ts index 2163eb905..7ae13154d 100644 --- a/client/src/app/shared/video-import/video-import.service.ts +++ b/client/src/app/shared/video-import/video-import.service.ts | |||
@@ -67,6 +67,7 @@ export class VideoImportService { | |||
67 | const description = video.description || null | 67 | const description = video.description || null |
68 | const support = video.support || null | 68 | const support = video.support || null |
69 | const scheduleUpdate = video.scheduleUpdate || null | 69 | const scheduleUpdate = video.scheduleUpdate || null |
70 | const originallyPublishedAt = video.originallyPublishedAt || null | ||
70 | 71 | ||
71 | return { | 72 | return { |
72 | name: video.name, | 73 | name: video.name, |
@@ -84,7 +85,8 @@ export class VideoImportService { | |||
84 | downloadEnabled: video.downloadEnabled, | 85 | downloadEnabled: video.downloadEnabled, |
85 | thumbnailfile: video.thumbnailfile, | 86 | thumbnailfile: video.thumbnailfile, |
86 | previewfile: video.previewfile, | 87 | previewfile: video.previewfile, |
87 | scheduleUpdate | 88 | scheduleUpdate, |
89 | originallyPublishedAt | ||
88 | } | 90 | } |
89 | } | 91 | } |
90 | 92 | ||
diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts index 18c62a1f9..c5d5bb406 100644 --- a/client/src/app/shared/video/video-edit.model.ts +++ b/client/src/app/shared/video/video-edit.model.ts | |||
@@ -26,6 +26,7 @@ export class VideoEdit implements VideoUpdate { | |||
26 | uuid?: string | 26 | uuid?: string |
27 | id?: number | 27 | id?: number |
28 | scheduleUpdate?: VideoScheduleUpdate | 28 | scheduleUpdate?: VideoScheduleUpdate |
29 | originallyPublishedAt?: Date | string | ||
29 | 30 | ||
30 | constructor ( | 31 | constructor ( |
31 | video?: Video & { | 32 | video?: Video & { |
@@ -56,6 +57,7 @@ export class VideoEdit implements VideoUpdate { | |||
56 | this.previewUrl = video.previewUrl | 57 | this.previewUrl = video.previewUrl |
57 | 58 | ||
58 | this.scheduleUpdate = video.scheduledUpdate | 59 | this.scheduleUpdate = video.scheduledUpdate |
60 | this.originallyPublishedAt = new Date(video.originallyPublishedAt) | ||
59 | } | 61 | } |
60 | } | 62 | } |
61 | 63 | ||
@@ -77,6 +79,12 @@ export class VideoEdit implements VideoUpdate { | |||
77 | } else { | 79 | } else { |
78 | this.scheduleUpdate = null | 80 | this.scheduleUpdate = null |
79 | } | 81 | } |
82 | |||
83 | // Convert originallyPublishedAt to string so that function objectToFormData() works correctly | ||
84 | if (this.originallyPublishedAt) { | ||
85 | const originallyPublishedAt = new Date(values['originallyPublishedAt']) | ||
86 | this.originallyPublishedAt = originallyPublishedAt.toISOString() | ||
87 | } | ||
80 | } | 88 | } |
81 | 89 | ||
82 | toFormPatch () { | 90 | toFormPatch () { |
@@ -93,7 +101,8 @@ export class VideoEdit implements VideoUpdate { | |||
93 | downloadEnabled: this.downloadEnabled, | 101 | downloadEnabled: this.downloadEnabled, |
94 | waitTranscoding: this.waitTranscoding, | 102 | waitTranscoding: this.waitTranscoding, |
95 | channelId: this.channelId, | 103 | channelId: this.channelId, |
96 | privacy: this.privacy | 104 | privacy: this.privacy, |
105 | originallyPublishedAt: this.originallyPublishedAt | ||
97 | } | 106 | } |
98 | 107 | ||
99 | // Special case if we scheduled an update | 108 | // Special case if we scheduled an update |
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts index 6ea83d13b..460c09258 100644 --- a/client/src/app/shared/video/video.model.ts +++ b/client/src/app/shared/video/video.model.ts | |||
@@ -17,6 +17,7 @@ export class Video implements VideoServerModel { | |||
17 | createdAt: Date | 17 | createdAt: Date |
18 | updatedAt: Date | 18 | updatedAt: Date |
19 | publishedAt: Date | 19 | publishedAt: Date |
20 | originallyPublishedAt: Date | string | ||
20 | category: VideoConstant<number> | 21 | category: VideoConstant<number> |
21 | licence: VideoConstant<number> | 22 | licence: VideoConstant<number> |
22 | language: VideoConstant<string> | 23 | language: VideoConstant<string> |
@@ -116,6 +117,9 @@ export class Video implements VideoServerModel { | |||
116 | this.privacy.label = peertubeTranslate(this.privacy.label, translations) | 117 | this.privacy.label = peertubeTranslate(this.privacy.label, translations) |
117 | 118 | ||
118 | this.scheduledUpdate = hash.scheduledUpdate | 119 | this.scheduledUpdate = hash.scheduledUpdate |
120 | this.originallyPublishedAt = hash.originallyPublishedAt ? | ||
121 | new Date(hash.originallyPublishedAt.toString()) | ||
122 | : null | ||
119 | if (this.state) this.state.label = peertubeTranslate(this.state.label, translations) | 123 | if (this.state) this.state.label = peertubeTranslate(this.state.label, translations) |
120 | 124 | ||
121 | this.blacklisted = hash.blacklisted | 125 | this.blacklisted = hash.blacklisted |
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index 565aad93b..960846e21 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts | |||
@@ -81,6 +81,7 @@ export class VideoService implements VideosProvider { | |||
81 | const description = video.description || null | 81 | const description = video.description || null |
82 | const support = video.support || null | 82 | const support = video.support || null |
83 | const scheduleUpdate = video.scheduleUpdate || null | 83 | const scheduleUpdate = video.scheduleUpdate || null |
84 | const originallyPublishedAt = video.originallyPublishedAt || null | ||
84 | 85 | ||
85 | const body: VideoUpdate = { | 86 | const body: VideoUpdate = { |
86 | name: video.name, | 87 | name: video.name, |
@@ -98,7 +99,8 @@ export class VideoService implements VideosProvider { | |||
98 | downloadEnabled: video.downloadEnabled, | 99 | downloadEnabled: video.downloadEnabled, |
99 | thumbnailfile: video.thumbnailfile, | 100 | thumbnailfile: video.thumbnailfile, |
100 | previewfile: video.previewfile, | 101 | previewfile: video.previewfile, |
101 | scheduleUpdate | 102 | scheduleUpdate, |
103 | originallyPublishedAt | ||
102 | } | 104 | } |
103 | 105 | ||
104 | const data = objectToFormData(body) | 106 | const data = objectToFormData(body) |
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.html b/client/src/app/videos/+video-edit/shared/video-edit.component.html index 59ba15b53..2fb540170 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.component.html +++ b/client/src/app/videos/+video-edit/shared/video-edit.component.html | |||
@@ -114,6 +114,20 @@ | |||
114 | </div> | 114 | </div> |
115 | </div> | 115 | </div> |
116 | 116 | ||
117 | <div class="form-group"> | ||
118 | <label i18n for="originallyPublishedAt">Original publication date</label> | ||
119 | <my-help i18n-preHtml preHtml="This is the date when the content was originally published (e.g. the release date for a film)"></my-help> | ||
120 | <p-calendar | ||
121 | id="originallyPublishedAt" formControlName="originallyPublishedAt" [dateFormat]="calendarDateFormat" | ||
122 | [locale]="calendarLocale" [showTime]="true" [hideOnDateTimeSelect]="true" [monthNavigator]="true" [yearNavigator]="true" [yearRange]="myYearRange" | ||
123 | > | ||
124 | </p-calendar> | ||
125 | |||
126 | <div *ngIf="formErrors.originallyPublishedAt" class="form-error"> | ||
127 | {{ formErrors.originallyPublishedAt }} | ||
128 | </div> | ||
129 | </div> | ||
130 | |||
117 | <my-peertube-checkbox | 131 | <my-peertube-checkbox |
118 | inputName="nsfw" formControlName="nsfw" | 132 | inputName="nsfw" formControlName="nsfw" |
119 | i18n-labelText labelText="This video contains mature or explicit content" | 133 | i18n-labelText labelText="This video contains mature or explicit content" |
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.ts b/client/src/app/videos/+video-edit/shared/video-edit.component.ts index 3ed7a4a10..836452948 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts | |||
@@ -45,6 +45,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
45 | 45 | ||
46 | calendarLocale: any = {} | 46 | calendarLocale: any = {} |
47 | minScheduledDate = new Date() | 47 | minScheduledDate = new Date() |
48 | myYearRange = '1880:' + (new Date()).getFullYear() | ||
48 | 49 | ||
49 | calendarTimezone: string | 50 | calendarTimezone: string |
50 | calendarDateFormat: string | 51 | calendarDateFormat: string |
@@ -101,7 +102,8 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
101 | thumbnailfile: null, | 102 | thumbnailfile: null, |
102 | previewfile: null, | 103 | previewfile: null, |
103 | support: this.videoValidatorsService.VIDEO_SUPPORT, | 104 | support: this.videoValidatorsService.VIDEO_SUPPORT, |
104 | schedulePublicationAt: this.videoValidatorsService.VIDEO_SCHEDULE_PUBLICATION_AT | 105 | schedulePublicationAt: this.videoValidatorsService.VIDEO_SCHEDULE_PUBLICATION_AT, |
106 | originallyPublishedAt: this.videoValidatorsService.VIDEO_ORIGINALLY_PUBLISHED_AT | ||
105 | } | 107 | } |
106 | 108 | ||
107 | this.formValidatorService.updateForm( | 109 | this.formValidatorService.updateForm( |
diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.html index 1875230d8..6e18ab6a6 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.html +++ b/client/src/app/videos/+video-watch/video-watch.component.html | |||
@@ -33,7 +33,6 @@ | |||
33 | <div> | 33 | <div> |
34 | <div class="d-block d-sm-none"> <!-- only shown on small devices, has its conterpart for larger viewports below --> | 34 | <div class="d-block d-sm-none"> <!-- only shown on small devices, has its conterpart for larger viewports below --> |
35 | <h1 class="video-info-name">{{ video.name }}</h1> | 35 | <h1 class="video-info-name">{{ video.name }}</h1> |
36 | |||
37 | <div i18n class="video-info-date-views"> | 36 | <div i18n class="video-info-date-views"> |
38 | Published {{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views | 37 | Published {{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views |
39 | </div> | 38 | </div> |
@@ -162,6 +161,11 @@ | |||
162 | <span class="video-attribute-value">{{ video.privacy.label }}</span> | 161 | <span class="video-attribute-value">{{ video.privacy.label }}</span> |
163 | </div> | 162 | </div> |
164 | 163 | ||
164 | <div *ngIf="!!video.originallyPublishedAt" class="video-attribute"> | ||
165 | <span i18n class="video-attribute-label">Originally published</span> | ||
166 | <span class="video-attribute-value">{{ video.originallyPublishedAt | date: 'dd MMMM yyyy' }}</span> | ||
167 | </div> | ||
168 | |||
165 | <div class="video-attribute"> | 169 | <div class="video-attribute"> |
166 | <span i18n class="video-attribute-label">Category</span> | 170 | <span i18n class="video-attribute-label">Category</span> |
167 | <span *ngIf="!video.category.id" class="video-attribute-value">{{ video.category.label }}</span> | 171 | <span *ngIf="!video.category.id" class="video-attribute-value">{{ video.category.label }}</span> |
diff --git a/client/src/app/videos/+video-watch/video-watch.component.scss b/client/src/app/videos/+video-watch/video-watch.component.scss index b03ed197d..cfe3533b6 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.scss +++ b/client/src/app/videos/+video-watch/video-watch.component.scss | |||
@@ -286,7 +286,7 @@ $other-videos-width: 260px; | |||
286 | margin-bottom: 12px; | 286 | margin-bottom: 12px; |
287 | 287 | ||
288 | .video-attribute-label { | 288 | .video-attribute-label { |
289 | min-width: 91px; | 289 | min-width: 142px; |
290 | padding-right: 5px; | 290 | padding-right: 5px; |
291 | display: inline-block; | 291 | display: inline-block; |
292 | color: $grey-foreground-color; | 292 | color: $grey-foreground-color; |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 76a318d13..6ac13e6a4 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -190,7 +190,8 @@ async function addVideo (req: express.Request, res: express.Response) { | |||
190 | support: videoInfo.support, | 190 | support: videoInfo.support, |
191 | privacy: videoInfo.privacy, | 191 | privacy: videoInfo.privacy, |
192 | duration: videoPhysicalFile['duration'], // duration was added by a previous middleware | 192 | duration: videoPhysicalFile['duration'], // duration was added by a previous middleware |
193 | channelId: res.locals.videoChannel.id | 193 | channelId: res.locals.videoChannel.id, |
194 | originallyPublishedAt: videoInfo.originallyPublishedAt | ||
194 | } | 195 | } |
195 | const video = new VideoModel(videoData) | 196 | const video = new VideoModel(videoData) |
196 | video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object | 197 | video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object |
@@ -328,6 +329,11 @@ async function updateVideo (req: express.Request, res: express.Response) { | |||
328 | if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description) | 329 | if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description) |
329 | if (videoInfoToUpdate.commentsEnabled !== undefined) videoInstance.set('commentsEnabled', videoInfoToUpdate.commentsEnabled) | 330 | if (videoInfoToUpdate.commentsEnabled !== undefined) videoInstance.set('commentsEnabled', videoInfoToUpdate.commentsEnabled) |
330 | if (videoInfoToUpdate.downloadEnabled !== undefined) videoInstance.set('downloadEnabled', videoInfoToUpdate.downloadEnabled) | 331 | if (videoInfoToUpdate.downloadEnabled !== undefined) videoInstance.set('downloadEnabled', videoInfoToUpdate.downloadEnabled) |
332 | |||
333 | if (videoInfoToUpdate.originallyPublishedAt !== undefined && videoInfoToUpdate.originallyPublishedAt !== null) { | ||
334 | videoInstance.set('originallyPublishedAt', videoInfoToUpdate.originallyPublishedAt) | ||
335 | } | ||
336 | |||
331 | if (videoInfoToUpdate.privacy !== undefined) { | 337 | if (videoInfoToUpdate.privacy !== undefined) { |
332 | const newPrivacy = parseInt(videoInfoToUpdate.privacy.toString(), 10) | 338 | const newPrivacy = parseInt(videoInfoToUpdate.privacy.toString(), 10) |
333 | videoInstance.set('privacy', newPrivacy) | 339 | videoInstance.set('privacy', newPrivacy) |
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 95e256b8f..dd04aa5f6 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -13,7 +13,7 @@ import { | |||
13 | VIDEO_STATES | 13 | VIDEO_STATES |
14 | } from '../../initializers' | 14 | } from '../../initializers' |
15 | import { VideoModel } from '../../models/video/video' | 15 | import { VideoModel } from '../../models/video/video' |
16 | import { exists, isArray, isFileValid } from './misc' | 16 | import { exists, isArray, isDateValid, isFileValid } from './misc' |
17 | import { VideoChannelModel } from '../../models/video/video-channel' | 17 | import { VideoChannelModel } from '../../models/video/video-channel' |
18 | import { UserModel } from '../../models/account/user' | 18 | import { UserModel } from '../../models/account/user' |
19 | import * as magnetUtil from 'magnet-uri' | 19 | import * as magnetUtil from 'magnet-uri' |
@@ -115,6 +115,10 @@ function isScheduleVideoUpdatePrivacyValid (value: number) { | |||
115 | ) | 115 | ) |
116 | } | 116 | } |
117 | 117 | ||
118 | function isVideoOriginallyPublishedAtValid (value: string | null) { | ||
119 | return value === null || isDateValid(value) | ||
120 | } | ||
121 | |||
118 | function isVideoFileInfoHashValid (value: string | null | undefined) { | 122 | function isVideoFileInfoHashValid (value: string | null | undefined) { |
119 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) | 123 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) |
120 | } | 124 | } |
@@ -220,6 +224,7 @@ export { | |||
220 | isVideoTagsValid, | 224 | isVideoTagsValid, |
221 | isVideoFPSResolutionValid, | 225 | isVideoFPSResolutionValid, |
222 | isScheduleVideoUpdatePrivacyValid, | 226 | isScheduleVideoUpdatePrivacyValid, |
227 | isVideoOriginallyPublishedAtValid, | ||
223 | isVideoFile, | 228 | isVideoFile, |
224 | isVideoMagnetUriValid, | 229 | isVideoMagnetUriValid, |
225 | isVideoStateValid, | 230 | isVideoStateValid, |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 639493d73..3656a23f9 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -16,7 +16,7 @@ let config: IConfig = require('config') | |||
16 | 16 | ||
17 | // --------------------------------------------------------------------------- | 17 | // --------------------------------------------------------------------------- |
18 | 18 | ||
19 | const LAST_MIGRATION_VERSION = 335 | 19 | const LAST_MIGRATION_VERSION = 340 |
20 | 20 | ||
21 | // --------------------------------------------------------------------------- | 21 | // --------------------------------------------------------------------------- |
22 | 22 | ||
diff --git a/server/initializers/migrations/0340-add-originally-published-at.ts b/server/initializers/migrations/0340-add-originally-published-at.ts new file mode 100644 index 000000000..ab8d66854 --- /dev/null +++ b/server/initializers/migrations/0340-add-originally-published-at.ts | |||
@@ -0,0 +1,31 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | async function up (utils: { | ||
4 | transaction: Sequelize.Transaction, | ||
5 | queryInterface: Sequelize.QueryInterface, | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | }): Promise<void> { | ||
8 | |||
9 | { | ||
10 | const data = { | ||
11 | type: Sequelize.DATE, | ||
12 | allowNull: true, | ||
13 | defaultValue: Sequelize.NOW | ||
14 | } | ||
15 | await utils.queryInterface.addColumn('video', 'originallyPublishedAt', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const query = 'UPDATE video SET "originallyPublishedAt" = video."publishedAt"' | ||
20 | await utils.sequelize.query(query) | ||
21 | } | ||
22 | } | ||
23 | |||
24 | function down (options) { | ||
25 | throw new Error('Not implemented.') | ||
26 | } | ||
27 | |||
28 | export { | ||
29 | up, | ||
30 | down | ||
31 | } | ||
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index d9626929c..159727e28 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -14,6 +14,7 @@ import { | |||
14 | } from '../../../helpers/custom-validators/misc' | 14 | } from '../../../helpers/custom-validators/misc' |
15 | import { | 15 | import { |
16 | checkUserCanManageVideo, | 16 | checkUserCanManageVideo, |
17 | isVideoOriginallyPublishedAtValid, | ||
17 | isScheduleVideoUpdatePrivacyValid, | 18 | isScheduleVideoUpdatePrivacyValid, |
18 | isVideoCategoryValid, | 19 | isVideoCategoryValid, |
19 | isVideoChannelOfAccountExist, | 20 | isVideoChannelOfAccountExist, |
@@ -344,7 +345,10 @@ function getCommonVideoAttributes () { | |||
344 | .optional() | 345 | .optional() |
345 | .toBoolean() | 346 | .toBoolean() |
346 | .custom(isBooleanValid).withMessage('Should have downloading enabled boolean'), | 347 | .custom(isBooleanValid).withMessage('Should have downloading enabled boolean'), |
347 | 348 | body('originallyPublishedAt') | |
349 | .optional() | ||
350 | .customSanitizer(toValueOrNull) | ||
351 | .custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'), | ||
348 | body('scheduleUpdate') | 352 | body('scheduleUpdate') |
349 | .optional() | 353 | .optional() |
350 | .customSanitizer(toValueOrNull), | 354 | .customSanitizer(toValueOrNull), |
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index 76d0445d4..c63285e25 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts | |||
@@ -67,6 +67,7 @@ function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormatting | |||
67 | createdAt: video.createdAt, | 67 | createdAt: video.createdAt, |
68 | updatedAt: video.updatedAt, | 68 | updatedAt: video.updatedAt, |
69 | publishedAt: video.publishedAt, | 69 | publishedAt: video.publishedAt, |
70 | originallyPublishedAt: video.originallyPublishedAt, | ||
70 | account: { | 71 | account: { |
71 | id: formattedAccount.id, | 72 | id: formattedAccount.id, |
72 | uuid: formattedAccount.uuid, | 73 | uuid: formattedAccount.uuid, |
@@ -323,6 +324,9 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject { | |||
323 | commentsEnabled: video.commentsEnabled, | 324 | commentsEnabled: video.commentsEnabled, |
324 | downloadEnabled: video.downloadEnabled, | 325 | downloadEnabled: video.downloadEnabled, |
325 | published: video.publishedAt.toISOString(), | 326 | published: video.publishedAt.toISOString(), |
327 | originallyPublishedAt: video.originallyPublishedAt ? | ||
328 | video.originallyPublishedAt.toISOString() : | ||
329 | null, | ||
326 | updated: video.updatedAt.toISOString(), | 330 | updated: video.updatedAt.toISOString(), |
327 | mediaType: 'text/markdown', | 331 | mediaType: 'text/markdown', |
328 | content: video.getTruncatedDescription(), | 332 | content: video.getTruncatedDescription(), |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 0feeed4f8..73626b6a0 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -103,6 +103,7 @@ const indexes: Sequelize.DefineIndexesOptions[] = [ | |||
103 | 103 | ||
104 | { fields: [ 'createdAt' ] }, | 104 | { fields: [ 'createdAt' ] }, |
105 | { fields: [ 'publishedAt' ] }, | 105 | { fields: [ 'publishedAt' ] }, |
106 | { fields: [ 'originallyPublishedAt' ] }, | ||
106 | { fields: [ 'duration' ] }, | 107 | { fields: [ 'duration' ] }, |
107 | { fields: [ 'views' ] }, | 108 | { fields: [ 'views' ] }, |
108 | { fields: [ 'channelId' ] }, | 109 | { fields: [ 'channelId' ] }, |
@@ -740,6 +741,9 @@ export class VideoModel extends Model<VideoModel> { | |||
740 | @Column | 741 | @Column |
741 | publishedAt: Date | 742 | publishedAt: Date |
742 | 743 | ||
744 | @Column | ||
745 | originallyPublishedAt: Date | ||
746 | |||
743 | @ForeignKey(() => VideoChannelModel) | 747 | @ForeignKey(() => VideoChannelModel) |
744 | @Column | 748 | @Column |
745 | channelId: number | 749 | channelId: number |
diff --git a/shared/models/activitypub/objects/video-torrent-object.ts b/shared/models/activitypub/objects/video-torrent-object.ts index 4231fbb68..239822bc4 100644 --- a/shared/models/activitypub/objects/video-torrent-object.ts +++ b/shared/models/activitypub/objects/video-torrent-object.ts | |||
@@ -25,6 +25,7 @@ export interface VideoTorrentObject { | |||
25 | waitTranscoding: boolean | 25 | waitTranscoding: boolean |
26 | state: VideoState | 26 | state: VideoState |
27 | published: string | 27 | published: string |
28 | originallyPublishedAt: string | ||
28 | updated: string | 29 | updated: string |
29 | mediaType: 'text/markdown' | 30 | mediaType: 'text/markdown' |
30 | content: string | 31 | content: string |
diff --git a/shared/models/videos/video-create.model.ts b/shared/models/videos/video-create.model.ts index f153a1d00..53631bf79 100644 --- a/shared/models/videos/video-create.model.ts +++ b/shared/models/videos/video-create.model.ts | |||
@@ -16,4 +16,5 @@ export interface VideoCreate { | |||
16 | downloadEnabled?: boolean | 16 | downloadEnabled?: boolean |
17 | privacy: VideoPrivacy | 17 | privacy: VideoPrivacy |
18 | scheduleUpdate?: VideoScheduleUpdate | 18 | scheduleUpdate?: VideoScheduleUpdate |
19 | originallyPublishedAt: Date | string | ||
19 | } | 20 | } |
diff --git a/shared/models/videos/video-update.model.ts b/shared/models/videos/video-update.model.ts index 6f96633ae..4ef904156 100644 --- a/shared/models/videos/video-update.model.ts +++ b/shared/models/videos/video-update.model.ts | |||
@@ -18,4 +18,5 @@ export interface VideoUpdate { | |||
18 | thumbnailfile?: Blob | 18 | thumbnailfile?: Blob |
19 | previewfile?: Blob | 19 | previewfile?: Blob |
20 | scheduleUpdate?: VideoScheduleUpdate | 20 | scheduleUpdate?: VideoScheduleUpdate |
21 | originallyPublishedAt?: Date | string | ||
21 | } | 22 | } |
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index 891831a9e..df800461c 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts | |||
@@ -44,6 +44,7 @@ export interface Video { | |||
44 | createdAt: Date | string | 44 | createdAt: Date | string |
45 | updatedAt: Date | string | 45 | updatedAt: Date | string |
46 | publishedAt: Date | string | 46 | publishedAt: Date | string |
47 | originallyPublishedAt: Date | string | ||
47 | category: VideoConstant<number> | 48 | category: VideoConstant<number> |
48 | licence: VideoConstant<number> | 49 | licence: VideoConstant<number> |
49 | language: VideoConstant<string> | 50 | language: VideoConstant<string> |