Skip to content

Conversation

@polyglot-k
Copy link
Contributor

@polyglot-k polyglot-k commented Aug 24, 2025

✨ 구현한 기능

📢 논의하고 싶은 내용

🎸 기타

Summary by CodeRabbit

  • Bug Fixes
    • After a successful deposit, related applications are now reliably updated from Pending to Approved, preventing stuck states and ensuring the dashboard shows correct status.
    • Improved error handling for missing application records, producing clearer failures and reducing silent errors during payment processing.
    • Notifications and confirmation emails continue to be sent as before, with status updates reflected consistently.

@polyglot-k polyglot-k self-assigned this Aug 24, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 24, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Caution

Review failed

The pull request is closed.

Walkthrough

DepositSuccessEventHandler now fetches the related Application via ApplicationJpaRepository using the virtual account log’s applicationId, sets its status to APPROVED when previously PENDING, and throws APPLICATION_LIST_NOT_FOUND if absent. Constructor gains the new repository dependency; notifications and email flow remain unchanged.

Changes

Cohort / File(s) Summary
Event handling update
src/main/java/life/mosu/mosuserver/application/virtualaccount/event/DepositSuccessEventHandler.java
Added ApplicationJpaRepository dependency; after loading VirtualAccountLog and ExamApplication, fetches Application by log.getApplicationId() and throws APPLICATION_LIST_NOT_FOUND if missing; sets status to ApplicationStatus.APPROVED when prior status is PENDING; retains LunaNotificationEvent publish and mail send.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor VA as Virtual Account System
  participant H as DepositSuccessEventHandler
  participant V as VirtualAccountLogService
  participant E as ExamApplicationJpaRepository
  participant A as ApplicationJpaRepository
  participant N as NotifyEventPublisher
  participant M as MailNotifier

  VA->>H: DepositSuccessEvent
  H->>V: findByTxId(txId)
  V-->>H: VirtualAccountLog
  H->>E: findById(log.examApplicationId)
  E-->>H: ExamApplication or null
  alt exam application missing
    H-->>VA: throws EXAM_APPLICATION_NOT_FOUND
  else
    H->>A: findById(log.applicationId)
    A-->>H: Application or null
    alt application missing
      H-->>VA: throws APPLICATION_LIST_NOT_FOUND
    else
      H->>A: save(status=APPROVED)  %% new/changed action (green)
      H->>N: publish(LunaNotificationEvent)
      H->>M: send(DepositSuccessMailRequest)
      H-->>VA: ack
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

Thump-thump, I dig and hop,
Found the app, gave it a prop.
Status flipped, a carrot cheer,
Notifications bounce, mails appear.
Hooray — approved! 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ceebc49 and 6141749.

