]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Change models
authorclementbrizard <clementbrizard53@gmail.com>
Sat, 12 Jan 2019 13:41:45 +0000 (13:41 +0000)
committerclementbrizard <clementbrizard53@gmail.com>
Sat, 12 Jan 2019 13:41:45 +0000 (13:41 +0000)
client/src/app/shared/video/video-edit.model.ts
client/src/app/shared/video/video.model.ts
server/models/video/video-format-utils.ts
server/models/video/video.ts
shared/models/activitypub/objects/video-torrent-object.ts
shared/models/videos/video-create.model.ts
shared/models/videos/video-update.model.ts
shared/models/videos/video.model.ts

index fc772a3cf4a54743656f5e2ee79f017efe07aaa0..9078bb5d2889067cef453469dd223869a33285f2 100644 (file)
@@ -25,6 +25,7 @@ export class VideoEdit implements VideoUpdate {
   uuid?: string
   id?: number
   scheduleUpdate?: VideoScheduleUpdate
+  originallyPublishedAt?: Date | string
 
   constructor (video?: Video & { tags: string[], commentsEnabled: boolean, support: string, thumbnailUrl: string, previewUrl: string }) {
     if (video) {
@@ -46,6 +47,7 @@ export class VideoEdit implements VideoUpdate {
       this.previewUrl = video.previewUrl
 
       this.scheduleUpdate = video.scheduledUpdate
+      this.originallyPublishedAt = new Date(video.originallyPublishedAt)
     }
   }
 
@@ -67,6 +69,12 @@ export class VideoEdit implements VideoUpdate {
     } else {
       this.scheduleUpdate = null
     }
+
+    // Convert originallyPublishedAt to string so that function objectToFormData() works correctly
+    if (this.originallyPublishedAt) {
+      const originallyPublishedAt = new Date(values['originallyPublishedAt'])
+      this.originallyPublishedAt = originallyPublishedAt.toISOString()
+    }
   }
 
   toFormPatch () {
@@ -82,7 +90,8 @@ export class VideoEdit implements VideoUpdate {
       commentsEnabled: this.commentsEnabled,
       waitTranscoding: this.waitTranscoding,
       channelId: this.channelId,
-      privacy: this.privacy
+      privacy: this.privacy,
+      originallyPublishedAt: this.originallyPublishedAt
     }
 
     // Special case if we scheduled an update
index b92c96450b1b4a60d99c8ca2bb97932e6f6c3ed7..c9b0529517745e3db57bcbb610af1c8338e975f9 100644 (file)
@@ -17,6 +17,7 @@ export class Video implements VideoServerModel {
   createdAt: Date
   updatedAt: Date
   publishedAt: Date
+  originallyPublishedAt: Date | string
   category: VideoConstant<number>
   licence: VideoConstant<number>
   language: VideoConstant<string>
@@ -116,6 +117,9 @@ export class Video implements VideoServerModel {
     this.privacy.label = peertubeTranslate(this.privacy.label, translations)
 
     this.scheduledUpdate = hash.scheduledUpdate
+    this.originallyPublishedAt = hash.originallyPublishedAt ?
+    new Date(hash.originallyPublishedAt.toString())
+    : null
     if (this.state) this.state.label = peertubeTranslate(this.state.label, translations)
 
     this.blacklisted = hash.blacklisted
index de0747f2221229b24d29386ac3b0ff300781d928..7a9513cbe5d776c21f2b49983d3854832888cfbb 100644 (file)
@@ -60,6 +60,7 @@ function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormatting
     createdAt: video.createdAt,
     updatedAt: video.updatedAt,
     publishedAt: video.publishedAt,
+    originallyPublishedAt: video.originallyPublishedAt,
     account: {
       id: formattedAccount.id,
       uuid: formattedAccount.uuid,
@@ -264,6 +265,9 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject {
     state: video.state,
     commentsEnabled: video.commentsEnabled,
     published: video.publishedAt.toISOString(),
+    originallyPublishedAt: video.originallyPublishedAt ?
+      video.originallyPublishedAt.toISOString() :
+      null,
     updated: video.updatedAt.toISOString(),
     mediaType: 'text/markdown',
     content: video.getTruncatedDescription(),
index 80a6c78320e20bf5a63f7e71ac51bfc951721ee5..806b6e0464de870245d59ead7297af161c69e5f3 100644 (file)
@@ -102,6 +102,7 @@ const indexes: Sequelize.DefineIndexesOptions[] = [
 
   { fields: [ 'createdAt' ] },
   { fields: [ 'publishedAt' ] },
+  { fields: [ 'originallyPublishedAt' ] },
   { fields: [ 'duration' ] },
   { fields: [ 'views' ] },
   { fields: [ 'channelId' ] },
@@ -684,6 +685,9 @@ export class VideoModel extends Model<VideoModel> {
   @Column
   publishedAt: Date
 
+  @Column
+  originallyPublishedAt: Date
+
   @ForeignKey(() => VideoChannelModel)
   @Column
   channelId: number
index 8504c178fa0d50eed5e52345d3db86c66d34c6f3..df07507b43697e688d11d459a7b7bd9322339a84 100644 (file)
@@ -24,6 +24,7 @@ export interface VideoTorrentObject {
   waitTranscoding: boolean
   state: VideoState
   published: string
+  originallyPublishedAt: string
   updated: string
   mediaType: 'text/markdown'
   content: string
index 190d637832719d744d45f8430b47584134ec1686..392bd10258f200741e98d97740adeb2b0cbcd56e 100644 (file)
@@ -15,4 +15,5 @@ export interface VideoCreate {
   commentsEnabled?: boolean
   privacy: VideoPrivacy
   scheduleUpdate?: VideoScheduleUpdate
+  originallyPublishedAt: Date | string
 }
index ed141a824f6959e169ac2ba9c573e1f60da68b66..62e02e0794cb7910eb491f379f5aede0c7797638 100644 (file)
@@ -17,4 +17,5 @@ export interface VideoUpdate {
   thumbnailfile?: Blob
   previewfile?: Blob
   scheduleUpdate?: VideoScheduleUpdate
+  originallyPublishedAt?: Date | string
 }
index 4a9fa58b109792a7b4b57958a0a2eb04d3d538c8..2373ceb1899c1412b47c8fe5afd8ef99c6680c77 100644 (file)
@@ -43,6 +43,7 @@ export interface Video {
   createdAt: Date | string
   updatedAt: Date | string
   publishedAt: Date | string
+  originallyPublishedAt: Date | string
   category: VideoConstant<number>
   licence: VideoConstant<number>
   language: VideoConstant<string>