Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/main/java/com/wellmeet/config/WebPushConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.wellmeet.config;

import java.security.GeneralSecurityException;
import java.security.Security;
import lombok.RequiredArgsConstructor;
import nl.martijndwars.webpush.PushService;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
@Profile("!test")
@RequiredArgsConstructor
public class WebPushConfig {

private final VapidConfig vapidConfig;

@Bean
public PushService pushService() throws GeneralSecurityException {
Security.addProvider(new BouncyCastleProvider());
PushService pushService = new PushService();
pushService.setPublicKey(vapidConfig.getPublicKey());
pushService.setPrivateKey(vapidConfig.getPrivateKey());
pushService.setSubject(vapidConfig.getSubject());
return pushService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class NotificationSender {
public void send(NotificationMessage message, List<NotificationEnabled> enables) {
NotificationHistory history = new NotificationHistory(message.getRecipient(),
message.getPayload().toString());
notificationHistoryRepository.save(history);
for (NotificationEnabled enabled : enables) {
notificationHistoryRepository.save(history);
Sender sender = senders.stream()
.filter(low -> low.isEnabled(enabled.getChannel()))
.findFirst()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ public class MessageHeader {

private String messageId;
private LocalDateTime timestamp;
private String source;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
@Getter
public enum NotificationType {

RESERVATION_CREATED
RESERVATION_CREATED,
RESERVATION_CONFIRMED,
RESERVATION_UPDATED,
RESERVATION_CANCELED,
Comment on lines +8 to +11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

예약 생명주기를 위한 알림 타입 추가가 적절합니다.

새로운 알림 타입들(RESERVATION_CONFIRMED, RESERVATION_UPDATED, RESERVATION_CANCELED)이 PR 목표와 일치하며, 네이밍 컨벤션도 올바르게 적용되었습니다.

다만 코드베이스 전체에서 이 새로운 알림 타입들을 올바르게 처리하는지 확인해 주세요. 특히 알림 소비자(consumer)와 생성자(producer) 쪽에서 모든 타입에 대한 처리 로직이 구현되어 있는지 검증이 필요합니다.

다음 스크립트를 실행하여 새로운 알림 타입의 사용처를 확인하세요:


🏁 Script executed:

#!/bin/bash
# Description: 새로운 NotificationType 상수들이 코드베이스에서 어떻게 사용되는지 확인

echo "=== RESERVATION_CONFIRMED 사용처 ==="
rg -n "RESERVATION_CONFIRMED" --type java -C 3

echo -e "\n=== RESERVATION_UPDATED 사용처 ==="
rg -n "RESERVATION_UPDATED" --type java -C 3

echo -e "\n=== RESERVATION_CANCELED 사용처 ==="
rg -n "RESERVATION_CANCELED" --type java -C 3

echo -e "\n=== NotificationType switch/if 분기 처리 ==="
rg -n "NotificationType\." --type java -A 10 | rg -A 10 "switch|case"

Length of output: 1885


새 알림 타입에 대한 핸들링 로직 구현 필요

새로 추가된 RESERVATION_CONFIRMED, RESERVATION_UPDATED, RESERVATION_CANCELED 타입이 enum에만 정의되어 있으며, 알림 소비자·생성자 코드에서 해당 타입을 처리하는 분기나 핸들러가 없습니다. 각 이벤트에 맞춰 알림 발송·수신 로직을 구현해주세요.

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import com.wellmeet.notification.webpush.dto.SubscribeResponse;
import com.wellmeet.notification.webpush.dto.TestPushRequest;
import com.wellmeet.notification.webpush.dto.UnsubscribeRequest;
import com.wellmeet.notification.webpush.infrastructure.WebPushSender;
import com.wellmeet.notification.webpush.repository.PushSubscriptionRepository;
import com.wellmeet.notification.webpush.sender.WebPushSender;
import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wellmeet.notification.webpush.infrastructure;
package com.wellmeet.notification.webpush.sender;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.wellmeet.config.VapidConfig;
import com.wellmeet.exception.ErrorCode;
import com.wellmeet.exception.WellMeetNotificationException;
import com.wellmeet.notification.Sender;
Expand All @@ -10,10 +9,8 @@
import com.wellmeet.notification.webpush.domain.PushSubscription;
import com.wellmeet.notification.webpush.dto.TestPushRequest;
import com.wellmeet.notification.webpush.repository.PushSubscriptionRepository;
import jakarta.annotation.PostConstruct;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.Security;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -23,7 +20,6 @@
import nl.martijndwars.webpush.PushService;
import nl.martijndwars.webpush.Subscription;
import nl.martijndwars.webpush.Subscription.Keys;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.jose4j.lang.JoseException;
import org.springframework.stereotype.Service;

Expand All @@ -32,22 +28,8 @@
public class WebPushSender implements Sender {

private final PushSubscriptionRepository pushSubscriptionRepository;
private final VapidConfig vapidConfig;
private final PushService pushService;
private final ObjectMapper objectMapper = new ObjectMapper();
private PushService pushService;

@PostConstruct
public void init() {
Security.addProvider(new BouncyCastleProvider());
try {
pushService = new PushService();
pushService.setPublicKey(vapidConfig.getPublicKey());
pushService.setPrivateKey(vapidConfig.getPrivateKey());
pushService.setSubject(vapidConfig.getSubject());
} catch (Exception e) {
throw new WellMeetNotificationException(ErrorCode.INTERNAL_SERVER_ERROR);
}
}

@Override
public boolean isEnabled(NotificationChannel channel) {
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/com/wellmeet/BaseControllerTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wellmeet;

import com.wellmeet.config.WebPushTestConfig;
import com.wellmeet.notification.webpush.repository.PushSubscriptionRepository;
import io.restassured.RestAssured;
import io.restassured.builder.RequestSpecBuilder;
Expand All @@ -11,11 +12,13 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;

@ExtendWith(DataBaseCleaner.class)
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Import(WebPushTestConfig.class)
public abstract class BaseControllerTest {

@Autowired
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/com/wellmeet/BaseServiceTest.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.wellmeet;

import com.wellmeet.config.WebPushTestConfig;
import com.wellmeet.notification.webpush.repository.PushSubscriptionRepository;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;

@ExtendWith(DataBaseCleaner.class)
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@Import(WebPushTestConfig.class)
public abstract class BaseServiceTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.wellmeet;

import com.wellmeet.config.WebPushTestConfig;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest
@ActiveProfiles("test")
@Import(WebPushTestConfig.class)
class WellmeetNotificationApplicationTests {

@Test
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/com/wellmeet/config/WebPushTestConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.wellmeet.config;

import static org.mockito.Mockito.mock;

import nl.martijndwars.webpush.PushService;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;

@TestConfiguration
public class WebPushTestConfig {

@Bean
@Primary
public PushService pushService() {
return mock(PushService.class);
}
}