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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public void sendMessage(
ChatMessageBroadcast broadcast = chatMessageWriteService.saveChatMessage(userId, request);

// 3. Redis 채널로 publish
redisPublisher.publish("chatroom:" + request.getRepositoryId(), broadcast);
redisPublisher.publish("chat:" + request.getRepositoryId(), broadcast);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.deepdirect.deepwebide_be.member.domain.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

Expand Down Expand Up @@ -41,11 +40,11 @@ public class ChatMessageBroadcast {
@Schema(description = "보낸 시간")
private LocalDateTime sentAt;

@Schema(description = "내 메시지 여부", name = "IsMine")
private boolean isMine;
@Schema(description = "내 메시지 여부")
private boolean IsMine;


public static ChatMessageBroadcast of(ChatMessage message, User sender, Long repositoryId, CodeReferenceResponse codeReference) {
public static ChatMessageBroadcast of(ChatMessage message, User sender, Long repositoryId, CodeReferenceResponse codeReference, Long currentUserId) {
return ChatMessageBroadcast.builder()
.repositoryId(repositoryId)
.type(ChatMessageType.CHAT) //일반 채팅
Expand All @@ -56,7 +55,7 @@ public static ChatMessageBroadcast of(ChatMessage message, User sender, Long rep
.message(message.getMessage())
.codeReference(codeReference)
.sentAt(message.getSentAt())
.isMine(false)
.IsMine(sender.getId().equals(currentUserId))
.build();
}

Expand All @@ -71,7 +70,7 @@ public static ChatMessageBroadcast system(User user, ChatMessageType type, Strin
.message(message)
.codeReference(null)
.sentAt(LocalDateTime.now())
.isMine(false)
.IsMine(false)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ public ChatMessageBroadcast saveChatMessage(Long userId, ChatMessageRequest requ
// 3. 응답 DTO 변환
CodeReferenceResponse codeReferenceResponse = reference != null ? CodeReferenceResponse.from(reference) : null;

return ChatMessageBroadcast.of(chatMessage, sender, repositoryId, codeReferenceResponse);
return ChatMessageBroadcast.of(chatMessage, sender, repositoryId, codeReferenceResponse, userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.deepdirect.deepwebide_be.chat.dto.response.ChatSystemMessageResponse;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.sentry.Sentry;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
Expand Down Expand Up @@ -45,7 +44,7 @@ public void onMessage(Message message, byte[] pattern) {
.message(broadcast.getMessage())
.codeReference(broadcast.getCodeReference())
.sentAt(broadcast.getSentAt())
.isMine(false)
.IsMine(false)
.build();

messagingTemplate.convertAndSend("/sub/repositories/" + repositoryId + "/chat", response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class RedisConfig {
public RedisMessageListenerContainer redisMessageListenerContainer() {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.addMessageListener(redisSubscriber, new PatternTopic("chat:*"));
// container.addMessageListener(redisSubscriber, new PatternTopic("chat:*"));
return container;
}

Expand Down