]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/+video-watch/comment/video-comment.model.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / comment / video-comment.model.ts
CommitLineData
76d36e0b 1import { Account as AccountInterface } from '../../../../../../shared/models/actors'
be27ef3b 2import { VideoComment as VideoCommentServerModel, VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model'
d3e91a5f 3import { Actor } from '@app/shared/actor/actor.model'
7e73f071 4import { getAbsoluteAPIUrl } from '@app/shared/misc/utils'
4635f59d
C
5
6export 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
69222afa
JM
15 deletedAt: Date | string
16 isDeleted: boolean
76d36e0b 17 account: AccountInterface
5b0413dd 18 totalRepliesFromVideoAuthor: number
4635f59d 19 totalReplies: number
4635f59d 20 by: string
244b4ae3 21 accountAvatarUrl: string
4635f59d 22
7e73f071
C
23 isLocal: boolean
24
4635f59d
C
25 constructor (hash: VideoCommentServerModel) {
26 this.id = hash.id
27 this.url = hash.url
28 this.text = hash.text
29 this.threadId = hash.threadId
30 this.inReplyToCommentId = hash.inReplyToCommentId
31 this.videoId = hash.videoId
32 this.createdAt = new Date(hash.createdAt.toString())
33 this.updatedAt = new Date(hash.updatedAt.toString())
69222afa
JM
34 this.deletedAt = hash.deletedAt ? new Date(hash.deletedAt.toString()) : null
35 this.isDeleted = hash.isDeleted
4635f59d 36 this.account = hash.account
5b0413dd 37 this.totalRepliesFromVideoAuthor = hash.totalRepliesFromVideoAuthor
4635f59d
C
38 this.totalReplies = hash.totalReplies
39
69222afa
JM
40 if (this.account) {
41 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
42 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
7e73f071 43
69222afa
JM
44 const absoluteAPIUrl = getAbsoluteAPIUrl()
45 const thisHost = new URL(absoluteAPIUrl).host
46 this.isLocal = this.account.host.trim() === thisHost
47 }
4635f59d
C
48 }
49}