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
2 changes: 2 additions & 0 deletions src/main/java/goorm/ddok/global/config/WebSocketConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws/chats-ws")
.setAllowedOriginPatterns("http://localhost:5173", "http://127.0.0.1:5173");

registry.addEndpoint("/ws/notifications")
.setAllowedOriginPatterns("*");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void handleAction(String meUserIdStr, String notificationIdStr, String ac
.message(action.equals("accept") ? "요청을 수락했습니다." : "요청을 거절했습니다.")
.IsRead(true)
.createdAt(Instant.now())
.userId(String.valueOf(me))
.actorUserId(String.valueOf(me))
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
@Service
@RequiredArgsConstructor
public class NotificationPushService {
private final SimpMessagingTemplate messagingTemplate;
private final SimpMessagingTemplate template;

// 개인 알림
public void pushToUser(Long userId, NotificationPayload payload) {
messagingTemplate.convertAndSendToUser(
String.valueOf(userId),
"/queue/notifications",
payload
);
template.convertAndSendToUser(String.valueOf(userId), "/queue/notifications", payload);
}
}

// 브로드캐스트(옵션)
public void broadcast(NotificationPayload payload) {
template.convertAndSend("/topic/notifications", payload);
}
}
Loading