]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/+video-watch/comment/video-comment.model.ts
Merge branch 'master' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / comment / video-comment.model.ts
1 import { Account as AccountInterface } from '../../../../../../shared/models/actors'
2 import { VideoComment as VideoCommentServerModel } from '../../../../../../shared/models/videos/video-comment.model'
3 import { Actor } from '@app/shared/actor/actor.model'
4 import { getAbsoluteAPIUrl } from '@app/shared/misc/utils'
5
6 export class VideoComment implements VideoCommentServerModel {
7 id: number
8 url: string
9 text: string
10 threadId: number
11 inReplyToCommentId: number
12 videoId: number
13 createdAt: Date | string
14 updatedAt: Date | string
15 account: AccountInterface
16 totalReplies: number
17 by: string
18 accountAvatarUrl: string
19
20 isLocal: boolean
21
22 constructor (hash: VideoCommentServerModel) {
23 this.id = hash.id
24 this.url = hash.url
25 this.text = hash.text
26 this.threadId = hash.threadId
27 this.inReplyToCommentId = hash.inReplyToCommentId
28 this.videoId = hash.videoId
29 this.createdAt = new Date(hash.createdAt.toString())
30 this.updatedAt = new Date(hash.updatedAt.toString())
31 this.account = hash.account
32 this.totalReplies = hash.totalReplies
33
34 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
35 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
36
37 const absoluteAPIUrl = getAbsoluteAPIUrl()
38 const thisHost = new URL(absoluteAPIUrl).host
39 this.isLocal = this.account.host.trim() === thisHost
40 }
41 }