aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/shared/video/video-miniature.component.html2
-rw-r--r--client/src/app/shared/video/video.model.ts2
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.html2
-rw-r--r--server/controllers/api/videos/index.ts9
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/migrations/0200-video-published-at.ts32
-rw-r--r--server/models/video/video.ts8
-rw-r--r--shared/models/videos/video.model.ts1
8 files changed, 53 insertions, 5 deletions
diff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.html
index 7ac017235..f28e9b8d9 100644
--- a/client/src/app/shared/video/video-miniature.component.html
+++ b/client/src/app/shared/video/video-miniature.component.html
@@ -11,7 +11,7 @@
11 </a> 11 </a>
12 </span> 12 </span>
13 13
14 <span class="video-miniature-created-at-views">{{ video.createdAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span> 14 <span class="video-miniature-created-at-views">{{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span>
15 <span class="video-miniature-account">{{ video.by }}</span> 15 <span class="video-miniature-account">{{ video.by }}</span>
16 </div> 16 </div>
17</div> 17</div>
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts
index 7b68933a1..0c02cbcb9 100644
--- a/client/src/app/shared/video/video.model.ts
+++ b/client/src/app/shared/video/video.model.ts
@@ -9,6 +9,7 @@ export class Video implements VideoServerModel {
9 by: string 9 by: string
10 createdAt: Date 10 createdAt: Date
11 updatedAt: Date 11 updatedAt: Date
12 publishedAt: Date
12 category: VideoConstant<number> 13 category: VideoConstant<number>
13 licence: VideoConstant<number> 14 licence: VideoConstant<number>
14 language: VideoConstant<number> 15 language: VideoConstant<number>
@@ -56,6 +57,7 @@ export class Video implements VideoServerModel {
56 const absoluteAPIUrl = getAbsoluteAPIUrl() 57 const absoluteAPIUrl = getAbsoluteAPIUrl()
57 58
58 this.createdAt = new Date(hash.createdAt.toString()) 59 this.createdAt = new Date(hash.createdAt.toString())
60 this.publishedAt = new Date(hash.publishedAt.toString())
59 this.category = hash.category 61 this.category = hash.category
60 this.licence = hash.licence 62 this.licence = hash.licence
61 this.language = hash.language 63 this.language = hash.language
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 6c7fc08e1..ec5bd30dc 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.html
+++ b/client/src/app/videos/+video-watch/video-watch.component.html
@@ -14,7 +14,7 @@
14 <div class="video-info-name">{{ video.name }}</div> 14 <div class="video-info-name">{{ video.name }}</div>
15 15
16 <div class="video-info-date-views"> 16 <div class="video-info-date-views">
17 {{ video.createdAt | myFromNow }} - {{ video.views | myNumberFormatter }} views 17 {{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views
18 </div> 18 </div>
19 19
20 <div class="video-info-channel"> 20 <div class="video-info-channel">
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 552e5edac..244099015 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -307,10 +307,17 @@ async function updateVideo (req: express.Request, res: express.Response) {
307 if (videoInfoToUpdate.licence !== undefined) videoInstance.set('licence', videoInfoToUpdate.licence) 307 if (videoInfoToUpdate.licence !== undefined) videoInstance.set('licence', videoInfoToUpdate.licence)
308 if (videoInfoToUpdate.language !== undefined) videoInstance.set('language', videoInfoToUpdate.language) 308 if (videoInfoToUpdate.language !== undefined) videoInstance.set('language', videoInfoToUpdate.language)
309 if (videoInfoToUpdate.nsfw !== undefined) videoInstance.set('nsfw', videoInfoToUpdate.nsfw) 309 if (videoInfoToUpdate.nsfw !== undefined) videoInstance.set('nsfw', videoInfoToUpdate.nsfw)
310 if (videoInfoToUpdate.privacy !== undefined) videoInstance.set('privacy', parseInt(videoInfoToUpdate.privacy.toString(), 10))
311 if (videoInfoToUpdate.support !== undefined) videoInstance.set('support', videoInfoToUpdate.support) 310 if (videoInfoToUpdate.support !== undefined) videoInstance.set('support', videoInfoToUpdate.support)
312 if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description) 311 if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description)
313 if (videoInfoToUpdate.commentsEnabled !== undefined) videoInstance.set('commentsEnabled', videoInfoToUpdate.commentsEnabled) 312 if (videoInfoToUpdate.commentsEnabled !== undefined) videoInstance.set('commentsEnabled', videoInfoToUpdate.commentsEnabled)
313 if (videoInfoToUpdate.privacy !== undefined) {
314 const newPrivacy = parseInt(videoInfoToUpdate.privacy.toString(), 10)
315 videoInstance.set('privacy', newPrivacy)
316
317 if (wasPrivateVideo === true && newPrivacy !== VideoPrivacy.PRIVATE) {
318 videoInstance.set('publishedAt', new Date())
319 }
320 }
314 321
315 const videoInstanceUpdated = await videoInstance.save(sequelizeOptions) 322 const videoInstanceUpdated = await videoInstance.save(sequelizeOptions)
316 323
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 5152095b3..2622b2c71 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -12,7 +12,7 @@ let config: IConfig = require('config')
12 12
13// --------------------------------------------------------------------------- 13// ---------------------------------------------------------------------------
14 14
15const LAST_MIGRATION_VERSION = 195 15const LAST_MIGRATION_VERSION = 200
16 16
17// --------------------------------------------------------------------------- 17// ---------------------------------------------------------------------------
18 18
diff --git a/server/initializers/migrations/0200-video-published-at.ts b/server/initializers/migrations/0200-video-published-at.ts
new file mode 100644
index 000000000..edaf4a145
--- /dev/null
+++ b/server/initializers/migrations/0200-video-published-at.ts
@@ -0,0 +1,32 @@
1import * as Sequelize from 'sequelize'
2
3async 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: false,
13 defaultValue: Sequelize.NOW
14 }
15 await utils.queryInterface.addColumn('video', 'publishedAt', data)
16 }
17
18 {
19 const query = 'UPDATE video SET "publishedAt" = video."createdAt"'
20 await utils.sequelize.query(query)
21 }
22
23}
24
25function down (options) {
26 throw new Error('Not implemented.')
27}
28
29export {
30 up,
31 down
32}
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 7c56c65a6..2a1226f6d 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -376,6 +376,11 @@ export class VideoModel extends Model<VideoModel> {
376 @UpdatedAt 376 @UpdatedAt
377 updatedAt: Date 377 updatedAt: Date
378 378
379 @AllowNull(false)
380 @Default(Sequelize.NOW)
381 @Column
382 publishedAt: Date
383
379 @ForeignKey(() => VideoChannelModel) 384 @ForeignKey(() => VideoChannelModel)
380 @Column 385 @Column
381 channelId: number 386 channelId: number
@@ -968,6 +973,7 @@ export class VideoModel extends Model<VideoModel> {
968 embedPath: this.getEmbedPath(), 973 embedPath: this.getEmbedPath(),
969 createdAt: this.createdAt, 974 createdAt: this.createdAt,
970 updatedAt: this.updatedAt, 975 updatedAt: this.updatedAt,
976 publishedAt: this.publishedAt,
971 account: { 977 account: {
972 name: formattedAccount.name, 978 name: formattedAccount.name,
973 displayName: formattedAccount.displayName, 979 displayName: formattedAccount.displayName,
@@ -1122,7 +1128,7 @@ export class VideoModel extends Model<VideoModel> {
1122 views: this.views, 1128 views: this.views,
1123 sensitive: this.nsfw, 1129 sensitive: this.nsfw,
1124 commentsEnabled: this.commentsEnabled, 1130 commentsEnabled: this.commentsEnabled,
1125 published: this.createdAt.toISOString(), 1131 published: this.publishedAt.toISOString(),
1126 updated: this.updatedAt.toISOString(), 1132 updated: this.updatedAt.toISOString(),
1127 mediaType: 'text/markdown', 1133 mediaType: 'text/markdown',
1128 content: this.getTruncatedDescription(), 1134 content: this.getTruncatedDescription(),
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts
index ebd2813ca..1b5f1a09c 100644
--- a/shared/models/videos/video.model.ts
+++ b/shared/models/videos/video.model.ts
@@ -22,6 +22,7 @@ export interface Video {
22 uuid: string 22 uuid: string
23 createdAt: Date | string 23 createdAt: Date | string
24 updatedAt: Date | string 24 updatedAt: Date | string
25 publishedAt: Date | string
25 category: VideoConstant<number> 26 category: VideoConstant<number>
26 licence: VideoConstant<number> 27 licence: VideoConstant<number>
27 language: VideoConstant<number> 28 language: VideoConstant<number>