From 7519127b5cb44095f78f6bf4c51d4ebf2b7d5e88 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 11 Feb 2019 14:41:55 +0100 Subject: Add originallyPublishedAt unit tests --- server/models/video/video-format-utils.ts | 4 +--- server/models/video/video.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'server/models/video') diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index c63285e25..a62335333 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts @@ -324,9 +324,7 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject { commentsEnabled: video.commentsEnabled, downloadEnabled: video.downloadEnabled, published: video.publishedAt.toISOString(), - originallyPublishedAt: video.originallyPublishedAt ? - video.originallyPublishedAt.toISOString() : - null, + originallyPublishedAt: video.originallyPublishedAt ? video.originallyPublishedAt.toISOString() : null, updated: video.updatedAt.toISOString(), mediaType: 'text/markdown', content: video.getTruncatedDescription(), diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 73626b6a0..215e26d7d 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -40,7 +40,7 @@ import { isVideoDurationValid, isVideoLanguageValid, isVideoLicenceValid, - isVideoNameValid, + isVideoNameValid, isVideoOriginallyPublishedAtValid, isVideoPrivacyValid, isVideoStateValid, isVideoSupportValid @@ -103,10 +103,17 @@ const indexes: Sequelize.DefineIndexesOptions[] = [ { fields: [ 'createdAt' ] }, { fields: [ 'publishedAt' ] }, - { fields: [ 'originallyPublishedAt' ] }, { fields: [ 'duration' ] }, { fields: [ 'views' ] }, { fields: [ 'channelId' ] }, + { + fields: [ 'originallyPublishedAt' ], + where: { + originallyPublishedAt: { + [Sequelize.Op.ne]: null + } + } + }, { fields: [ 'category' ], // We don't care videos with an unknown category where: { @@ -741,6 +748,8 @@ export class VideoModel extends Model { @Column publishedAt: Date + @AllowNull(true) + @Default(null) @Column originallyPublishedAt: Date -- cgit v1.2.3