]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video.ts
Refractor activity pub lib/helpers
[github/Chocobozzz/PeerTube.git] / server / models / video / video.ts
index 5b0377c2e67e25df3553090cb4e50b0f38cee0f9..e2069eb0c6d8110280433e4ba978616f627649a2 100644 (file)
@@ -9,7 +9,6 @@ import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/v
 import {
   createTorrentPromise,
   generateImageFromVideoFile,
-  getActivityPubUrl,
   getVideoFileHeight,
   isVideoCategoryValid,
   isVideoDescriptionValid,
@@ -26,6 +25,7 @@ import {
   unlinkPromise,
   writeFilePromise
 } from '../../helpers'
+import { isVideoUrlValid } from '../../helpers/custom-validators/videos'
 import {
   API_VERSION,
   CONFIG,
@@ -45,8 +45,7 @@ import { addMethodsToModel, getSort } from '../utils'
 import { TagInstance } from './tag-interface'
 import { VideoFileInstance, VideoFileModel } from './video-file-interface'
 import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface'
-import { sendDeleteVideo } from '../../lib/activitypub/send-request'
-import { isVideoUrlValid } from '../../helpers/custom-validators/videos'
+import { sendDeleteVideo } from '../../lib/index'
 
 const Buffer = safeBuffer.Buffer
 
@@ -550,6 +549,7 @@ toFormattedDetailsJSON = function (this: VideoInstance) {
 
 toActivityPubObject = function (this: VideoInstance) {
   const { baseUrlHttp, baseUrlWs } = getBaseUrls(this)
+  if (!this.Tags) this.Tags = []
 
   const tag = this.Tags.map(t => ({
     type: 'Hashtag' as 'Hashtag',
@@ -583,7 +583,7 @@ toActivityPubObject = function (this: VideoInstance) {
 
   const videoObject: VideoTorrentObject = {
     type: 'Video' as 'Video',
-    id: getActivityPubUrl('video', this.uuid),
+    id: this.url,
     name: this.name,
     // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
     duration: 'PT' + this.duration + 'S',
@@ -614,7 +614,7 @@ toActivityPubObject = function (this: VideoInstance) {
       width: THUMBNAILS_SIZE.width,
       height: THUMBNAILS_SIZE.height
     },
-    url
+    url // FIXME: needed?
   }
 
   return videoObject