Skip to content

Refactor(audience): 알림 구독 로직 수정#356

Merged
Sohyunnnn merged 3 commits intodevelopfrom
refactor/os-modal-logic/#355
Apr 8, 2026
Merged

Refactor(audience): 알림 구독 로직 수정#356
Sohyunnnn merged 3 commits intodevelopfrom
refactor/os-modal-logic/#355

Conversation

@Sohyunnnn
Copy link
Copy Markdown
Contributor

📌 Summary

#355

알림 구독 로직 수정

📚 Tasks

  • 알림 구독 로직 수정

🔍 Describe

배경

현재 알림 구독 플로우는
알림 OS 모달 노출 → 토큰 발급 → 알림 구독 요청 순서로 동작하고 있습니다.

다만 전역 에러 핸들링(401, 403, 404)은 API 요청 이후에만 동작하기 때문에, 비로그인 사용자도 알림 구독 API 요청 전에 알림 OS 모달이 먼저 노출되는 문제가 있었습니다.

이에 알림 OS 모달 노출 전에 로그인 여부를 먼저 확인할 수 있도록 로직을 수정했습니다.

수정 내용

로그인 상태를 확인할 수 있는 API를 사용해, 알림 OS 모달 노출 전에 로그인 여부를 먼저 확인하도록 로직을 수정했습니다.
비로그인 사용자라면 알림 OS 모달을 노출하지 않고 로그인 유도 페이지로 이동하도록 처리했습니다.

👀 To Reviewer

더 나은 개선 방향이 있다면 코멘트 부탁드립니다 👀
api 부분이 뒤죽박죽인 거 같아서,, 1차 스프린트 이후에 컨벤션 확실히 정해서 통일시켜보아요 !! ☺️

📸 Screenshot

2026-04-03.11.44.51.mov

@Sohyunnnn Sohyunnnn requested a review from a team as a code owner April 6, 2026 14:13
@Sohyunnnn Sohyunnnn linked an issue Apr 6, 2026 that may be closed by this pull request
@github-actions github-actions bot added ♻️ Refactor 코드 리팩토링 🐰 소현 labels Apr 6, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

인증 상태 조회 기능이 추가되었습니다. 새로운 엔드포인트 및 타입, React Query 옵션이 도입되고, 공지사항 페이지에서 인증 상태를 확인해 미인증 사용자를 인증 필요 경로로 리다이렉트합니다.

Changes

Cohort / File(s) Summary
Auth API & Types
apps/audience/src/entities/auth/api/auth.ts, apps/audience/src/entities/auth/types/response.ts
getAuthStatus API 헬퍼 추가 및 응답 타입 AuthStatusResponse (authenticated, email, userType) 추가
Auth Query Configuration
apps/audience/src/entities/auth/model/query-options.ts
AUTH_QUERY_OPTIONS.AUTH_STATUS()로 TanStack React Query 쿼리 옵션 등록 (queryKey + queryFn 호출)
Feature Integration
apps/audience/src/pages/notice-list/notice-list.tsx
useQuery(AUTH_QUERY_OPTIONS.AUTH_STATUS()) 적용 및 미인증 시 ROUTE_PATH.AUTH_REQUIRED로 조기 리다이렉트 로직 추가
Shared Constants
apps/audience/src/shared/constants/end-point.ts, apps/audience/src/shared/constants/query-key.ts
END_POINT.GET_AUTH_STATUS: '/auth/status' 추가 및 USERS_QUERY_KEY.AUTH_STATUS() 쿼리 키 생성기 추가

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

📡 API

