Skip to content

Commit

Permalink
Merge pull request #210 from CHZZK-Study/dev
Browse files Browse the repository at this point in the history
[fix] 댓글 이메일 알림이 느렸던 현상 해소
  • Loading branch information
HongYeseul authored Oct 30, 2024
2 parents bb9bfdd + 1cacbe9 commit 46a5cd5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/java/chzzk/grassdiary/GrassdiaryApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableAsync
@EnableScheduling
@EnableJpaAuditing
@SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import chzzk.grassdiary.domain.comment.service.CommentService;
import chzzk.grassdiary.global.auth.common.AuthenticatedMember;
import chzzk.grassdiary.global.auth.service.dto.AuthMemberPayload;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand All @@ -28,10 +30,13 @@ public class CommentController {
private final CommentService commentService;

@PostMapping("/{diaryId}")
@Operation(
summary = "댓글 작성 요청",
description = "댓글 내용, 부모 댓글이 있다면 id 값, 없다면 null")
public CommentResponseDTO save(
@PathVariable(name = "diaryId") Long diaryId,
@Schema(hidden = true) @PathVariable(name = "diaryId") Long diaryId,
@RequestBody CommentSaveRequestDTO requestDTO,
@AuthenticatedMember AuthMemberPayload payload
@Schema(hidden = true) @AuthenticatedMember AuthMemberPayload payload
) {
return commentService.save(diaryId, requestDTO, payload.id());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import chzzk.grassdiary.domain.member.entity.Member;

public record CommentSaveRequestDTO(
Long memberId,
Long diaryId,
String content,
Long parentCommentId
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package chzzk.grassdiary.domain.notification;

import jakarta.mail.MessagingException;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;
Expand All @@ -12,8 +12,12 @@ public class EmailNotificationListener {

private final EmailService emailService;

/**
* 댓글 알림 이벤트 리스너
*/
@Async
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
public void handleCommentCreatedEvent(CommentCreatedEvent event) throws MessagingException {
public void handleCommentCreatedEvent(CommentCreatedEvent event) {
emailService.sendCommentNotification(event);
}
}

0 comments on commit 46a5cd5

Please sign in to comment.