1 import { getAbsoluteAPIUrl } from '@app/helpers'
2 import { Account, Actor, Video } from '@app/shared/shared-main'
3 import { Account as AccountInterface, VideoComment as VideoCommentServerModel, VideoCommentAdmin as VideoCommentAdminServerModel } from '@shared/models'
5 export class VideoComment implements VideoCommentServerModel {
10 inReplyToCommentId: number
12 createdAt: Date | string
13 updatedAt: Date | string
14 deletedAt: Date | string
16 account: AccountInterface
17 totalRepliesFromVideoAuthor: number
23 constructor (hash: VideoCommentServerModel) {
27 this.threadId = hash.threadId
28 this.inReplyToCommentId = hash.inReplyToCommentId
29 this.videoId = hash.videoId
30 this.createdAt = new Date(hash.createdAt.toString())
31 this.updatedAt = new Date(hash.updatedAt.toString())
32 this.deletedAt = hash.deletedAt ? new Date(hash.deletedAt.toString()) : null
33 this.isDeleted = hash.isDeleted
34 this.account = hash.account
35 this.totalRepliesFromVideoAuthor = hash.totalRepliesFromVideoAuthor
36 this.totalReplies = hash.totalReplies
39 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
41 const absoluteAPIUrl = getAbsoluteAPIUrl()
42 const thisHost = new URL(absoluteAPIUrl).host
43 this.isLocal = this.account.host.trim() === thisHost
48 export class VideoCommentAdmin implements VideoCommentAdminServerModel {
55 inReplyToCommentId: number
57 createdAt: Date | string
58 updatedAt: Date | string
60 account: AccountInterface & { localUrl?: string }
72 constructor (hash: VideoCommentAdminServerModel, textHtml: string) {
76 this.textHtml = textHtml
78 this.threadId = hash.threadId
79 this.inReplyToCommentId = hash.inReplyToCommentId
81 this.createdAt = new Date(hash.createdAt.toString())
82 this.updatedAt = new Date(hash.updatedAt.toString())
86 uuid: hash.video.uuid,
87 name: hash.video.name,
88 localUrl: Video.buildWatchUrl(hash.video)
91 this.localUrl = this.video.localUrl + ';threadId=' + this.threadId
93 this.account = hash.account
96 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
98 this.account.localUrl = '/a/' + this.by