aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorclementbrizard <clementbrizard53@gmail.com>2019-01-12 13:41:45 +0000
committerclementbrizard <clementbrizard53@gmail.com>2019-01-12 13:41:45 +0000
commitc80341655fce5e70ad6da7d812e2ddeb1f8ef7f2 (patch)
tree9f0415756552c5e4d4b18aee50bccbfaa75dd4c3
parent94a680c095b3007179820ac091189f639dd39e6b (diff)
downloadPeerTube-c80341655fce5e70ad6da7d812e2ddeb1f8ef7f2.tar.gz
PeerTube-c80341655fce5e70ad6da7d812e2ddeb1f8ef7f2.tar.zst
PeerTube-c80341655fce5e70ad6da7d812e2ddeb1f8ef7f2.zip
Change models
-rw-r--r--client/src/app/shared/video/video-edit.model.ts11
-rw-r--r--client/src/app/shared/video/video.model.ts4
-rw-r--r--server/models/video/video-format-utils.ts4
-rw-r--r--server/models/video/video.ts4
-rw-r--r--shared/models/activitypub/objects/video-torrent-object.ts1
-rw-r--r--shared/models/videos/video-create.model.ts1
-rw-r--r--shared/models/videos/video-update.model.ts1
-rw-r--r--shared/models/videos/video.model.ts1
8 files changed, 26 insertions, 1 deletions
diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts
index fc772a3cf..9078bb5d2 100644
--- a/client/src/app/shared/video/video-edit.model.ts
+++ b/client/src/app/shared/video/video-edit.model.ts
@@ -25,6 +25,7 @@ export class VideoEdit implements VideoUpdate {
25 uuid?: string 25 uuid?: string
26 id?: number 26 id?: number
27 scheduleUpdate?: VideoScheduleUpdate 27 scheduleUpdate?: VideoScheduleUpdate
28 originallyPublishedAt?: Date | string
28 29
29 constructor (video?: Video & { tags: string[], commentsEnabled: boolean, support: string, thumbnailUrl: string, previewUrl: string }) { 30 constructor (video?: Video & { tags: string[], commentsEnabled: boolean, support: string, thumbnailUrl: string, previewUrl: string }) {
30 if (video) { 31 if (video) {
@@ -46,6 +47,7 @@ export class VideoEdit implements VideoUpdate {
46 this.previewUrl = video.previewUrl 47 this.previewUrl = video.previewUrl
47 48
48 this.scheduleUpdate = video.scheduledUpdate 49 this.scheduleUpdate = video.scheduledUpdate
50 this.originallyPublishedAt = new Date(video.originallyPublishedAt)
49 } 51 }
50 } 52 }
51 53
@@ -67,6 +69,12 @@ export class VideoEdit implements VideoUpdate {
67 } else { 69 } else {
68 this.scheduleUpdate = null 70 this.scheduleUpdate = null
69 } 71 }
72
73 // Convert originallyPublishedAt to string so that function objectToFormData() works correctly
74 if (this.originallyPublishedAt) {
75 const originallyPublishedAt = new Date(values['originallyPublishedAt'])
76 this.originallyPublishedAt = originallyPublishedAt.toISOString()
77 }
70 } 78 }
71 79
72 toFormPatch () { 80 toFormPatch () {
@@ -82,7 +90,8 @@ export class VideoEdit implements VideoUpdate {
82 commentsEnabled: this.commentsEnabled, 90 commentsEnabled: this.commentsEnabled,
83 waitTranscoding: this.waitTranscoding, 91 waitTranscoding: this.waitTranscoding,
84 channelId: this.channelId, 92 channelId: this.channelId,
85 privacy: this.privacy 93 privacy: this.privacy,
94 originallyPublishedAt: this.originallyPublishedAt
86 } 95 }
87 96
88 // Special case if we scheduled an update 97 // Special case if we scheduled an update
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts
index b92c96450..c9b052951 100644
--- a/client/src/app/shared/video/video.model.ts
+++ b/client/src/app/shared/video/video.model.ts
@@ -17,6 +17,7 @@ export class Video implements VideoServerModel {
17 createdAt: Date 17 createdAt: Date
18 updatedAt: Date 18 updatedAt: Date
19 publishedAt: Date 19 publishedAt: Date
20 originallyPublishedAt: Date | string
20 category: VideoConstant<number> 21 category: VideoConstant<number>
21 licence: VideoConstant<number> 22 licence: VideoConstant<number>
22 language: VideoConstant<string> 23 language: VideoConstant<string>
@@ -116,6 +117,9 @@ export class Video implements VideoServerModel {
116 this.privacy.label = peertubeTranslate(this.privacy.label, translations) 117 this.privacy.label = peertubeTranslate(this.privacy.label, translations)
117 118
118 this.scheduledUpdate = hash.scheduledUpdate 119 this.scheduledUpdate = hash.scheduledUpdate
120 this.originallyPublishedAt = hash.originallyPublishedAt ?
121 new Date(hash.originallyPublishedAt.toString())
122 : null
119 if (this.state) this.state.label = peertubeTranslate(this.state.label, translations) 123 if (this.state) this.state.label = peertubeTranslate(this.state.label, translations)
120 124
121 this.blacklisted = hash.blacklisted 125 this.blacklisted = hash.blacklisted
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts
index de0747f22..7a9513cbe 100644
--- a/server/models/video/video-format-utils.ts
+++ b/server/models/video/video-format-utils.ts
@@ -60,6 +60,7 @@ function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormatting
60 createdAt: video.createdAt, 60 createdAt: video.createdAt,
61 updatedAt: video.updatedAt, 61 updatedAt: video.updatedAt,
62 publishedAt: video.publishedAt, 62 publishedAt: video.publishedAt,
63 originallyPublishedAt: video.originallyPublishedAt,
63 account: { 64 account: {
64 id: formattedAccount.id, 65 id: formattedAccount.id,
65 uuid: formattedAccount.uuid, 66 uuid: formattedAccount.uuid,
@@ -264,6 +265,9 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject {
264 state: video.state, 265 state: video.state,
265 commentsEnabled: video.commentsEnabled, 266 commentsEnabled: video.commentsEnabled,
266 published: video.publishedAt.toISOString(), 267 published: video.publishedAt.toISOString(),
268 originallyPublishedAt: video.originallyPublishedAt ?
269 video.originallyPublishedAt.toISOString() :
270 null,
267 updated: video.updatedAt.toISOString(), 271 updated: video.updatedAt.toISOString(),
268 mediaType: 'text/markdown', 272 mediaType: 'text/markdown',
269 content: video.getTruncatedDescription(), 273 content: video.getTruncatedDescription(),
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 80a6c7832..806b6e046 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -102,6 +102,7 @@ const indexes: Sequelize.DefineIndexesOptions[] = [
102 102
103 { fields: [ 'createdAt' ] }, 103 { fields: [ 'createdAt' ] },
104 { fields: [ 'publishedAt' ] }, 104 { fields: [ 'publishedAt' ] },
105 { fields: [ 'originallyPublishedAt' ] },
105 { fields: [ 'duration' ] }, 106 { fields: [ 'duration' ] },
106 { fields: [ 'views' ] }, 107 { fields: [ 'views' ] },
107 { fields: [ 'channelId' ] }, 108 { fields: [ 'channelId' ] },
@@ -684,6 +685,9 @@ export class VideoModel extends Model<VideoModel> {
684 @Column 685 @Column
685 publishedAt: Date 686 publishedAt: Date
686 687
688 @Column
689 originallyPublishedAt: Date
690
687 @ForeignKey(() => VideoChannelModel) 691 @ForeignKey(() => VideoChannelModel)
688 @Column 692 @Column
689 channelId: number 693 channelId: number
diff --git a/shared/models/activitypub/objects/video-torrent-object.ts b/shared/models/activitypub/objects/video-torrent-object.ts
index 8504c178f..df07507b4 100644
--- a/shared/models/activitypub/objects/video-torrent-object.ts
+++ b/shared/models/activitypub/objects/video-torrent-object.ts
@@ -24,6 +24,7 @@ export interface VideoTorrentObject {
24 waitTranscoding: boolean 24 waitTranscoding: boolean
25 state: VideoState 25 state: VideoState
26 published: string 26 published: string
27 originallyPublishedAt: string
27 updated: string 28 updated: string
28 mediaType: 'text/markdown' 29 mediaType: 'text/markdown'
29 content: string 30 content: string
diff --git a/shared/models/videos/video-create.model.ts b/shared/models/videos/video-create.model.ts
index 190d63783..392bd1025 100644
--- a/shared/models/videos/video-create.model.ts
+++ b/shared/models/videos/video-create.model.ts
@@ -15,4 +15,5 @@ export interface VideoCreate {
15 commentsEnabled?: boolean 15 commentsEnabled?: boolean
16 privacy: VideoPrivacy 16 privacy: VideoPrivacy
17 scheduleUpdate?: VideoScheduleUpdate 17 scheduleUpdate?: VideoScheduleUpdate
18 originallyPublishedAt: Date | string
18} 19}
diff --git a/shared/models/videos/video-update.model.ts b/shared/models/videos/video-update.model.ts
index ed141a824..62e02e079 100644
--- a/shared/models/videos/video-update.model.ts
+++ b/shared/models/videos/video-update.model.ts
@@ -17,4 +17,5 @@ export interface VideoUpdate {
17 thumbnailfile?: Blob 17 thumbnailfile?: Blob
18 previewfile?: Blob 18 previewfile?: Blob
19 scheduleUpdate?: VideoScheduleUpdate 19 scheduleUpdate?: VideoScheduleUpdate
20 originallyPublishedAt?: Date | string
20} 21}
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts
index 4a9fa58b1..2373ceb18 100644
--- a/shared/models/videos/video.model.ts
+++ b/shared/models/videos/video.model.ts
@@ -43,6 +43,7 @@ export interface Video {
43 createdAt: Date | string 43 createdAt: Date | string
44 updatedAt: Date | string 44 updatedAt: Date | string
45 publishedAt: Date | string 45 publishedAt: Date | string
46 originallyPublishedAt: Date | string
46 category: VideoConstant<number> 47 category: VideoConstant<number>
47 licence: VideoConstant<number> 48 licence: VideoConstant<number>
48 language: VideoConstant<string> 49 language: VideoConstant<string>