aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
authorJulien Le Bras <julien.lb.pro@gmail.com>2018-03-28 23:38:52 +0200
committerChocobozzz <me@florianbigard.com>2018-03-30 08:52:58 +0200
commit2922e048de95738b3319054ce0778f873a34a0ee (patch)
treeee35b2e8bf9e1967b7d08974d6680697b2965472 /server/models/video
parent2920281946cffd62ce5046b661d63f9867ab0654 (diff)
downloadPeerTube-2922e048de95738b3319054ce0778f873a34a0ee.tar.gz
PeerTube-2922e048de95738b3319054ce0778f873a34a0ee.tar.zst
PeerTube-2922e048de95738b3319054ce0778f873a34a0ee.zip
Add publishedAt field for video model.
* New field added in the `video` table + migration script * `publishedAt` updated to NOW when privacy changes from private to public/unlisted (default = NOW) * Models updated to handle the new attribute * Client interface updated to use `publishedAt` instead of `createdAt` except in My Account > My Videos view
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video.ts8
1 files changed, 7 insertions, 1 deletions
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(),