33import lombok .RequiredArgsConstructor ;
44import lombok .extern .slf4j .Slf4j ;
55import org .dfbf .soundlink .domain .alert .dto .AlertChatRequest ;
6- import org .dfbf .soundlink .domain .alert .entity .Alert ;
76import org .dfbf .soundlink .domain .alert .service .AlertService ;
87import org .dfbf .soundlink .domain .blocklist .repository .BlockListRepository ;
98import org .dfbf .soundlink .domain .chat .dto .ChatRejectDto ;
3130import org .springframework .data .redis .core .RedisTemplate ;
3231import org .springframework .security .core .annotation .AuthenticationPrincipal ;
3332import org .springframework .stereotype .Service ;
34- import org .springframework .transaction .annotation .Transactional ;
3533
3634import java .sql .Timestamp ;
3735import java .time .Duration ;
@@ -218,11 +216,11 @@ public ResponseResult createChatRoom(Long userId, Long recordId, String requestN
218216 if (chatRoomId .isPresent ()) {
219217 Map <String , Object > map = new HashMap <>();
220218 map .put ("chatRoomId" , chatRoomId .get ());
221-
219+
222220// Alert alert = alertService.createAlert(requestUserId, "accept", map);
223221// kafkaProducer.send(TOPIC, alert);
224222 alertService .send (requestUserId , "accept" , map );
225-
223+
226224 return new ResponseResult (map );
227225 }
228226
@@ -241,6 +239,10 @@ public ResponseResult createChatRoom(Long userId, Long recordId, String requestN
241239
242240 ChatReqDto chatReqDto = new ChatReqDto (userId , responseUserId );
243241
242+ // 채팅 오픈 상태 보내기
243+ log .info ("Setting chatting status to true for userId: {}" , userId );
244+ userStatusService .setChatting (userId , true );
245+
244246 // 레디스에 저장
245247 redisTemplate .opsForValue ().set ("Room::" + chatRoom .getChatRoomId (), String .valueOf (chatReqDto ));
246248
@@ -253,9 +255,6 @@ public ResponseResult createChatRoom(Long userId, Long recordId, String requestN
253255// kafkaProducer.send(TOPIC, alert);
254256 alertService .send (requestUserId , "accept" , map );
255257
256- // 채팅 오픈 상태 보내기
257- userStatusService .setChatting (userId , true );
258-
259258 return new ResponseResult (ErrorCode .SUCCESS , map );
260259
261260 } else {
@@ -282,12 +281,12 @@ public ResponseResult closeChatRoom(@AuthenticationPrincipal Long userId, Long c
282281 throw new UnauthorizedAccessException (); // 권한이 없을 경우 예외 발생
283282 }
284283
285- // 채팅 완료 상태 보내기
286- userStatusService .setChatting (userId , false );
287-
288284 chatRoom .updateChatRoomStatus (RoomStatus .CLOSED ); // 삳태 '닫기'로 변경
289285 chatRoomRepository .save (chatRoom ); // DB에 저장
290286
287+ // 채팅 종료 상태 보내기
288+ log .info ("Setting chatting status to false for userId: {}" , userId );
289+ userStatusService .setChatting (userId , false );
291290
292291 redisTemplate .delete ("Room::" +chatRoomId ); // 레디스에서 삭제
293292
0 commit comments