Skip to content

refactor(publishing): consolidate social media API error handling and retry strategy in publishing#188

Merged
wheatliu merged 1 commit into
mainfrom
refactor/channel
Nov 13, 2025
Merged

refactor(publishing): consolidate social media API error handling and retry strategy in publishing#188
wheatliu merged 1 commit into
mainfrom
refactor/channel

Conversation

@Yuuki-Sakura
Copy link
Copy Markdown
Contributor

Pull Request

🧩 Issue Link

Closes #187

📝 Description

📋 Changes

  • consolidate social media API error handling and retry strategy in publishing

🧪 Testing

  • Passed ESLint check locally
  • Build succeeded locally
  • Added/updated related tests
  • All tests passed

📝 Notes

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Yuuki-Sakura, 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 comprehensive refactoring of the social media publishing system. The core objective is to standardize and centralize error handling across diverse social media API integrations, ensuring a more predictable and manageable response to operational failures. Furthermore, a sophisticated retry strategy has been implemented to enhance the system's resilience, allowing publishing tasks to recover gracefully from transient issues. This extensive overhaul includes a significant reorganization of the module structure, the introduction of a new, unified exception hierarchy, and a complete redesign of the publishing services to promote modularity and robustness.

Highlights

  • Refactored Module Structure: The module structure has been significantly reorganized, renaming 'plat' directories to 'platforms' and 'publish' to 'publishing' for improved clarity and consistency across the codebase.
  • Consolidated API Error Handling: A new SocialMediaError base class and platform-specific error classes (e.g., BilibiliError, FacebookError, InstagramError) have been introduced to standardize error reporting and handling for all social media API interactions. This centralizes error logic and provides more detailed context for debugging.
  • Enhanced Publishing Retry Strategy: The publishing process now incorporates a more robust retry mechanism. This includes explicit handling for immediate publishing, media processing finalization, and distinguishing between retryable and non-retryable errors to improve task resilience.
  • Overhauled Publishing Logic: The previous mcp (Model Context Protocol) and publish/plat services have been replaced by a new publishing module. This new module features dedicated providers for each social media platform and consumers (ImmediatePublishPostConsumer, FinalizePublishPostConsumer) to manage the lifecycle of publishing tasks more effectively.
  • Updated Data Models: The PublishTask and PostMediaContainer database schemas have been updated to include new fields like queued and jobId, which are essential for supporting the new queuing and job management logic within the refactored publishing system.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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.

@wheatliu wheatliu merged commit 604e52f into main Nov 13, 2025
4 checks passed
Copy link
Copy Markdown
Contributor

@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

This pull request is a significant and well-executed refactoring of the publishing and related modules. The changes greatly improve the codebase's structure, consistency, and robustness. Key improvements include:

  • Consistent Naming: File and directory names now consistently use kebab-case, improving readability and maintainability.
  • Modularization: The logic for publishing has been consolidated into a new, well-structured publishing module. The use of a strategy pattern with PUBLISHING_PROVIDERS is an excellent design choice for handling different social media platforms.
  • Error Handling: The introduction of a new error handling framework with a base SocialMediaError class and platform-specific exceptions is a major enhancement. This provides centralized, consistent, and more informative error handling across the application.
  • Code Cleanup: Many parts of the code have been cleaned up, removing dead code, redundant logic, and improving clarity.
  • Improved Logic: The logic for creating and running publishing tasks has been improved to prevent duplicate processing.

Overall, this is a high-quality refactoring that sets a strong foundation for future development. I have one minor suggestion for improvement.

Comment on lines +22 to +25
constructor(
private reflector: Reflector,
private readonly skKeyService: SkKeyService,
) {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The reflector dependency is injected into the SkKeyAuthGuard constructor but it is not used anywhere in the class. To keep the code clean and avoid unnecessary dependencies, it should be removed.

  constructor(
    private readonly skKeyService: SkKeyService,
  ) {}

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.

refactor(publishing): consolidate social media API error handling and retry strategy in publishing

2 participants