Repository navigation
Conversation
There was a problem hiding this comment.
🤖 AI 코드 리뷰 - 버그 관점
FirebaseFunctions callable을 통한 약속 생성·참여·나가기 서버 구현과, 클라이언트 측 LeaveAppointmentUseCase 및 관련 ViewModel/ViewController 연동이 주요 변경 사항이다. HomeViewModel의 콜백 기반 joinAppointment를 @published 패턴으로 마이그레이션하고, AppointmentInfoViewController에서 나가기 후 채팅 화면을 닫는 흐름도 추가되었다. 전반적으로 서버·클라이언트 간 인터페이스가 일관성 있게 설계되어 있으나, leaveResult가 재사용되는 구조에서 동일 결과가 재구독될 수 있는 버그와, Functions 에뮬레이터 설정 시 잘못된 API 사용이 확인된다.
snughnu
approved these changes
Oct 29, 2026
snughnu
left a comment
Collaborator
There was a problem hiding this comment.
리뷰 노트 확인했습니다. 수고하셨습니다! 🙊
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.
JIRA
📝 작업 내용
📌 요약
🔍 상세
[1] Cloud Functions (
firebase/functions/index.js)createAppointment: 코드 생성 후 약속 문서 생성, 만든 사람을 첫 참여자로 추가joinAppointment(code): 코드로 약속을 찾아 참여자에 추가, 참여자 공개 프로필과 함께 반환. 이미 참여 중이면 그대로 반환leaveAppointment(appointmentID): 참여자에서 제거. 마지막 참여자면 약속 문서·하위 컬렉션·코드 예약 삭제asia-northeast3[2] 약속 코드 고유성
appointmentCodes/{code}예약 문서 신규 — 문서 ID가 코드, 값은appointmentID. 서버만 접근[3] 앱 연동
FirebaseAppointmentRepository: 생성·참여·나가기는 callable 호출, 조회·정보 수정은 Firestore 연동 전까지 Mock에 위임AppointmentDTO: callable 응답 →Appointment변환, 참여자는UserDTO재사용LeaveAppointmentUseCase: 약속 나가기Functions.app: 앱이 호출하는 리전을 고정한 Functions 인스턴스FirebaseErrorMapper: Functions 에러 →AppError변환 추가AppointmentRepository에leaveAppointment(appointmentID:)추가[4] 약속 나가기 진입점
약속 목록 / 지난 약속 카드 길게 누르기 → 약속 나가기: 서버에서 나간 뒤 카드 제거채팅방 ... → 약속 정보 카드의 약속 나가기 버튼: 서버에서 나간 뒤 카드와 채팅방을 닫고 이전 화면으로 이동UIAlertController.leaveFailureAlert()표시[5] 에뮬레이터
firebase.json에 Functions 에뮬레이터(5001) 추가, 앱은 DEBUG에서 Functions 에뮬레이터 연결npm run seed(firebase/functions): 더미 사용자 2명이 참여한 약속(코드DUMMY2) 생성💬 리뷰 노트
코드 중복 방지에 예약 문서를 둔 이유
처음에는
code로 기존 약속을 조회한 뒤 없으면 생성하는 방식이었는데, 조회와 생성 사이에 같은 코드가 끼어들 여지가 있었습니다.코드를 문서 ID로 쓰는
appointmentCodes컬렉션을 두면 같은 코드의 문서는 하나만 존재할 수 있고, 트랜잭션 안에서 읽은 문서는 커밋까지 잠깁니다. 에뮬레이터에서 같은 코드로 트랜잭션 10개를 동시에 실행해 1개만 성공하는 것을 확인했습니다.기존에 확정한 문서 구조에 없던 컬렉션이 하나 추가된 점 참고 부탁드립니다. 참여도 이 문서로 바로 찾기 때문에
code필드 조회가 필요 없어졌습니다.👉 결론: 코드 고유성은
appointmentCodes/{code}예약 문서 + 트랜잭션으로 보장참여 응답에 참여자 프로필을 함께 담은 이유
Appointment는participants: [User]가 필요한데, 참여 직후 앱이 users를 다시 조회하지 않도록 서버가 함께 반환합니다.다른 사람에게 보여도 되는 필드(닉네임, 프로필 이미지, 이동수단, 위치 공유 범위)만 담고, 알림 설정은 보내지 않습니다.
나가기를 실패 없이 처리하는 이유
이미 없는 약속이거나 참여하지 않은 약속에서 나가면 에러 대신 성공으로 처리합니다. 결과적으로 "그 약속에 내가 없는 상태"라는 목적은 같고, 두 번 눌러도 안전하기 때문입니다.
마지막 참여자 판단은 두 사람이 동시에 나가는 경우를 위해 트랜잭션으로 처리했습니다.
테스트
실기기(Debug, 에뮬레이터 연결)에서 아래 항목을 확인했습니다. 다른 계정의 참여는 Apple 로그인만 가능해서 시드 스크립트의 더미 약속(
DUMMY2)으로 확인했습니다.추후 작업
fetchMyAppointments교체📸 영상 / 이미지
WORK63.functions.MP4