import { Account } from '@app/shared/account/account.model'
import { User } from '../'
import { Video as VideoServerModel } from '../../../../../shared'
+import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
import { getAbsoluteAPIUrl } from '../misc/utils'
export class Video implements VideoServerModel {
- accountName: string
by: string
createdAt: Date
updatedAt: Date
likes: number
dislikes: number
nsfw: boolean
- account: Account
+
+ account: {
+ name: string
+ displayName: string
+ url: string
+ host: string
+ avatar: Avatar
+ }
private static createDurationString (duration: number) {
const minutes = Math.floor(duration / 60)
constructor (hash: VideoServerModel) {
const absoluteAPIUrl = getAbsoluteAPIUrl()
- this.accountName = hash.accountName
this.createdAt = new Date(hash.createdAt.toString())
this.categoryLabel = hash.categoryLabel
this.category = hash.category
this.uuid = hash.uuid
this.isLocal = hash.isLocal
this.name = hash.name
- this.serverHost = hash.serverHost
this.thumbnailPath = hash.thumbnailPath
this.thumbnailUrl = absoluteAPIUrl + hash.thumbnailPath
this.previewPath = hash.previewPath
this.likes = hash.likes
this.dislikes = hash.dislikes
this.nsfw = hash.nsfw
+ this.account = hash.account
- this.by = Account.CREATE_BY_STRING(hash.accountName, hash.serverHost)
+ this.by = Account.CREATE_BY_STRING(hash.account.name, hash.account.host)
}
isVideoNSFWForUser (user: User) {
isVideoLanguageValid,
isVideoLicenceValid,
isVideoNameValid,
- isVideoPrivacyValid, isVideoSupportValid
+ isVideoPrivacyValid,
+ isVideoSupportValid
} from '../../helpers/custom-validators/videos'
import { generateImageFromVideoFile, getVideoFileResolution, transcode } from '../../helpers/ffmpeg-utils'
import { logger } from '../../helpers/logger'
required: true,
include: [
{
- attributes: [ 'serverId' ],
+ attributes: [ 'preferredUsername', 'url', 'serverId' ],
model: ActorModel.unscoped(),
required: true,
include: [
{
attributes: [ 'host' ],
- model: ServerModel.unscoped()
+ model: ServerModel.unscoped(),
+ required: false
+ },
+ {
+ model: AvatarModel.unscoped(),
+ required: false
}
]
}
}
toFormattedJSON (): Video {
- let serverHost
-
- if (this.VideoChannel.Account.Actor.Server) {
- serverHost = this.VideoChannel.Account.Actor.Server.host
- } else {
- // It means it's our video
- serverHost = CONFIG.WEBSERVER.HOST
- }
+ const formattedAccount = this.VideoChannel.Account.toFormattedJSON()
return {
id: this.id,
languageLabel: this.getLanguageLabel(),
nsfw: this.nsfw,
description: this.getTruncatedDescription(),
- serverHost,
isLocal: this.isOwned(),
- accountName: this.VideoChannel.Account.name,
duration: this.duration,
views: this.views,
likes: this.likes,
previewPath: this.getPreviewPath(),
embedPath: this.getEmbedPath(),
createdAt: this.createdAt,
- updatedAt: this.updatedAt
+ updatedAt: this.updatedAt,
+ account: {
+ name: formattedAccount.name,
+ displayName: formattedAccount.displayName,
+ url: formattedAccount.url,
+ host: formattedAccount.host,
+ avatar: formattedAccount.avatar
+ }
}
}
nsfw: true,
description: 'my super description',
support: 'my super support text',
- host: 'localhost:9003',
- account: 'root',
+ account: {
+ name: 'root',
+ host: 'localhost:9003'
+ },
isLocal,
commentsEnabled: true,
duration: 5,
nsfw: true,
description: 'my super description for server 1',
support: 'my super support text for server 1',
- host: 'localhost:9001',
- account: 'root',
+ account: {
+ name: 'root',
+ host: 'localhost:9001'
+ },
isLocal: false,
duration: 10,
tags: [ 'tag1p1', 'tag2p1' ],
const res = await getVideosList(server.url)
const video = res.body.data[ 0 ]
- expect(video.accountName).to.equal('root')
+ expect(video.account.name).to.equal('root')
videoId = video.id
})
expect(res.body.total).to.equal(1)
const video = res.body.data[ 0 ]
- expect(video.accountName).to.equal('root')
+ expect(video.account.name).to.equal('root')
})
it('Should register a new user', async function () {
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
import {
- addVideoChannel, checkVideoFilesWereRemoved, completeVideoCheck, createUser, dateIsValid, doubleFollow, flushAndRunMultipleServers,
- flushTests, getVideo,
- getVideoChannelsList, getVideosList, killallServers, rateVideo, removeVideo, ServerInfo, setAccessTokensToServers, testImage,
- updateVideo, uploadVideo, userLogin, viewVideo, wait, webtorrentAdd
+ addVideoChannel,
+ checkVideoFilesWereRemoved,
+ completeVideoCheck,
+ createUser,
+ dateIsValid,
+ doubleFollow,
+ flushAndRunMultipleServers,
+ flushTests,
+ getVideo,
+ getVideoChannelsList,
+ getVideosList,
+ killallServers,
+ rateVideo,
+ removeVideo,
+ ServerInfo,
+ setAccessTokensToServers,
+ testImage,
+ updateVideo,
+ uploadVideo,
+ userLogin,
+ viewVideo,
+ wait,
+ webtorrentAdd
} from '../../utils'
import {
- addVideoCommentReply, addVideoCommentThread, deleteVideoComment, getVideoCommentThreads,
+ addVideoCommentReply,
+ addVideoCommentThread,
+ deleteVideoComment,
+ getVideoCommentThreads,
getVideoThreadComments
} from '../../utils/videos/video-comments'
nsfw: true,
description: 'my super description for server 1',
support: 'my super support text for server 1',
- host: 'localhost:9001',
- account: 'root',
+ account: {
+ name: 'root',
+ host: 'localhost:9001'
+ },
isLocal,
duration: 10,
tags: [ 'tag1p1', 'tag2p1' ],
nsfw: true,
description: 'my super description for server 2',
support: 'my super support text for server 2',
- host: 'localhost:9002',
- account: 'user1',
+ account: {
+ name: 'user1',
+ host: 'localhost:9002'
+ },
isLocal,
commentsEnabled: true,
duration: 5,
nsfw: true,
description: 'my super description for server 3',
support: 'my super support text for server 3',
- host: 'localhost:9003',
- account: 'root',
+ account: {
+ name: 'root',
+ host: 'localhost:9003'
+ },
isLocal,
duration: 5,
commentsEnabled: true,
nsfw: false,
description: 'my super description for server 3-2',
support: 'my super support text for server 3-2',
- host: 'localhost:9003',
- account: 'root',
+ account: {
+ name: 'root',
+ host: 'localhost:9003'
+ },
commentsEnabled: true,
isLocal,
duration: 5,
nsfw: true,
description: 'my super description updated',
support: 'my super support text updated',
- host: 'localhost:9003',
- account: 'root',
+ account: {
+ name: 'root',
+ host: 'localhost:9003'
+ },
isLocal,
duration: 5,
commentsEnabled: true,
expect(baseVideo.licence).to.equal(video.licence)
expect(baseVideo.category).to.equal(video.category)
expect(baseVideo.nsfw).to.equal(video.nsfw)
- expect(baseVideo.accountName).to.equal(video.accountName)
+ expect(baseVideo.account.name).to.equal(video.account.name)
+ expect(baseVideo.account.displayName).to.equal(video.account.displayName)
+ expect(baseVideo.account.url).to.equal(video.account.url)
+ expect(baseVideo.account.host).to.equal(video.account.host)
expect(baseVideo.tags).to.deep.equal(video.tags)
}
})
nsfw: false,
description: null,
support: null,
- host: 'localhost:9002',
- account: 'root',
+ account: {
+ name: 'root',
+ host: 'localhost:9002'
+ },
isLocal,
duration: 5,
commentsEnabled: true,
expect(res.body.html).to.equal(expectedHtml)
expect(res.body.title).to.equal(server.video.name)
- expect(res.body.author_name).to.equal(server.video.accountName)
+ expect(res.body.author_name).to.equal(server.video.account.name)
expect(res.body.width).to.equal(560)
expect(res.body.height).to.equal(315)
expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
expect(res.body.html).to.equal(expectedHtml)
expect(res.body.title).to.equal(server.video.name)
- expect(res.body.author_name).to.equal(server.video.accountName)
+ expect(res.body.author_name).to.equal(server.video.account.name)
expect(res.body.height).to.equal(50)
expect(res.body.width).to.equal(50)
expect(res.body).to.not.have.property('thumbnail_url')
nsfw: true,
description: 'my super description',
support: 'my super support text',
- host: 'localhost:9001',
- account: 'root',
+ account: {
+ name: 'root',
+ host: 'localhost:9001'
+ },
isLocal: true,
duration: 5,
tags: [ 'tag1', 'tag2', 'tag3' ],
nsfw: false,
description: 'my super description updated',
support: 'my super support text updated',
- host: 'localhost:9001',
- account: 'root',
+ account: {
+ name: 'root',
+ host: 'localhost:9001'
+ },
isLocal: true,
tags: [ 'tagup1', 'tagup2' ],
privacy: VideoPrivacy.PUBLIC,
await completeVideoCheck(server.url, video, getCheckAttributes)
})
- // Not implemented yet
- // it('Should search the video by serverHost', async function () {
- // const res = await videosUtils.searchVideo(server.url, '9001', 'host')
-
- // expect(res.body.total).to.equal(1)
- // expect(res.body.data).to.be.an('array')
- // expect(res.body.data.length).to.equal(1)
-
- // const video = res.body.data[0]
- // expect(video.name).to.equal('my super name')
- // expect(video.description).to.equal('my super description')
- // expect(video.serverHost).to.equal('localhost:9001')
- // expect(video.author).to.equal('root')
- // expect(video.isLocal).to.be.true
- // expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
- // expect(dateIsValid(video.createdAt)).to.be.true
- // expect(dateIsValid(video.updatedAt)).to.be.true
-
- // const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath)
- // expect(test).to.equal(true)
-
- // done()
- // })
- // })
- // })
-
// Not implemented yet
// it('Should search the video by tag', async function () {
// const res = await searchVideo(server.url, 'tag1')
// expect(video.languageLabel).to.equal('Mandarin')
// expect(video.nsfw).to.be.ok
// expect(video.description).to.equal('my super description')
- // expect(video.serverHost).to.equal('localhost:9001')
- // expect(video.accountName).to.equal('root')
+ // expect(video.account.name).to.equal('root')
+ // expect(video.account.host).to.equal('localhost:9001')
// expect(video.isLocal).to.be.true
// expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
// expect(dateIsValid(video.createdAt)).to.be.true
id: number
uuid: string
name: string
- accountName: string
+ account: {
+ name: string
+ }
}
remoteVideo?: {
commentsEnabled: boolean
description: string
support: string
- host: string
- account: string
+ account: {
+ name: string
+ host: string
+ }
isLocal: boolean,
tags: string[],
privacy: number,
expect(video.languageLabel).to.equal(VIDEO_LANGUAGES[attributes.language] || 'Unknown')
expect(video.nsfw).to.equal(attributes.nsfw)
expect(video.description).to.equal(attributes.description)
- expect(video.serverHost).to.equal(attributes.host)
- expect(video.accountName).to.equal(attributes.account)
+ expect(video.account.host).to.equal(attributes.account.host)
+ expect(video.account.name).to.equal(attributes.account.name)
expect(video.likes).to.equal(attributes.likes)
expect(video.dislikes).to.equal(attributes.dislikes)
expect(video.isLocal).to.equal(attributes.isLocal)
let extension = extname(attributes.fixture)
// Transcoding enabled on server 2, extension will always be .mp4
- if (attributes.host === 'localhost:9002') extension = '.mp4'
+ if (attributes.account.host === 'localhost:9002') extension = '.mp4'
const magnetUri = file.magnetUri
expect(file.magnetUri).to.have.lengthOf.above(2)
- expect(file.torrentUrl).to.equal(`http://${attributes.host}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
- expect(file.fileUrl).to.equal(`http://${attributes.host}/static/webseed/${videoDetails.uuid}-${file.resolution}${extension}`)
+ expect(file.torrentUrl).to.equal(`http://${attributes.account.host}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
+ expect(file.fileUrl).to.equal(`http://${attributes.account.host}/static/webseed/${videoDetails.uuid}-${file.resolution}${extension}`)
expect(file.resolution).to.equal(attributeFile.resolution)
expect(file.resolutionLabel).to.equal(attributeFile.resolution + 'p')
import { Account } from '../actors'
+import { Avatar } from '../avatars/avatar.model'
import { VideoChannel } from './video-channel.model'
import { VideoPrivacy } from './video-privacy.enum'
export interface Video {
id: number
uuid: string
- accountName: string
createdAt: Date | string
updatedAt: Date | string
categoryLabel: string
duration: number
isLocal: boolean
name: string
- serverHost: string
thumbnailPath: string
previewPath: string
embedPath: string
likes: number
dislikes: number
nsfw: boolean
+
+ account: {
+ name: string
+ displayName: string
+ url: string
+ host: string
+ avatar: Avatar
+ }
}
export interface VideoDetails extends Video {
type: number
uuid:
type: string
- accountName:
- type: string
createdAt:
type: string
updatedAt:
type: boolean
name:
type: string
- serverHost:
- type: string
thumbnailPath:
type: string
previewPath:
type: number
nsfw:
type: boolean
+ account:
+ name: string
+ displayName: string
+ url: string
+ host: string
+ avatar:
+ $ref: "#/definitions/Avatar"
VideoAbuse:
properties:
id:
[Unit]
Description=PeerTube daemon
-After=network.target
+After=network.target postgresql.service
[Service]
Type=simple