]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-video-comment/video-comment.model.ts
Move to sass module
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-video-comment / video-comment.model.ts
CommitLineData
67ed6552 1import { getAbsoluteAPIUrl } from '@app/helpers'
c418d483 2import { Account, Actor } from '@app/shared/shared-main'
0f8d00e3 3import { Account as AccountInterface, VideoComment as VideoCommentServerModel, VideoCommentAdmin as VideoCommentAdminServerModel } from '@shared/models'
4635f59d
C
4
5export class VideoComment implements VideoCommentServerModel {
6 id: number
7 url: string
8 text: string
9 threadId: number
10 inReplyToCommentId: number
11 videoId: number
12 createdAt: Date | string
13 updatedAt: Date | string
69222afa
JM
14 deletedAt: Date | string
15 isDeleted: boolean
76d36e0b 16 account: AccountInterface
5b0413dd 17 totalRepliesFromVideoAuthor: number
4635f59d 18 totalReplies: number
4635f59d
C
19 by: string
20
7e73f071
C
21 isLocal: boolean
22
4635f59d
C
23 constructor (hash: VideoCommentServerModel) {
24 this.id = hash.id
25 this.url = hash.url
26 this.text = hash.text
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())
69222afa
JM
32 this.deletedAt = hash.deletedAt ? new Date(hash.deletedAt.toString()) : null
33 this.isDeleted = hash.isDeleted
4635f59d 34 this.account = hash.account
5b0413dd 35 this.totalRepliesFromVideoAuthor = hash.totalRepliesFromVideoAuthor
4635f59d
C
36 this.totalReplies = hash.totalReplies
37
69222afa
JM
38 if (this.account) {
39 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
7e73f071 40
69222afa
JM
41 const absoluteAPIUrl = getAbsoluteAPIUrl()
42 const thisHost = new URL(absoluteAPIUrl).host
43 this.isLocal = this.account.host.trim() === thisHost
44 }
4635f59d
C
45 }
46}
0f8d00e3
C
47
48export class VideoCommentAdmin implements VideoCommentAdminServerModel {
49 id: number
50 url: string
51 text: string
52 textHtml: string
53
54 threadId: number
55 inReplyToCommentId: number
56
57 createdAt: Date | string
58 updatedAt: Date | string
59
f1273314
C
60 account: AccountInterface & { localUrl?: string }
61 localUrl: string
0f8d00e3
C
62
63 video: {
64 id: number
65 uuid: string
66 name: string
f1273314 67 localUrl: string
0f8d00e3
C
68 }
69
70 by: string
0f8d00e3
C
71
72 constructor (hash: VideoCommentAdminServerModel, textHtml: string) {
73 this.id = hash.id
74 this.url = hash.url
75 this.text = hash.text
76 this.textHtml = textHtml
77
78 this.threadId = hash.threadId
79 this.inReplyToCommentId = hash.inReplyToCommentId
80
81 this.createdAt = new Date(hash.createdAt.toString())
82 this.updatedAt = new Date(hash.updatedAt.toString())
83
84 this.video = {
85 id: hash.video.id,
86 uuid: hash.video.uuid,
f1273314 87 name: hash.video.name,
a1eda903 88 localUrl: '/w/' + hash.video.uuid
0f8d00e3
C
89 }
90
f1273314
C
91 this.localUrl = this.video.localUrl + ';threadId=' + this.threadId
92
0f8d00e3
C
93 this.account = hash.account
94
95 if (this.account) {
96 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
f1273314 97
71887396 98 this.account.localUrl = '/a/' + this.by
0f8d00e3
C
99 }
100 }
101}