📒 Files selected for processing (1)
  • src/main/java/life/mosu/mosuserver/application/virtualaccount/event/DepositSuccessEventHandler.java (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/fix-deposit

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @polyglot-k, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new feature that automates the update of an application's status following a successful deposit. By integrating application repository access into the deposit success event handler, the system can now automatically transition an application to an 'APPROVED' state, streamlining the process and ensuring data consistency. This change enhances the system's ability to react to financial events by directly impacting the lifecycle of related applications.

Highlights

  • Dependency Injection: The DepositSuccessEventHandler now includes ApplicationJpaRepository to interact with application data.
  • Application Status Update: Upon a successful deposit event, the corresponding application's status is automatically updated to APPROVED.
  • Error Handling: New error handling has been added to gracefully manage scenarios where an application associated with a deposit log cannot be found.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

입금 성공 이벤트 발생 시, 신청서의 상태를 APPROVED로 변경하는 기능이 추가되었네요. 이벤트 핸들러의 안정성을 높이기 위해, 상태 변경 전 현재 신청서의 상태를 확인하는 로직을 추가하는 것을 제안합니다. 자세한 내용은 코드 리뷰 코멘트를 참고해주세요.

Copy link

@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: 0

🧹 Nitpick comments (4)
src/main/java/life/mosu/mosuserver/application/virtualaccount/event/DepositSuccessEventHandler.java (4)

43-47: Make the status update idempotent to tolerate duplicate events.

If a duplicate DepositSuccessEvent arrives, calling changeStatus repeatedly may be noisy or violate state-transition rules. Guard the write.

Apply this diff locally within this block:

-        application.changeStatus(ApplicationStatus.APPROVED);
+        if (application.getStatus() != ApplicationStatus.APPROVED) {
+            application.changeStatus(ApplicationStatus.APPROVED);
+        }

Optionally enforce optimistic locking on Application (e.g., @Version) to prevent double-handling races.


43-45: Error code naming likely off: APPLICATION_LIST_NOT_FOUND reads unnatural.

If the intent is “application not found,” prefer APPLICATION_NOT_FOUND. The current constant name suggests a collection and may confuse callers/logs.

If the enum contains APPLICATION_NOT_FOUND, apply this change:

-                .orElseThrow(
-                        () -> new CustomRuntimeException(ErrorCode.APPLICATION_LIST_NOT_FOUND));
+                .orElseThrow(
+                        () -> new CustomRuntimeException(ErrorCode.APPLICATION_NOT_FOUND));

If not present, consider adding it and deprecating APPLICATION_LIST_NOT_FOUND.


52-54: Emit external side effects after transaction commit.

notifier.notify(...) and mailer.send(...) run inside the transaction. If the TX later rolls back, side effects already leaked. Prefer AFTER_COMMIT delivery (Spring @TransactionalEventListener) or an outbox.

Sketch:

  • In handle(...): publish an in-process event carrying userId, examId, and mail payload.
  • New listener:
@Service
@RequiredArgsConstructor
public class ApplicationApprovedListener {
  private final NotifyEventPublisher notifier;
  private final MailNotifier<DepositSuccessMailRequest> mailer;

  @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
  public void on(ApplicationApprovedEvent e) {
    notifier.notify(LunaNotificationEvent.create(
        LunaNotificationStatus.APPLICATION_GUEST_SUCCESS, e.userId(), e.examId()));
    mailer.send(e.mailRequest());
  }
}

This avoids duplicates on rollback and keeps the handler pure.


43-47: Add focused tests for the new behavior.

  • Happy path: when deposit succeeds, Application status changes to APPROVED and notifications/mail are triggered.
  • Not-found: missing Application -> throws CustomRuntimeException with the expected ErrorCode.
  • Idempotency (if you add the guard): second invocation does not change state again nor throw.

I can draft unit tests using Mockito for repositories and verifications for notifier/mailer interactions. Want me to push a test skeleton?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 929e98f and ceebc49.

📒 Files selected for processing (1)
  • src/main/java/life/mosu/mosuserver/application/virtualaccount/event/DepositSuccessEventHandler.java (3 hunks)
🔇 Additional comments (2)
src/main/java/life/mosu/mosuserver/application/virtualaccount/event/DepositSuccessEventHandler.java (2)

5-6: Confirm the business-state mapping: Deposit success -> ApplicationStatus.APPROVED.

Is APPROVED the intended post-payment state (vs. PAID/COMPLETED/RECEIVED)? If approval is an admin action in your domain, this transition could skip a review step.


30-30: Verified: All dependencies and enums are present and correctly wired

  • Confirmed ApplicationJpaRepository interface exists at
    src/main/java/life/mosu/mosuserver/domain/application/repository/ApplicationJpaRepository.java
  • Confirmed ErrorCode enum includes APPLICATION_LIST_NOT_FOUND
  • Confirmed ApplicationStatus enum includes APPROVED

Constructor injection via @RequiredArgsConstructor will pick up the repository under component scan as expected. No further changes required.

@polyglot-k polyglot-k merged commit fb22412 into develop Aug 24, 2025
2 of 3 checks passed
@polyglot-k polyglot-k deleted the feat/fix-deposit branch August 24, 2025 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants