aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-11 14:41:55 +0100
committerChocobozzz <me@florianbigard.com>2019-02-11 15:16:39 +0100
commit7519127b5cb44095f78f6bf4c51d4ebf2b7d5e88 (patch)
treeed94c1fb00a85a1f25c15b9a82831f4999e72948 /server/models
parent6913f69134947432a192890b2de7c2d48094e85c (diff)
downloadPeerTube-7519127b5cb44095f78f6bf4c51d4ebf2b7d5e88.tar.gz
PeerTube-7519127b5cb44095f78f6bf4c51d4ebf2b7d5e88.tar.zst
PeerTube-7519127b5cb44095f78f6bf4c51d4ebf2b7d5e88.zip
Add originallyPublishedAt unit tests
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video-format-utils.ts4
-rw-r--r--server/models/video/video.ts13
2 files changed, 12 insertions, 5 deletions
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 {
324 commentsEnabled: video.commentsEnabled, 324 commentsEnabled: video.commentsEnabled,
325 downloadEnabled: video.downloadEnabled, 325 downloadEnabled: video.downloadEnabled,
326 published: video.publishedAt.toISOString(), 326 published: video.publishedAt.toISOString(),
327 originallyPublishedAt: video.originallyPublishedAt ? 327 originallyPublishedAt: video.originallyPublishedAt ? video.originallyPublishedAt.toISOString() : null,
328 video.originallyPublishedAt.toISOString() :
329 null,
330 updated: video.updatedAt.toISOString(), 328 updated: video.updatedAt.toISOString(),
331 mediaType: 'text/markdown', 329 mediaType: 'text/markdown',
332 content: video.getTruncatedDescription(), 330 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 {
40 isVideoDurationValid, 40 isVideoDurationValid,
41 isVideoLanguageValid, 41 isVideoLanguageValid,
42 isVideoLicenceValid, 42 isVideoLicenceValid,
43 isVideoNameValid, 43 isVideoNameValid, isVideoOriginallyPublishedAtValid,
44 isVideoPrivacyValid, 44 isVideoPrivacyValid,
45 isVideoStateValid, 45 isVideoStateValid,
46 isVideoSupportValid 46 isVideoSupportValid
@@ -103,11 +103,18 @@ const indexes: Sequelize.DefineIndexesOptions[] = [
103 103
104 { fields: [ 'createdAt' ] }, 104 { fields: [ 'createdAt' ] },
105 { fields: [ 'publishedAt' ] }, 105 { fields: [ 'publishedAt' ] },
106 { fields: [ 'originallyPublishedAt' ] },
107 { fields: [ 'duration' ] }, 106 { fields: [ 'duration' ] },
108 { fields: [ 'views' ] }, 107 { fields: [ 'views' ] },
109 { fields: [ 'channelId' ] }, 108 { fields: [ 'channelId' ] },
110 { 109 {
110 fields: [ 'originallyPublishedAt' ],
111 where: {
112 originallyPublishedAt: {
113 [Sequelize.Op.ne]: null
114 }
115 }
116 },
117 {
111 fields: [ 'category' ], // We don't care videos with an unknown category 118 fields: [ 'category' ], // We don't care videos with an unknown category
112 where: { 119 where: {
113 category: { 120 category: {
@@ -741,6 +748,8 @@ export class VideoModel extends Model<VideoModel> {
741 @Column 748 @Column
742 publishedAt: Date 749 publishedAt: Date
743 750
751 @AllowNull(true)
752 @Default(null)
744 @Column 753 @Column
745 originallyPublishedAt: Date 754 originallyPublishedAt: Date
746 755