Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
feat: 시그니처 댓글 작성시 알림을 발송하라
Browse files Browse the repository at this point in the history
  • Loading branch information
kaaang committed Feb 18, 2024
1 parent 560b212 commit a7c68e5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/signature/signature.comment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { GetCommentWriterDto } from './dto/comment/get-comment-writer.dto';
import * as querystring from 'querystring';
import { CursorPageMetaDto } from '../mate/cursor-page/cursor-page.meta.dto';
import { CursorPageDto } from '../mate/cursor-page/cursor-page.dto';
import { NotificationEntity } from '../notification/notification.entity';

@Injectable()
export class SignatureCommentService{
Expand Down Expand Up @@ -48,6 +49,9 @@ export class SignatureCommentService{
comment.signature = signature;
comment.content = createCommentDto.content;

// 알림 생성
const notification = new NotificationEntity();

// parentCommentId가 존재할 경우 -> 답글 / 존재하지 않을 경우 -> 댓글
if(parentCommentId){ // 대댓글: parentId는 파라미터로 받은 parentCommentId로 설정

Expand All @@ -61,13 +65,22 @@ export class SignatureCommentService{
await comment.save();
}

notification.notificationReceiver = parentComment.user;
}
else{ // 댓글: parentId는 본인으로 설정
const savedComment = await comment.save();
savedComment.parentComment = savedComment;
await savedComment.save();

notification.notificationReceiver = signature.user;
}

notification.notificationSender = user;
notification.notificationTargetType = 'SIGNATURE';
notification.notificationTargetId = signature.id;
notification.notificationAction = 'COMMENT';
await notification.save();

return comment.id;
}
}
Expand Down

0 comments on commit a7c68e5

Please sign in to comment.