]>
Commit | Line | Data |
---|---|---|
76d36e0b | 1 | import { Account as AccountInterface } from '../../../../../../shared/models/actors' |
4635f59d | 2 | import { VideoComment as VideoCommentServerModel } from '../../../../../../shared/models/videos/video-comment.model' |
d3e91a5f | 3 | import { Actor } from '@app/shared/actor/actor.model' |
7e73f071 | 4 | import { getAbsoluteAPIUrl } from '@app/shared/misc/utils' |
4635f59d C |
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 | |
69222afa JM |
15 | deletedAt: Date | string |
16 | isDeleted: boolean | |
76d36e0b | 17 | account: AccountInterface |
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 C |
35 | this.account = hash.account |
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) | |
40 | this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account) | |
7e73f071 | 41 | |
69222afa JM |
42 | const absoluteAPIUrl = getAbsoluteAPIUrl() |
43 | const thisHost = new URL(absoluteAPIUrl).host | |
44 | this.isLocal = this.account.host.trim() === thisHost | |
45 | } | |
4635f59d C |
46 | } |
47 | } |