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