Skip to content

Commit 84cfe8d

Browse files
committed
feat: 채팅 요청 수락 로직 수정(#105)
- 채팅 요청 수락시 채팅방 ID 응답토록 변경 - 요청한 사용자와 알림을 받은 사용자가 불일치할 때 예외 발생토록 수정
1 parent 0b63962 commit 84cfe8d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

be/src/main/java/yeonba/be/chatting/service/ChatService.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.springframework.transaction.annotation.Transactional;
1313
import yeonba.be.chatting.dto.request.ChatPublishRequest;
1414
import yeonba.be.chatting.dto.response.ChatMessageResponse;
15+
import yeonba.be.chatting.dto.response.ChatRequestAcceptResponse;
1516
import yeonba.be.chatting.dto.response.ChatRoomResponse;
1617
import yeonba.be.chatting.entity.ChatMessage;
1718
import yeonba.be.chatting.entity.ChatRoom;
@@ -145,7 +146,7 @@ public void requestChat(long senderId, long receiverId) {
145146
}
146147

147148
@Transactional
148-
public void acceptRequestedChat(long userId, long notificationId) {
149+
public ChatRequestAcceptResponse acceptRequestedChat(long userId, long notificationId) {
149150

150151
Notification notification = notificationQuery.findById(notificationId);
151152

@@ -159,7 +160,7 @@ public void acceptRequestedChat(long userId, long notificationId) {
159160
User receiver = userQuery.findById(notification.getReceiver().getId());
160161

161162
// 본인에게 온 채팅 요청인지 검증
162-
if (receiver.equals(userQuery.findById(userId))) {
163+
if (!receiver.equals(userQuery.findById(userId))) {
163164

164165
throw new GeneralException(
165166
NotificationException.NOT_YOUR_CHATTING_REQUEST_NOTIFICATION);
@@ -183,6 +184,8 @@ public void acceptRequestedChat(long userId, long notificationId) {
183184
LocalDateTime.now());
184185

185186
eventPublisher.publishEvent(notificationSendEvent);
187+
188+
return new ChatRequestAcceptResponse(chatRoom.getId());
186189
}
187190

188191
@Transactional

0 commit comments

Comments
 (0)