Repository navigation
feat(receiver,setting): 수신자 등록에 카카오톡 초대 발급·수락 흐름을 잇는다 (#944) #2109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c5833b3
feat(core): 카카오톡 수신자 초대 계약을 core 에 세운다 (#944)
OnlyReadOneBook 325c336
feat(app): 카카오톡 초대 스킴을 받아 랜딩을 띄운다 (#944)
OnlyReadOneBook 9eddd73
feat(receiver): 초대 랜딩·수락 완료 화면을 Nav3 로컬 스택으로 만든다 (#944)
OnlyReadOneBook 0eef1cf
feat(setting): 수신자 등록에 카카오톡 초대 보내기를 잇는다 (#944)
OnlyReadOneBook 61da6b9
test: update screenshot baselines in CI
github-actions[bot] 726afd4
fix(setting): 카카오톡 공유 실패 원인을 진단에 남긴다 (#944)
OnlyReadOneBook ee6cb59
Merge remote-tracking branch 'origin/develop' into feat/944-kakao-rec…
OnlyReadOneBook f7e2a25
style(setting): 병합 뒤 남은 연속 빈 줄을 정리한다 (#944)
OnlyReadOneBook 19c5dd4
merge: 최신 설정 패키지와 초대 진입 호출부 반영 (#944)
OnlyReadOneBook 04fda27
refactor: 앱 내비게이션을 실제 모듈 호출 범위로 제한 (#944)
OnlyReadOneBook File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/afternote/afternote_fe/invitation/ReceiverInvitationIntentContract.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package com.afternote.afternote_fe.invitation | ||
|
|
||
| import android.content.Intent | ||
|
|
||
| /** | ||
| * 카카오톡 초대 메시지 버튼이 여는 `kakao{앱키}://kakaolink?inviteToken=…` Intent 를 해석한다 (#944). | ||
| * | ||
| * `NotificationIntentContract` 처럼 순수 객체다 — 판정 규칙은 [resolve] 하나에 모여 있고, | ||
| * `MainActivity` 는 [fromIntent] 만 부른다. | ||
| * | ||
| * 토큰은 서버가 발급한 43자 base64url 이다. 형식 밖 값은 우리가 만든 링크가 아니므로 저장하지 않는다 — | ||
| * 스킴은 누구나 던질 수 있어 검증 없이 보관하면 임의 문자열이 서버 경로 세그먼트까지 흘러간다. | ||
| */ | ||
| internal object ReceiverInvitationIntentContract { | ||
| fun fromIntent(intent: Intent): String? { | ||
| val data = runCatching { intent.data }.getOrNull() ?: return null | ||
| return resolve( | ||
| scheme = data.scheme, | ||
| host = data.host, | ||
| rawToken = runCatching { data.getQueryParameter(QUERY_INVITE_TOKEN) }.getOrNull(), | ||
| ) | ||
| } | ||
|
|
||
| private fun resolve( | ||
| scheme: String?, | ||
| host: String?, | ||
| rawToken: String?, | ||
| ): String? { | ||
| if (scheme == null || !scheme.startsWith(SCHEME_PREFIX)) return null | ||
| if (host != HOST_KAKAOLINK) return null | ||
| val token = rawToken?.takeIf { TOKEN_FORMAT.matches(it) } ?: return null | ||
| return token | ||
| } | ||
|
|
||
| /** 카카오 네이티브 앱 키를 붙인 스킴 — 키 값 자체는 매니페스트 플레이스홀더가 맞춘다. */ | ||
| private const val SCHEME_PREFIX = "kakao" | ||
| private const val HOST_KAKAOLINK = "kakaolink" | ||
| private const val QUERY_INVITE_TOKEN = "inviteToken" | ||
|
|
||
| /** base64url 문자만, 길이 상한 128 — 서버 발급 길이(43)의 여유분이지 계약값은 아니다. */ | ||
| private val TOKEN_FORMAT = Regex("^[A-Za-z0-9_-]{1,128}$") | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requestLogin()은 두 경로에서 불립니다. 하나는 랜딩이!isLoggedIn일 때 직접 부르는 경로이고, 다른 하나는ReceiverInvitationViewModel이Unauthenticated(401·1000)를 받아LoginRequired를 내는 경로입니다. 두 번째는 셸이 로그인 상태라고 본 뒤에만 탈 수 있습니다(비로그인이면 Accept 가 VM 까지 가지 않음). 이때는 랜딩 아래가 온보딩이 아니라 Home 이라, 이 주석의 전제가 맞지 않습니다.그 경우 pop 하는 순간에
isLoggedIn이 아직true면MainViewModel.pendingInvitationToken이 그대로 토큰을 냅니다.token == awaitingLogin && !loggedIn조건이 로그인 상태에서는 걸리지 않기 때문입니다. 그러면currentDestination?.id키가 바뀐LaunchedEffect가 랜딩을 곧바로 다시 push 할 수 있습니다.TokenAuthenticator가 refresh 실패 때clearSession()을 하긴 하지만, DataStore 방출과 이 effect 중 어느 쪽이 먼저 오는지는 보장되지 않습니다. refresh 가 네트워크 오류로 끝나 세션이 남는 경우에는 수락을 누를 때마다 같은 일이 되풀이됩니다.로그인 상태에서 받은 401 은
requestLogin과 갈라서 처리하면 좋겠습니다. 예를 들어 오류 팝업을 띄우거나, 셸 쪽 defer 판정이 로그인 여부를 보지 않게 하는 방법이 있습니다. 이 분기를 덮는 테스트(로그인 상태 + accept 가 1000 을 받는 경우)도 하나 있으면 좋겠습니다.