Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Gmail OAuth 기반으로 MailAccount를 실제 연동(인가 URL 생성 → callback 토큰 교환/사용자 정보 조회 → 계정 저장)하고, 계정 표시용 메타데이터(alias/icon/color) 및 만료시각 저장과 “내 메일 계정 목록 조회” API를 추가하는 PR입니다.
Changes:
- Google OAuth 연동을 위한 Properties/QueryService/DTO를 추가하고 authorize/callback 플로우를 실제 Google API 호출로 연결
MailAccount도메인 확장(alias/icon/color) 및 삭제되지 않은 계정만 조회하도록 Repository/QueryService 수정- 내 메일 계정 목록 조회 API 및 Swagger 문서/예외 코드 보강
sequenceDiagram
participant C as Client/Browser
participant API as Core API
participant G as Google OAuth
participant OQS as GoogleOAuthQueryService
participant DB as DB(JPA)
C->>API: GET /api/v1/mail-accounts/google/authorize (alias/icon/color)
API->>API: session에 state,userId,appearance 저장
API-->>C: authorizationUrl 반환
C->>G: Google 동의 화면 이동
G-->>C: redirect (code,state)
C->>API: GET /api/v1/mail-accounts/google/callback?code&state
API->>API: session state/userId 검증
API->>OQS: code -> token 교환
OQS->>G: POST token-uri
OQS->>G: GET user-info-uri (Bearer access_token)
OQS-->>API: GoogleMailAccountResult
API->>DB: MailAccount 저장
API-->>C: 302 Redirect (/)
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| docker-compose.yml | Google OAuth 환경변수 주입 추가 |
| db/src/main/resources/schema.sql | mail_accounts에 alias/icon/color 컬럼 반영 |
| db/src/main/java/com/mailsangja/db/port/MailAccountRepositoryPort.java | 삭제되지 않은 계정 조회 메서드로 변경 |
| db/src/main/java/com/mailsangja/db/module/mail/MailAccountJpaRepositoryModule.java | findAllByUserIdAndDeletedAtIsNull로 조회 정책 변경 |
| db/src/main/java/com/mailsangja/db/entity/mail/MailAccount.java | alias/icon/color 필드 및 업데이트 메서드 추가 |
| db/src/main/java/com/mailsangja/db/adapter/mail/MailAccountRepositoryAdapter.java | Port 변경사항 반영 |
| core/src/main/resources/application.yaml | Google OAuth 설정(properties) 추가 |
| core/src/main/java/com/mailsangja/core/service/mail/MailAccountQueryService.java | 삭제되지 않은 계정만 조회하도록 변경 |
| core/src/main/java/com/mailsangja/core/service/mail/MailAccountCommandService.java | Google MailAccount 생성 커맨드/검증 로직 추가 |
| core/src/main/java/com/mailsangja/core/service/google/GoogleOAuthQueryService.java | 토큰 교환/유저정보 조회/인가 URL 생성 로직 신규 추가 |
| core/src/main/java/com/mailsangja/core/facade/MailAccountFacade.java | 실제 OAuth 결과 기반 저장 + appearance 정규화/검증 + 목록 조회 추가 |
| core/src/main/java/com/mailsangja/core/controller/MailAccountController.java | 목록 조회 API 추가 및 callback 302 redirect로 변경 |
| core/src/main/java/com/mailsangja/core/controller/docs/MailAccountControllerDocs.java | Swagger 문서에 목록 조회/redirect 응답 반영 |
| core/src/main/java/com/mailsangja/core/dto/mail/* | authorize 요청, list 응답, OAuth DTO 및 response 필드 확장 |
| core/src/main/java/com/mailsangja/core/config/properties/GoogleOAuthProperties.java | mailsangja.oauth.google 바인딩 클래스 추가 |
| core/src/main/java/com/mailsangja/core/common/exception/mail/MailAccountErrorCode.java | OAuth/appearance 관련 에러 코드 추가 |
| .claude/skills/spring-api-rules.md | OAuth/Validation 레이어 규칙 문서 업데이트 |
core/src/main/java/com/mailsangja/core/service/google/GoogleOAuthQueryService.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/mailsangja/core/service/google/GoogleOAuthQueryService.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/mailsangja/core/controller/MailAccountController.java
Show resolved
Hide resolved
core/src/main/java/com/mailsangja/core/controller/docs/MailAccountControllerDocs.java
Outdated
Show resolved
Hide resolved
Member
|
LGTM 😄 고생하셨습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 관련 작업
👤 User Story
📌 Task
💡 작업 내용
MailAccount연동 플로우를 구현하고, 실제 callback에서 토큰 교환 및 사용자 정보 조회 후 메일 계정을 저장하도록 구성했습니다.MailAccount도메인을 확장해alias,icon,color, OAuth 토큰 만료 시각 등을 저장하고, 연결된 메일 계정 목록 조회 API를 추가했습니다.📝 추가 설명
1. Gmail OAuth 연동 구현
GET /api/v1/mail-accounts/google/authorize와GET /api/v1/mail-accounts/google/callback흐름을 실제 Google OAuth 연동으로 연결했습니다.GoogleOAuthProperties,GoogleOAuthQueryService,GoogleOAuthTokenResult,GoogleUserInfoResult를 추가해 인가 URL 생성, 토큰 교환, 사용자 정보 조회를 분리했습니다./swagger-ui.html로 리다이렉트하도록 처리했습니다.2. MailAccount 도메인 및 저장 정책 확장
MailAccount엔티티와schema.sql에access_token_expires_at,alias,icon,color필드를 반영했습니다.refresh_token누락 시 전용 예외를 통해 재연동을 유도하고,verified_email이true가 아니면 연결을 차단하도록 검증을 추가했습니다.alias,icon,color는 authorize 단계에서 세션에 저장하고 callback 직전에 보정/검증하도록 변경했습니다.alias비어있음:emailAddress사용icon비어있음:"good"사용color비어있음: 랜덤 HEX 사용color값 존재 시 HEX 형식 검증3. 메일 계정 조회 및 문서화
GET /api/v1/mail-accounts를 추가했습니다.id,isActive,provider,emailAddress,alias,color,icon만 포함하는List<MailAccountListResponse>형태로 구성했습니다..claude규칙 문서를 MailAccount OAuth/Validation/CQS 규칙에 맞게 보강했습니다.⚡️ Test 결과
Callback