Add support for handling banned accounts in login mutations and tests#161
Conversation
📝 WalkthroughWalkthroughThe GraphQL schema and operations introduce a new ChangesLogin union result handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant HackersPubRepository
participant ApolloClient
Client->>HackersPubRepository: completeLoginChallenge() / loginByPasskey()
HackersPubRepository->>ApolloClient: execute mutation
ApolloClient-->>HackersPubRepository: union result (Session or AccountBannedError)
alt onSession present
HackersPubRepository->>HackersPubRepository: toDomainSession()
HackersPubRepository-->>Client: success(Session)
else onAccountBannedError present
HackersPubRepository->>HackersPubRepository: accountBannedMessage(since)
HackersPubRepository-->>Client: failure(banned message)
else unrecognized __typename
HackersPubRepository-->>Client: failure(unknown result message)
end
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/src/main/java/pub/hackers/android/data/repository/HackersPubRepository.kt (1)
926-954: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: the two
toDomainSession()bodies are identical, andaccountBannedMessagetakesAny.The
CompleteLoginChallengeMutation.OnSessionandLoginByPasskeyMutation.OnSessionmappers are byte-for-byte duplicates. Since they operate on distinct generated types they can't be merged directly, but you could funnel both through a small shared builder taking the primitive fields to keep them from drifting. Separately,accountBannedMessage(since: Any)interpolates the raw scalar (e.g.2026-07-05T00:00:00Z) directly into a user-facing message; consider parsing/formatting the timestamp if this string is surfaced in the UI. Both are minor and consistent with the rest of the file, so feel free to defer.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/src/main/java/pub/hackers/android/data/repository/HackersPubRepository.kt` around lines 926 - 954, The `CompleteLoginChallengeMutation.OnSession.toDomainSession()` and `LoginByPasskeyMutation.OnSession.toDomainSession()` mappings in `HackersPubRepository` are duplicated, so extract the shared field-to-`Session` construction into a small private helper and have both methods delegate to it to prevent drift. Also update `accountBannedMessage(since: Any)` to avoid interpolating the raw scalar directly; convert the `since` value into a properly formatted, user-friendly timestamp before building the message.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@app/src/main/java/pub/hackers/android/data/repository/HackersPubRepository.kt`:
- Around line 926-954: The
`CompleteLoginChallengeMutation.OnSession.toDomainSession()` and
`LoginByPasskeyMutation.OnSession.toDomainSession()` mappings in
`HackersPubRepository` are duplicated, so extract the shared field-to-`Session`
construction into a small private helper and have both methods delegate to it to
prevent drift. Also update `accountBannedMessage(since: Any)` to avoid
interpolating the raw scalar directly; convert the `since` value into a properly
formatted, user-friendly timestamp before building the message.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 75b25a25-4494-4243-b576-8aead5e69ceb
📒 Files selected for processing (4)
app/src/main/graphql/pub/hackers/android/operations.graphqlapp/src/main/graphql/pub/hackers/android/schema.graphqlsapp/src/main/java/pub/hackers/android/data/repository/HackersPubRepository.ktapp/src/test/java/pub/hackers/android/data/repository/HackersPubRepositoryAuthTest.kt
Resolved Symptoms
Root Cause
completeLoginChallengeresponse can return a union result: eitherSessionorAccountBannedErrorSessionloginByPasskeyuses the same kind of authentication result, so it could hit the same response-mapping issueSolution
completeLoginChallengeandloginByPasskeyGraphQL operations to request__typenameand union fragmentsSessionresults into the existing domainSessionmodelAccountBannedErroras a failed login result with a message that includes the banned timestampReferences