Skip to content

Commit

Permalink
fix(reader): assign to comment dto
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Sep 16, 2024
1 parent e49f80e commit 764e30f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions apps/core/src/modules/comment/comment.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ export class CommentController {
isWhispers: parent.isWhispers,
}

await this.commentService.assignReaderToComment(model)

const comment = await this.commentService.model.create(model)
const commentId = comment._id.toString()
scheduleManager.schedule(async () => {
Expand Down
14 changes: 9 additions & 5 deletions apps/core/src/modules/comment/comment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,7 @@ export class CommentService implements OnModuleInit {
return res
}

async createComment(
id: string,
doc: Partial<CommentModel>,
type?: CollectionRefTypes,
) {
async assignReaderToComment(doc: Partial<CommentModel>) {
const readerId = RequestContext.currentRequest()?.readerId

let reader: ReaderModel | null = null
Expand All @@ -174,7 +170,15 @@ export class CommentService implements OnModuleInit {
if (reader) {
doc.author = reader.name
doc.mail = reader.email
doc.avatar = reader.image
}
}
async createComment(
id: string,
doc: Partial<CommentModel>,
type?: CollectionRefTypes,
) {
await this.assignReaderToComment(doc)

let ref: (WriteBaseModel & { _id: any }) | null = null
let refType = type
Expand Down

0 comments on commit 764e30f

Please sign in to comment.