Conversation
|
@mxp96 is attempting to deploy a commit to the Southclaws Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughBackend email removal service enhanced with account querier and authentication repository dependencies to validate last verified email and OAuth presence before deletion. Frontend email settings component updated to provide undo capability for email deletion operations. Changes
Sequence DiagramsequenceDiagram
participant User
participant UI as EmailCard UI
participant Service as Email Manager
participant AccountQ as Account Querier
participant AuthRepo as Auth Repository
participant Bus as Event Bus
User->>UI: Request delete email
UI->>Service: Remove email (with validation)
Service->>AccountQ: Fetch account details
AccountQ-->>Service: Account data
Service->>AuthRepo: Get all auth methods
AuthRepo-->>Service: Auth methods
Service->>Service: Check: Last verified email?
alt Has OAuth method
Service->>Service: Cannot delete last verified
Service-->>UI: Permission denied
UI->>UI: Show undo option
else No OAuth method
Service->>Service: Proceed with removal
Service->>Service: Delete email
Service->>Bus: Publish account update
Bus-->>UI: Update confirmed
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Areas requiring extra attention:
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings, 1 inconclusive)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
.yarn/releases/yarn-4.10.3.cjsis excluded by!**/.yarn/**package.jsonis excluded by!**/*.json
📒 Files selected for processing (2)
app/services/account/account_email/account_email.go(3 hunks)web/src/components/settings/EmailSettings/EmailCard.tsx(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/services/**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
Go app/services must NEVER import from transports (may import resources and other services)
Files:
app/services/account/account_email/account_email.go
🧠 Learnings (1)
📚 Learning: 2025-09-04T20:11:11.162Z
Learnt from: CR
Repo: Southclaws/storyden PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-04T20:11:11.162Z
Learning: Applies to app/transports/**/*.go : Go app/transports may import from services and resources (no reverse dependencies)
Applied to files:
app/services/account/account_email/account_email.go
🧬 Code graph analysis (2)
web/src/components/settings/EmailSettings/EmailCard.tsx (1)
web/src/lib/thread/undo.ts (1)
withUndo(11-42)
app/services/account/account_email/account_email.go (4)
app/resources/account/authentication/repo.go (1)
Repository(10-35)app/resources/account/account_querier/account_querier.go (2)
Querier(23-26)New(28-30)app/resources/account/authentication/authentication_enum_gen.go (3)
ServiceOAuthDiscord(91-91)ServiceOAuthGitHub(90-90)ServiceOAuthGoogle(89-89)app/resources/account/email.go (1)
EmailAddress(9-13)
| await withUndo({ | ||
| message: "Email address deleted", | ||
| duration: 5000, | ||
| toastId: `email-${email.id}`, | ||
| action: async () => { | ||
| await accountEmailRemove(email.id); | ||
| }, | ||
| onUndo: () => {}, | ||
| }); |
There was a problem hiding this comment.
Show the toast as “pending” until accountEmailRemove completes.
withUndo now fires “Email address deleted” immediately, but the actual accountEmailRemove(email.id) call only runs after the undo window closes. When the new backend validation (e.g., “can’t delete last verified email without OAuth”) kicks in, we’ll spend five seconds telling the user the delete succeeded before bubbling the failure. Please either delay the success toast until accountEmailRemove resolves, or change this toast copy to a neutral “Deletion scheduled – undo?” and trigger the real success message once the API call finishes, so the UX stays truthful to the outcome.
🤖 Prompt for AI Agents
In web/src/components/settings/EmailSettings/EmailCard.tsx around lines 31-39,
the current withUndo call immediately shows a success “Email address deleted”
toast even though accountEmailRemove(email.id) runs only after the undo window;
change the UX so the toast is neutral/pending and only show a final success or
failure after accountEmailRemove completes. Concretely: change the initial
message to something like “Deletion scheduled — undo?” (neutral/pending), keep
the undo window behavior, then inside the action await
accountEmailRemove(email.id) and after it resolves fire a success toast (or on
error fire a failure toast); ensure onUndo still cancels without showing success
and reuse or pass the same toastId when updating/replacing the pending toast so
the user sees the final outcome in place.
| ftag.With(ftag.PermissionDenied), | ||
| fmsg.WithDesc( | ||
| "last verified email", | ||
| "You cannot delete your last verified email address without linking an OAuth account (Discord, GitHub, or Google) first. Please add an OAuth authentication method before removing this email.", |
There was a problem hiding this comment.
Since OAuth providers are 1. dynamic (they may be enabled/disabled) and 2. a growing list over time (we'll add more) it's best not to mention specific auth methods in the error, instead use more generic language like:
You cannot delete your only verified email. Please add another verified email address first.
| } | ||
|
|
||
| // Check if account has OAuth authentication (Discord or GitHub) | ||
| hasOAuthAuth := lo.ContainsBy(authMethods, func(auth *authentication_repo.Authentication) bool { |
There was a problem hiding this comment.
I don't think this logic should rely on OAuth providers specifically, just emails added to the account. Unless there's something I've missed with the intention here.
look like I lost my local change, I will re-work for this feature, sorry btw
#616