Skip to content

Commit 1392d86

Browse files
committed
fix: 세모피드 이모지 알림 필수 값 검증 추가
1 parent 8817dbb commit 1392d86

4 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/main/java/com/semosan/api/domain/notification/enums/NotificationType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public enum NotificationType {
3232
SEMOFEED_EMOJI(
3333
"세모피드에 반응이 달렸어요",
3434
"{actorName}님이 세모피드에 {emojiType} 반응을 남겼어요",
35-
Set.of("actorName", "emojiType"),
35+
Set.of("actorId", "actorName", "semoFeedId", "emojiType"),
3636
false
3737
),
3838

src/main/java/com/semosan/api/domain/semofeed/notification/service/SemoFeedNotificationService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class SemoFeedNotificationService {
1818
private final NotificationService notificationService;
1919
private final UserRepository userRepository;
2020

21+
// 세모피드에 새 이모지 반응이 등록되면 작성자에게 알림을 보냅니다.
2122
public void sendEmojiNotification(SemoFeed semoFeed, User reactor, SemoFeedEmojiType emojiType) {
2223
User receiver = semoFeed.getUser();
2324
sendIfEligible(
@@ -32,6 +33,7 @@ public void sendEmojiNotification(SemoFeed semoFeed, User reactor, SemoFeedEmoji
3233
);
3334
}
3435

36+
// 본인 반응과 탈퇴한 작성자는 알림 발송 대상에서 제외합니다.
3537
private void sendIfEligible(User receiver, User reactor, Map<String, Object> params) {
3638
if (receiver.getId().equals(reactor.getId())) {
3739
return;

src/main/java/com/semosan/api/domain/semofeed/service/SemoFeedEmojiService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public SemoFeedEmojiToggleResponse toggleWithCount(
3939

4040
boolean reacted = toggle(semoFeed, user, emojiType);
4141
if (reacted) {
42+
// 새 반응 등록일 때만 작성자 알림을 발송합니다.
4243
semoFeedNotificationService.sendEmojiNotification(semoFeed, user, emojiType);
4344
}
4445
long count = semoFeedEmojiRepository.countBySemoFeedAndEmojiType(semoFeed, emojiType);

src/test/java/com/semosan/api/domain/semofeed/notification/service/SemoFeedNotificationServiceTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import org.mockito.junit.jupiter.MockitoExtension;
1515
import org.springframework.test.util.ReflectionTestUtils;
1616

17+
import java.util.Map;
18+
19+
import static org.assertj.core.api.Assertions.assertThatCode;
1720
import static org.mockito.ArgumentMatchers.argThat;
1821
import static org.mockito.ArgumentMatchers.eq;
1922
import static org.mockito.Mockito.never;
@@ -32,6 +35,16 @@ class SemoFeedNotificationServiceTest {
3235
@InjectMocks
3336
private SemoFeedNotificationService semoFeedNotificationService;
3437

38+
@Test
39+
void semoFeedEmojiNotificationTypeRequiresNavigationPayload() {
40+
assertThatCode(() -> NotificationType.SEMOFEED_EMOJI.validate(Map.of(
41+
"actorId", 2L,
42+
"actorName", "reactor",
43+
"semoFeedId", 10L,
44+
"emojiType", "FIRE"
45+
))).doesNotThrowAnyException();
46+
}
47+
3548
@Test
3649
void sendEmojiNotificationSendsToSemoFeedAuthor() {
3750
User author = user(1L, "author");

0 commit comments

Comments
 (0)