diff --git a/.github/workflows/ci-cd-main.yaml b/.github/workflows/ci-cd-main.yaml index 3a069f8d..84f07cc6 100644 --- a/.github/workflows/ci-cd-main.yaml +++ b/.github/workflows/ci-cd-main.yaml @@ -90,6 +90,7 @@ jobs: envs: APP, COMPOSE script_stop: true script: | + ssh api1 "aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_REGISTRY }}" ssh api1 docker-compose -f $COMPOSE down ssh api1 docker pull ${{secrets.IMAGE_API}} ssh api1 docker-compose -p api -f $COMPOSE up -d @@ -178,6 +179,7 @@ jobs: envs: APP, COMPOSE script_stop: true script: | + ssh notification1 "aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_REGISTRY }}" ssh notification1 docker-compose -f $COMPOSE down ssh notification1 docker pull ${{secrets.IMAGE_NOTIFICATION}} ssh notification1 docker-compose -p notification -f $COMPOSE up -d @@ -264,6 +266,7 @@ jobs: envs: APP, COMPOSE script_stop: true script: | + ssh batch1 "aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_REGISTRY }}" ssh batch1 docker-compose -f $COMPOSE down ssh batch1 docker pull ${{secrets.IMAGE_BATCH}} ssh batch1 docker-compose -p batch -f $COMPOSE up -d @@ -350,6 +353,7 @@ jobs: envs: APP, COMPOSE script_stop: true script: | + ssh realtime1 "aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_REGISTRY }}" ssh realtime1 docker-compose -f $COMPOSE down ssh realtime1 docker pull ${{secrets.IMAGE_REALTIME}} ssh realtime1 docker-compose -p realtime -f $COMPOSE up -d diff --git a/api/src/main/kotlin/com/backgu/amaker/api/chat/dto/ChatWithUserDto.kt b/api/src/main/kotlin/com/backgu/amaker/api/chat/dto/ChatWithUserDto.kt index 2449be83..c89a9812 100644 --- a/api/src/main/kotlin/com/backgu/amaker/api/chat/dto/ChatWithUserDto.kt +++ b/api/src/main/kotlin/com/backgu/amaker/api/chat/dto/ChatWithUserDto.kt @@ -5,7 +5,7 @@ import com.backgu.amaker.api.user.dto.UserDto import com.backgu.amaker.domain.chat.ChatType import com.backgu.amaker.domain.chat.ChatWithUser import com.backgu.amaker.domain.chat.DefaultChatWithUser -import com.backgu.amaker.domain.event.EventWithUser +import com.backgu.amaker.domain.chat.EventChatWithUser import java.time.LocalDateTime sealed interface ChatWithUserDto { @@ -31,11 +31,11 @@ sealed interface ChatWithUserDto { user = UserDto.of(chatWithUser.user), ) - else -> + is EventChatWithUser -> EventChatWithUserDto( id = chatWithUser.id, chatRoomId = chatWithUser.chatRoomId, - content = EventWithUserDto.of(chatWithUser.content as EventWithUser), + content = EventWithUserDto.of(chatWithUser.content), chatType = chatWithUser.chatType, createdAt = chatWithUser.createdAt, updatedAt = chatWithUser.updatedAt, diff --git a/api/src/main/kotlin/com/backgu/amaker/api/chat/dto/response/ChatWithUserResponse.kt b/api/src/main/kotlin/com/backgu/amaker/api/chat/dto/response/ChatWithUserResponse.kt index be4db264..8b411c03 100644 --- a/api/src/main/kotlin/com/backgu/amaker/api/chat/dto/response/ChatWithUserResponse.kt +++ b/api/src/main/kotlin/com/backgu/amaker/api/chat/dto/response/ChatWithUserResponse.kt @@ -1,6 +1,7 @@ package com.backgu.amaker.api.chat.dto.response import com.backgu.amaker.api.chat.dto.ChatWithUserDto +import com.backgu.amaker.api.chat.dto.DefaultChatWithUserDto import com.backgu.amaker.api.chat.dto.EventChatWithUserDto import com.backgu.amaker.api.user.dto.response.UserResponse import com.backgu.amaker.domain.chat.ChatType @@ -32,7 +33,7 @@ interface ChatWithUserResponse { fun of(chatWithUserDto: ChatWithUserDto<*>): ChatWithUserResponse<*> = when (chatWithUserDto) { is EventChatWithUserDto -> EventChatWithUserResponse.of(chatWithUserDto) - else -> DefaultChatWithUserResponse.of(chatWithUserDto) + is DefaultChatWithUserDto -> DefaultChatWithUserResponse.of(chatWithUserDto) } } } diff --git a/api/src/main/kotlin/com/backgu/amaker/api/chat/service/ChatFacadeService.kt b/api/src/main/kotlin/com/backgu/amaker/api/chat/service/ChatFacadeService.kt index b1be3e3c..55f27c52 100644 --- a/api/src/main/kotlin/com/backgu/amaker/api/chat/service/ChatFacadeService.kt +++ b/api/src/main/kotlin/com/backgu/amaker/api/chat/service/ChatFacadeService.kt @@ -139,9 +139,15 @@ class ChatFacadeService( chatUserCacheFacadeService.findChat(chatRoomId, it) } - if (cachedChat != null) return ChatWithUserDto.of(cachedChat) + if (cachedChat != null) { + markMostRecentChatAsRead(chatRoomId, userId) + return ChatWithUserDto.of(cachedChat) + } - val chat = chatQueryService.getOneWithUser(chatRoomUser.lastReadChatId) + val chat = + chatQueryService.getOneWithUser( + chatRoomUser.lastReadChatId ?: chatRoomService.getById(chatRoomId).lastChatId, + ) if (!ChatType.isEventChat(chat.chatType)) return DefaultChatWithUserDto.of(chat) diff --git a/domain/src/main/kotlin/com/backgu/amaker/domain/chat/ChatWithUser.kt b/domain/src/main/kotlin/com/backgu/amaker/domain/chat/ChatWithUser.kt index ec4d7558..fc30976e 100644 --- a/domain/src/main/kotlin/com/backgu/amaker/domain/chat/ChatWithUser.kt +++ b/domain/src/main/kotlin/com/backgu/amaker/domain/chat/ChatWithUser.kt @@ -3,7 +3,7 @@ package com.backgu.amaker.domain.chat import com.backgu.amaker.domain.user.User import java.time.LocalDateTime -interface ChatWithUser { +sealed interface ChatWithUser { val id: Long val chatRoomId: Long val content: T diff --git a/domain/src/main/kotlin/com/backgu/amaker/domain/workspace/Workspace.kt b/domain/src/main/kotlin/com/backgu/amaker/domain/workspace/Workspace.kt index 1ac5d2bb..8fb4de53 100644 --- a/domain/src/main/kotlin/com/backgu/amaker/domain/workspace/Workspace.kt +++ b/domain/src/main/kotlin/com/backgu/amaker/domain/workspace/Workspace.kt @@ -35,7 +35,6 @@ class Workspace( fun createDefaultChatRoom(): ChatRoom = ChatRoom(workspaceId = id, name = "일반 채팅", chatRoomType = ChatRoomType.DEFAULT) - override fun toString(): String { - return "Workspace(id=$id, name='$name', thumbnail='$thumbnail', belongingNumber=$belongingNumber, workspacePlan=$workspacePlan)" - } + override fun toString(): String = + "Workspace(id=$id, name='$name', thumbnail='$thumbnail', belongingNumber=$belongingNumber, workspacePlan=$workspacePlan)" } diff --git a/infra/src/main/kotlin/com/backgu/amaker/application/chat/service/ChatUserCacheFacadeService.kt b/infra/src/main/kotlin/com/backgu/amaker/application/chat/service/ChatUserCacheFacadeService.kt index fbcc60b2..871e1e36 100644 --- a/infra/src/main/kotlin/com/backgu/amaker/application/chat/service/ChatUserCacheFacadeService.kt +++ b/infra/src/main/kotlin/com/backgu/amaker/application/chat/service/ChatUserCacheFacadeService.kt @@ -58,8 +58,8 @@ class ChatUserCacheFacadeService( userCacheService.save(fetchedUser) } - when (chat) { - is DefaultChatWithUserCache -> return chat.toDomain(user) + return when (chat) { + is DefaultChatWithUserCache -> chat.toDomain(user) is EventChatWithUserCache -> { val userIds = chat.content.users val cachedUsers = userCacheService.findAllByUserIds(userIds) @@ -68,7 +68,7 @@ class ChatUserCacheFacadeService( userService.getAllByUserIds(missingUserIds).onEach { userCacheService.save(it) } val allUsers = cachedUsers + fetchedUsers - return chat.toDomain(user, chat.content.toDomain(allUsers)) + chat.toDomain(user, chat.content.toDomain(allUsers)) } } } @@ -150,10 +150,6 @@ class ChatUserCacheFacadeService( return chat.toDomain(user, chat.content.toDomain(allUsers)) } - - else -> { - throw IllegalArgumentException("Invalid chat type") - } } } } diff --git a/infra/src/main/kotlin/com/backgu/amaker/application/workspace/WorkspaceService.kt b/infra/src/main/kotlin/com/backgu/amaker/application/workspace/WorkspaceService.kt index 444cf6fd..d616eb4c 100644 --- a/infra/src/main/kotlin/com/backgu/amaker/application/workspace/WorkspaceService.kt +++ b/infra/src/main/kotlin/com/backgu/amaker/application/workspace/WorkspaceService.kt @@ -23,7 +23,10 @@ class WorkspaceService( @Transactional fun updateBelonging(workspace: Workspace) { - workspaceRepository.updateBelongingWithLimit(workspace.id, workspace.workspacePlan.belongingLimit) != 1 && + workspaceRepository.updateBelongingWithLimit( + workspace.id, + workspace.workspacePlan.belongingLimit, + ) != 1 && throw BusinessException(StatusCode.INVALID_WORKSPACE_JOIN) }