From 621aa4a7dc993eaa81c1eb50c543885a172023b6 Mon Sep 17 00:00:00 2001 From: HeoSeokMun Date: Sun, 25 Aug 2024 19:43:20 +0900 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=EB=B0=B0=ED=8F=AC=EC=8B=9C=20ecr=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd-main.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci-cd-main.yaml b/.github/workflows/ci-cd-main.yaml index 3a069f8d..97d09016 100644 --- a/.github/workflows/ci-cd-main.yaml +++ b/.github/workflows/ci-cd-main.yaml @@ -4,6 +4,9 @@ on: push: branches: - 'main' + pull_request: + branches: + - 'develop' env: AWS_REGION: ap-northeast-2 @@ -90,6 +93,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 +182,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 +269,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 +356,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 From 131f9b5233e303f3129cecef1c7a8988cc0d226c Mon Sep 17 00:00:00 2001 From: HeoSeokMun Date: Sun, 25 Aug 2024 19:47:02 +0900 Subject: [PATCH 2/5] =?UTF-8?q?test:=20=EB=B0=B0=ED=8F=AC=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=A2=85=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd-main.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci-cd-main.yaml b/.github/workflows/ci-cd-main.yaml index 97d09016..84f07cc6 100644 --- a/.github/workflows/ci-cd-main.yaml +++ b/.github/workflows/ci-cd-main.yaml @@ -4,9 +4,6 @@ on: push: branches: - 'main' - pull_request: - branches: - - 'develop' env: AWS_REGION: ap-northeast-2 From fd11b306e67c4b4400da14727ea9086dd146efff Mon Sep 17 00:00:00 2001 From: HeoSeokMun Date: Sun, 25 Aug 2024 19:52:18 +0900 Subject: [PATCH 3/5] =?UTF-8?q?refactor:=20=EC=BD=94=EB=93=9C=20=EC=8A=A4?= =?UTF-8?q?=ED=83=80=EC=9D=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/backgu/amaker/api/chat/dto/ChatWithUserDto.kt | 5 +++-- .../api/chat/dto/response/ChatWithUserResponse.kt | 3 ++- .../com/backgu/amaker/domain/chat/ChatWithUser.kt | 2 +- .../com/backgu/amaker/domain/workspace/Workspace.kt | 5 ++--- .../chat/service/ChatUserCacheFacadeService.kt | 11 ++++------- .../amaker/application/workspace/WorkspaceService.kt | 5 ++++- 6 files changed, 16 insertions(+), 15 deletions(-) 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..56a46257 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,6 +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.chat.EventChatWithUser import com.backgu.amaker.domain.event.EventWithUser import java.time.LocalDateTime @@ -31,11 +32,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/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..1d175962 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 @@ -12,6 +12,7 @@ import com.backgu.amaker.infra.redis.chat.data.ChatWithUserCache import com.backgu.amaker.infra.redis.chat.data.DefaultChatWithUserCache import com.backgu.amaker.infra.redis.chat.data.EventChatWithUserCache import com.backgu.amaker.infra.redis.chat.repository.ChatPipelinedQueryRepository +import org.springframework.retry.annotation.Retryable import org.springframework.stereotype.Service import org.springframework.transaction.event.TransactionalEventListener @@ -58,8 +59,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 +69,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 +151,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) } From ba3c65a190d35a4f495e05bf5bc895e4018addf0 Mon Sep 17 00:00:00 2001 From: HeoSeokMun Date: Sun, 25 Aug 2024 19:52:44 +0900 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=EC=9E=98=EB=AA=BB=EB=90=9C=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amaker/api/chat/service/ChatFacadeService.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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) From d27a3ed10111d0ff1d38448dc9e9bec48506a84d Mon Sep 17 00:00:00 2001 From: HeoSeokMun Date: Sun, 25 Aug 2024 20:46:51 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20ktlint=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/backgu/amaker/api/chat/dto/ChatWithUserDto.kt | 1 - .../application/chat/service/ChatUserCacheFacadeService.kt | 1 - 2 files changed, 2 deletions(-) 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 56a46257..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 @@ -6,7 +6,6 @@ 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.chat.EventChatWithUser -import com.backgu.amaker.domain.event.EventWithUser import java.time.LocalDateTime sealed interface ChatWithUserDto { 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 1d175962..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 @@ -12,7 +12,6 @@ import com.backgu.amaker.infra.redis.chat.data.ChatWithUserCache import com.backgu.amaker.infra.redis.chat.data.DefaultChatWithUserCache import com.backgu.amaker.infra.redis.chat.data.EventChatWithUserCache import com.backgu.amaker.infra.redis.chat.repository.ChatPipelinedQueryRepository -import org.springframework.retry.annotation.Retryable import org.springframework.stereotype.Service import org.springframework.transaction.event.TransactionalEventListener