]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/+video-watch/comment/video-comment.model.ts
Soft delete video comments instead of detroy
[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 deletedAt: Date | string
16 isDeleted: boolean
17 account: AccountInterface
18 totalReplies: number
19 by: string
20 accountAvatarUrl: string
21
22 isLocal: boolean
23
24 constructor (hash: VideoCommentServerModel) {
25 this.id = hash.id
26 this.url = hash.url
27 this.text = hash.text
28 this.threadId = hash.threadId
29 this.inReplyToCommentId = hash.inReplyToCommentId
30 this.videoId = hash.videoId
31 this.createdAt = new Date(hash.createdAt.toString())
32 this.updatedAt = new Date(hash.updatedAt.toString())
33 this.deletedAt = hash.deletedAt ? new Date(hash.deletedAt.toString()) : null
34 this.isDeleted = hash.isDeleted
35 this.account = hash.account
36 this.totalReplies = hash.totalReplies
37
38 if (this.account) {
39 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
40 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
41
42 const absoluteAPIUrl = getAbsoluteAPIUrl()
43 const thisHost = new URL(absoluteAPIUrl).host
44 this.isLocal = this.account.host.trim() === thisHost
45 }
46 }
47 }