comments
This commit is contained in:
parent
52b5a490ac
commit
ebc314f638
9 changed files with 226 additions and 33 deletions
|
@ -8,6 +8,12 @@ export interface PostReaction {
|
|||
reactedOn: Temporal.Instant
|
||||
}
|
||||
|
||||
export interface PostComment {
|
||||
author: string
|
||||
content: string
|
||||
postedOn: Temporal.Instant
|
||||
}
|
||||
|
||||
export class Post {
|
||||
[immerable] = true
|
||||
|
||||
|
@ -18,6 +24,7 @@ export class Post {
|
|||
public readonly authorName: string
|
||||
public readonly reactions: PostReaction[]
|
||||
public readonly possibleReactions: string[]
|
||||
public readonly comments: PostComment[]
|
||||
|
||||
constructor(
|
||||
postId: string,
|
||||
|
@ -25,8 +32,9 @@ export class Post {
|
|||
media: PostMedia[],
|
||||
createdAt: string | Temporal.Instant,
|
||||
authorName: string,
|
||||
reactions: PostReaction[] = [],
|
||||
possibleReactions: string[] = [],
|
||||
reactions: PostReaction[],
|
||||
possibleReactions: string[],
|
||||
comments: PostComment[],
|
||||
) {
|
||||
this.postId = postId
|
||||
this.content = content
|
||||
|
@ -35,6 +43,7 @@ export class Post {
|
|||
this.authorName = authorName
|
||||
this.reactions = reactions
|
||||
this.possibleReactions = possibleReactions
|
||||
this.comments = comments
|
||||
}
|
||||
|
||||
public static fromDto(dto: components['schemas']['PostDto']): Post {
|
||||
|
@ -46,6 +55,7 @@ export class Post {
|
|||
dto.author.username,
|
||||
dto.reactions.map((r) => ({ ...r, reactedOn: Temporal.Instant.from(r.reactedOn) })),
|
||||
dto.possibleReactions,
|
||||
dto.comments.map((c) => ({ ...c, postedOn: Temporal.Instant.from(c.postedOn) })),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue