From 2922e048de95738b3319054ce0778f873a34a0ee Mon Sep 17 00:00:00 2001 From: Julien Le Bras Date: Wed, 28 Mar 2018 23:38:52 +0200 Subject: 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 --- server/models/video/video.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'server/models') 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 { @UpdatedAt updatedAt: Date + @AllowNull(false) + @Default(Sequelize.NOW) + @Column + publishedAt: Date + @ForeignKey(() => VideoChannelModel) @Column channelId: number @@ -968,6 +973,7 @@ export class VideoModel extends Model { embedPath: this.getEmbedPath(), createdAt: this.createdAt, updatedAt: this.updatedAt, + publishedAt: this.publishedAt, account: { name: formattedAccount.name, displayName: formattedAccount.displayName, @@ -1122,7 +1128,7 @@ export class VideoModel extends Model { views: this.views, sensitive: this.nsfw, commentsEnabled: this.commentsEnabled, - published: this.createdAt.toISOString(), + published: this.publishedAt.toISOString(), updated: this.updatedAt.toISOString(), mediaType: 'text/markdown', content: this.getTruncatedDescription(), -- cgit v1.2.3