Suggested reviewers

  • jin-evergreen
  • jisooooooooooo
  • eunkr82
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed PR 설명이 변경 사항과 관련되어 있으며, 배경, 수정 내용, 검토자 요청사항을 명확히 담고 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed PR 제목이 [type] 형식을 따르고 있으며, 31자로 50자 이내 요구사항을 충족하고 있어요. 제목이 변경사항(알림 구독 로직 수정)과 명확히 관련되어 있어요.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/audience/src/entities/auth/api/auth.ts`:
- Line 3: The import of AuthStatusResponse is a type-only import and should use
`import type` to avoid adding runtime dependency; update the import statement
that references AuthStatusResponse in
apps/audience/src/entities/auth/api/auth.ts to use a type-only import (i.e.,
`import type { AuthStatusResponse } ...`) so the type is erased at runtime and
no unnecessary bundle dependency is introduced.

In `@apps/audience/src/entities/auth/types/response.ts`:
- Around line 1-5: Narrow the AuthStatusResponse.userType from string to a union
of literal types that match backend values (e.g., 'ORGANIZER' | 'AUDIENCE') by
updating the AuthStatusResponse interface; also review the response contract for
authenticated === false and adjust types for email and userType (make them
optional or nullable) if the backend omits or returns empty values so
AuthStatusResponse, userType, authenticated, and email accurately reflect the
API shape.

In `@apps/audience/src/pages/notice-list/notice-list.tsx`:
- Around line 46-47: The auth status query currently uses
useQuery(AUTH_QUERY_OPTIONS.AUTH_STATUS()) which may cause unwanted automatic
retries on 401/authorization failures; update the call to merge in retry: false
(e.g., call useQuery({...AUTH_QUERY_OPTIONS.AUTH_STATUS(), retry: false})) and
also destructure the error flag (e.g., isError as isAuthError) so the component
can handle auth failures explicitly; locate the useQuery invocation and
AUTH_QUERY_OPTIONS.AUTH_STATUS() to apply these changes.
- Around line 104-107: The guard checking statusData?.authenticated === false is
dead code because axios interceptors already redirect 401s and statusData is
undefined during redirect or true for authenticated users; remove this
conditional block (the if that calls navigate(ROUTE_PATH.AUTH_REQUIRED)) from
the NoticeList component and rely on the interceptor, or alternatively change
the auth status fetch to return { authenticated: false } with 200 and update the
component to check statusData.authenticated === false before showing
auth-sensitive UI; update any references to statusData, navigate, and
ROUTE_PATH.AUTH_REQUIRED accordingly so no unreachable guard remains.

In `@apps/audience/src/shared/constants/end-point.ts`:
- Line 40: The GET_AUTH_STATUS entry in the end-point constants lacks a trailing
comma; update the constant map to add a trailing comma after GET_AUTH_STATUS:
'/auth/status' so it matches other entries and keeps diffs clean when new
endpoints are added (look for the GET_AUTH_STATUS symbol in end-point.ts and add
the comma).

In `@apps/audience/src/shared/constants/query-key.ts`:
- Line 64: The AUTH_STATUS entry (AUTH_STATUS: () => [...USERS_QUERY_KEY.ALL,
'auth-status']) is missing a trailing comma; update this constant to include a
trailing comma after the closing comma in the array-returning arrow function to
match the file's other entries and maintain consistent formatting for cleaner
future diffs (modify the AUTH_STATUS definition).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4edeb4e2-bc59-4a29-b706-55580d8d9e7f

📥 Commits

Reviewing files that changed from the base of the PR and between 94f4c97 and 5957a02.

📒 Files selected for processing (6)
  • apps/audience/src/entities/auth/api/auth.ts
  • apps/audience/src/entities/auth/model/query-options.ts
  • apps/audience/src/entities/auth/types/response.ts
  • apps/audience/src/pages/notice-list/notice-list.tsx
  • apps/audience/src/shared/constants/end-point.ts
  • apps/audience/src/shared/constants/query-key.ts

@Sohyunnnn Sohyunnnn changed the title Refactor(audience): Refactor(audience): 알림 구독 로직 수정 Apr 6, 2026
Copy link
Copy Markdown
Contributor

@jisooooooooooo jisooooooooooo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

불필요한 모달 노출도 없어지고 더 자연스러워진 것 같네요 👍🏻👍🏻
API 부분도 다음 스프린트 시작 전에 회의하면서 컨벤션 다시 정해봐도 좋을 것 같아요!!

Copy link
Copy Markdown
Member

@jin-evergreen jin-evergreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!!👍👍

@Sohyunnnn Sohyunnnn merged commit e8694ff into develop Apr 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor] 로그인 없이 카테고리 알림 받기 수정

3 participants