Feat : promotion improvements#205
Conversation
…nstants and improved configuration handling - Introduced automation-constants.ts to centralize default configuration values for Discord, Telegram, and Twitter. - Updated Discord automation service to utilize new constants and improve OAuth configuration checks. - Enhanced Telegram automation service with configuration defaults and announcement scheduling logic. - Improved error handling and caching mechanisms for connection status in both Discord and Telegram services.
…ud-v2 into feat/promotion-improvements
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
| const [showPromptInput, setShowPromptInput] = useState(false); | ||
| const [isUploadingAsset, setIsUploadingAsset] = useState(false); | ||
| const [deletingAssetUrl, setDeletingAssetUrl] = useState<string | null>(null); | ||
| const [localAssets, setLocalAssets] = useState(app.promotional_assets || []); |
There was a problem hiding this comment.
Local assets state not synced with prop changes
Medium Severity
The localAssets state is initialized from app.promotional_assets only once when the component mounts, but there's no useEffect to synchronize it when the app prop changes. If the parent component re-renders with updated app data (e.g., after navigation, external changes, or data refetch), the UI will continue displaying stale assets instead of the current values from the prop. This can cause assets to appear present after deletion or missing after being added elsewhere.
|
|
||
| await appsService.update(appId, { | ||
| promotional_assets: updatedAssets, | ||
| }); |
There was a problem hiding this comment.
Race condition in concurrent asset operations causes data loss
Medium Severity
Both uploadPromotionalAsset and deletePromotionalAsset use a read-modify-write pattern without atomic operations. The code reads promotional_assets, modifies the array in memory, then writes the entire array back. If two requests execute concurrently (e.g., user uploads from two tabs, or rapid sequential operations), the second write overwrites the first, silently losing data. For uploads, one asset can vanish; for deletes, an asset intended for deletion may be restored while another is incorrectly removed.
Additional Locations (1)
| setIsUploadingAsset(false); | ||
| if (assetInputRef.current) { | ||
| assetInputRef.current.value = ""; | ||
| } |
There was a problem hiding this comment.
Missing try/catch leaves UI stuck in loading state
Medium Severity
The handleAssetUpload and handleAssetDelete functions set loading state (setIsUploadingAsset(true) and setDeletingAssetUrl(...)) before calling server actions but lack try/catch blocks. Unlike the existing handleGenerateAssets and handlePostNow functions which properly wrap their async calls in try/catch, these handlers will never reset their loading state if the server action throws (e.g., network failure). This leaves upload/delete buttons permanently disabled until the user refreshes the page.
This pull request introduces two main sets of changes: (1) it adds support for uploading and deleting promotional assets (such as images) for apps, including both backend server actions and frontend UI integration, and (2) it centralizes and standardizes automation configuration defaults across Discord, Telegram, and Twitter services. Additionally, it refines the Discord status API to distinguish between OAuth configuration and bot token presence.
Key changes include:
Promotional Asset Upload & Management
app/actions/apps.tsfor uploading and deleting promotional assets, with file validation, ownership checks, and blob storage integration.AppPromotecomponent to allow users to upload, display, and delete promotional images, including UI feedback and local state management for assets. [1] [2] [3]Automation Configuration Standardization
lib/services/automation-constants.tsto centralize default configuration values and helper functions for Discord, Telegram, and Twitter automations.Discord Status API Improvements
These changes improve the user experience around app promotion and asset management, reduce code duplication in automation services, and clarify Discord integration status for organizations.
Note
Adds promotional asset management and standardizes automation config defaults while refining social integration status handling.
uploadPromotionalAsset/deletePromotionalAssetwith validation/blob storage;AppPromoteUI to upload, preview, and delete assets with local state and toastslib/services/automation-constants.tsand applies to Discord/Telegram services to remove duplicated default logic and use helpersisOAuthConfigured) from message capability (canSendMessages) and updates/api/v1/discord/statusisAnnouncementDueto Telegram; minor improvements to promo image selectiongetConnectionStatusresults with cache invalidation on credential changesWritten by Cursor Bugbot for commit ae86f83. This will update automatically on new commits. Configure here.