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