2018-08-21 16:18:59 +02:00
|
|
|
import { UserRight, VideoConstant, VideoDetails as VideoDetailsServerModel, VideoFile, VideoState } from '../../../../../shared'
|
2018-01-03 10:12:36 +01:00
|
|
|
import { AuthUser } from '../../core'
|
|
|
|
import { Video } from '../../shared/video/video.model'
|
2018-05-25 09:57:16 +02:00
|
|
|
import { Account } from '@app/shared/account/account.model'
|
2018-08-21 16:18:59 +02:00
|
|
|
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
|
2017-10-25 16:43:19 +02:00
|
|
|
|
|
|
|
export class VideoDetails extends Video implements VideoDetailsServerModel {
|
2018-03-19 11:04:40 +01:00
|
|
|
descriptionPath: string
|
2018-02-15 14:46:26 +01:00
|
|
|
support: string
|
2018-03-19 11:04:40 +01:00
|
|
|
channel: VideoChannel
|
2017-10-25 16:43:19 +02:00
|
|
|
tags: string[]
|
|
|
|
files: VideoFile[]
|
2017-12-06 17:15:59 +01:00
|
|
|
account: Account
|
2018-03-19 11:04:40 +01:00
|
|
|
commentsEnabled: boolean
|
2018-10-06 19:17:21 +02:00
|
|
|
downloadingEnabled: boolean
|
2018-03-19 11:04:40 +01:00
|
|
|
|
2018-06-12 20:04:58 +02:00
|
|
|
waitTranscoding: boolean
|
|
|
|
state: VideoConstant<VideoState>
|
|
|
|
|
2017-12-06 18:04:40 +01:00
|
|
|
likesPercent: number
|
|
|
|
dislikesPercent: number
|
2017-10-25 16:43:19 +02:00
|
|
|
|
2018-06-06 16:46:42 +02:00
|
|
|
constructor (hash: VideoDetailsServerModel, translations = {}) {
|
|
|
|
super(hash, translations)
|
2017-10-25 16:43:19 +02:00
|
|
|
|
2017-10-30 20:26:06 +01:00
|
|
|
this.descriptionPath = hash.descriptionPath
|
2017-10-25 16:43:19 +02:00
|
|
|
this.files = hash.files
|
2018-08-21 16:18:59 +02:00
|
|
|
this.channel = new VideoChannel(hash.channel)
|
2018-05-25 09:57:16 +02:00
|
|
|
this.account = new Account(hash.account)
|
2017-12-14 10:07:57 +01:00
|
|
|
this.tags = hash.tags
|
2018-02-20 16:13:05 +01:00
|
|
|
this.support = hash.support
|
2018-01-03 10:12:36 +01:00
|
|
|
this.commentsEnabled = hash.commentsEnabled
|
2018-10-06 19:17:21 +02:00
|
|
|
this.downloadingEnabled = hash.downloadingEnabled
|
2017-12-06 18:04:40 +01:00
|
|
|
|
2018-02-28 09:49:40 +01:00
|
|
|
this.buildLikeAndDislikePercents()
|
2017-10-25 16:43:19 +02:00
|
|
|
}
|
|
|
|
|
2017-10-27 16:55:03 +02:00
|
|
|
isRemovableBy (user: AuthUser) {
|
2018-03-19 11:04:40 +01:00
|
|
|
return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.REMOVE_ANY_VIDEO))
|
2017-10-25 16:43:19 +02:00
|
|
|
}
|
|
|
|
|
2017-10-27 16:55:03 +02:00
|
|
|
isBlackistableBy (user: AuthUser) {
|
2018-08-14 09:08:47 +02:00
|
|
|
return this.blacklisted !== true && user && user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) === true
|
|
|
|
}
|
|
|
|
|
|
|
|
isUnblacklistableBy (user: AuthUser) {
|
|
|
|
return this.blacklisted === true && user && user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) === true
|
2017-10-25 16:43:19 +02:00
|
|
|
}
|
|
|
|
|
2017-10-27 16:55:03 +02:00
|
|
|
isUpdatableBy (user: AuthUser) {
|
2018-03-19 11:04:40 +01:00
|
|
|
return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.UPDATE_ANY_VIDEO))
|
2017-10-25 16:43:19 +02:00
|
|
|
}
|
2018-02-28 09:49:40 +01:00
|
|
|
|
|
|
|
buildLikeAndDislikePercents () {
|
|
|
|
this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
|
|
|
|
this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100
|
|
|
|
}
|
2017-10-25 16:43:19 +02:00
|
|
|
}
|