Skip to content

Commit

Permalink
Fix: 배포환경 채팅 테스트 관련 수정
Browse files Browse the repository at this point in the history
- nginx.conf
- sse 관련 proxy 설정 수정

- NotificationController.java
- subscribe() 메서드 요청 URI 및 파라미터 수정
- getNotifications()
- 파라미터 수정

- WebMvcConfig.java
- 알람 요청 관련 URI 인터셉터 동작 URI 등록
  • Loading branch information
runtime-zer0 committed Aug 4, 2024
1 parent c16446a commit 7830089
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 27 deletions.
13 changes: 0 additions & 13 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,4 @@ server {
proxy_set_header Connection "Upgrade";
proxy_set_header Origin "";
}

location /api/notifications {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_read_timeout 120s;
proxy_pass_request_headers on;
proxy_set_header Connection "";
proxy_set_header Cache-Control "no-cache";
proxy_set_header X-Accel-Buffering "no";
proxy_set_header Content-Type "text/event-stream";
proxy_buffering off;
chunked_transfer_encoding on;
}
}
3 changes: 1 addition & 2 deletions src/main/java/sumcoda/boardbuddy/config/WebMvcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public void addInterceptors(InterceptorRegistry registry) {
"/api/login/oauth2/code/**",
"/api/rankings",
"/api/auth/locations/search",
"/api/ws-stomp/**",
"/api/notifications/**"
"/api/ws-stomp/**"
));
WebMvcConfigurer.super.addInterceptors(registry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import sumcoda.boardbuddy.dto.NotificationResponse;
Expand All @@ -28,18 +29,16 @@ public class NotificationController {
/**
* SSE Emitter 구독 요청
*
// * @param username 유저 아이디
* @param username 유저 아이디
**/
@GetMapping(value = "/api/notifications/subscribe", produces = "text/event-stream")
public ResponseEntity<SseEmitter> subscribe(
// @RequestAttribute String username
@GetMapping(value = "/api/subscribe", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public SseEmitter subscribe(
@RequestAttribute String username
) {
log.info("User {} subscribed for notifications", "test");
SseEmitter sseEmitter = notificationService.subscribe("test");
HttpHeaders headers = new HttpHeaders();
headers.add("Cache-Control", "no-cache");
headers.add("X-Accel-Buffering", "no");
return new ResponseEntity<>(sseEmitter, headers, HttpStatus.OK);
log.info("User {} subscribed for notifications", username);
SseEmitter sseEmitter = notificationService.subscribe(username);

return sseEmitter;
}

/**
Expand All @@ -50,10 +49,10 @@ public ResponseEntity<SseEmitter> subscribe(
**/
@GetMapping(value = "/api/notifications")
public ResponseEntity<ApiResponse<Map<String, List<NotificationResponse.NotificationDTO>>>> getNotifications(
// @RequestAttribute String username
@RequestAttribute String username
) {

List<NotificationResponse.NotificationDTO> notificationDTOs = notificationService.getNotifications("test");
List<NotificationResponse.NotificationDTO> notificationDTOs = notificationService.getNotifications(username);

return buildSuccessResponseWithPairKeyData("notifications", notificationDTOs, "알림이 조회되었습니다.", HttpStatus.OK);
}
Expand Down

0 comments on commit 7830089

Please sign in to comment.