[FIX#321] 프로그램 관리 웹훅 API body 제거#322
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Walkthrough웹훅 페이로드의 rollup 기반 리더 정보 추출을 제거하고, Notion에서 Changes
Sequence Diagram(s)sequenceDiagram
participant Webhook as Webhook Request
participant Controller as programController
participant ProgramSvc as programService
participant AppSvc as programApplicationService
participant Community as Community DB
Webhook->>Controller: POST /webhooks/leader-change (body.data.id)
Controller->>ProgramSvc: getProgramById(data.id)
ProgramSvc-->>Controller: program { leaderUserId, leaderNickname, ... }
alt program not found
Controller-->>Webhook: 404 NOT_FOUND
else program found
Controller->>AppSvc: updateCommunityLeader(programPageId, newLeaderUserId, nickname, program)
AppSvc->>Community: transaction: adjust admin/member roles
Community-->>AppSvc: update result
AppSvc-->>Controller: result (leaderUpdated/leaderRemoved/skipped)
Controller-->>Webhook: 200 JSON response
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔧 빌드 상태: 성공! ✅Firebase Functions 빌드 및 에뮬레이터 기동이 성공적으로 완료되었습니다! 🎉 ✅ 체크 완료
📊 상세 정보
|
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
be/functions/src/services/programService.js (1)
575-619: leaderUserId는 name/id로 뽑아줘지금은 plain_text가 없어서 거의 null로 떨어질 거야. getRollupValues 결과는 name/id 기반이라 그걸 우선 사용해야 리더 변경 웹훅이 안 깨져.
🛠️ 수정 제안
- const leaderUserId = leaderUserIdRollup?.value?.[0]?.plain_text || null; + const leaderUserId = + leaderUserIdRollup?.value?.[0]?.name ?? + leaderUserIdRollup?.value?.[0]?.id ?? + null;be/functions/src/services/programApplicationService.js (1)
1149-1166: updateCommunityLeader 새 파라미터 문서화 추가해줘signature에
program이 추가됐는데 JSDoc에 빠져있어. 코딩 가이드라인 기준으로.📝 JSDoc 보완
- * `@param` {string} nickname - 리더 닉네임 + * `@param` {string} nickname - 리더 닉네임 + * `@param` {Object|null} program - 미리 조회한 프로그램 데이터 (없으면 내부 조회)
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
be/functions/src/controllers/programController.js (1)
449-485: 웹훅data.id타입/공백 체크 추가해줘.
지금은 truthy만 보는데 객체/공백이면 Notion 호출로 넘어가서 500으로 떨어질 수 있어. 400으로 바로 컷하는 게 좋아.🛠️ 제안 수정
- if (!data || !data.id) { + if (!data || typeof data.id !== 'string' || !data.id.trim()) { const error = new Error('유효하지 않은 웹훅 데이터입니다'); error.code = 'BAD_REQUEST'; error.statusCode = 400; return next(error); } // 1. 프로그램 페이지 ID 추출 - const programPageId = data.id; + const programPageId = data.id.trim();be/functions/src/routes/programs.js (1)
596-613: Swagger에data자체도 required로 표시해줘.
컨트롤러가data없으면 400이라 스펙도 맞춰두는 게 좋아.🧾 스펙 보강 예시
* schema: * type: object + * required: + * - data * properties: * data: * type: object * required: * - id
🤖 Fix all issues with AI agents
In `@be/functions/src/services/programApplicationService.js`:
- Around line 1274-1282: The response can return undefined for wasAlreadyAdmin
in the leader-removal branch; update the return object to normalize that value
to false when missing by using a default (e.g. replace result.wasAlreadyAdmin
with result.wasAlreadyAdmin ?? false or Boolean(result.wasAlreadyAdmin)) so
wasAlreadyAdmin is always a boolean; adjust the same return that sets
communityId, newLeaderUserId, previousLeaderUserId, leaderRemoved to ensure
consistency (references: result.wasAlreadyAdmin, leaderRemoved,
newLeaderUserId).
🧹 Nitpick comments (1)
be/functions/src/services/programApplicationService.js (1)
1159-1166: JSDoc에program파라미터도 명시해줘.
시그니처가 늘었는데 주석은 그대로라서 헷갈릴 수 있어. 옵션 파라미터로 추가해두자. As per coding guidelines, ...✍️ JSDoc 업데이트 예시
/** * `@param` {string} programPageId - 노션 프로그램 페이지 ID (원본) * `@param` {string} newLeaderUserId - 새 리더 Firebase UID * `@param` {string} nickname - 리더 닉네임 + * `@param` {Object|null} [program] - 이미 조회한 프로그램 (옵션) * `@returns` {Promise<Object>} 업데이트 결과 */
📝 작업 내용
🎯 관련 이슈
Closes #321
🔄 변경사항
👀 리뷰 포인트
📱 스크린샷/영상
Before
After
Summary by CodeRabbit
릴리스 노트
버그 수정
변경
✏️ Tip: You can customize this high-level summary in your review settings.