fix: prevent sending empty title or body in push messages#2904
fix: prevent sending empty title or body in push messages#2904Bhaaru2 wants to merge 4 commits intoappwrite:mainfrom
Conversation
Console (appwrite/console)Project ID: Sites (1)
Tip Schedule functions to run as often as every minute with cron expressions |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughA push notification creation component was updated to add local draft tracking and input trimming. The create() function now copies Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Greptile SummaryThis PR adds whitespace-trim validation to the push message creation flow, preventing messages with whitespace-only titles or bodies from being sent. It also fixes a subtle pre-existing bug where Key changes:
Remaining concerns from prior review rounds:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User clicks Create or Save as Draft] --> B[create function invoked]
B --> C[Capture isDraft from draft\nReset draft to false]
C --> D[Compute trimmedTitle and trimmedBody]
D --> E{isDraft?}
E -- No --> F{trimmedTitle or trimmedBody empty?}
F -- Yes --> G[Show error notification\nReturn early - no API call]
F -- No --> H[Assign trimmed values back to title and body]
E -- Yes --> H
H --> I[Call Appwrite SDK createPush\nwith draft: isDraft]
I --> J{API Response}
J -- Success --> K[Show success notification\nNavigate to message page]
J -- Failure --> L[Show error notification\ntrackError called]
Last reviewed commit: a314c4b |
src/routes/(console)/project-[region]-[project]/messaging/create-[type]/(type)/push.svelte
Outdated
Show resolved
Hide resolved
src/routes/(console)/project-[region]-[project]/messaging/create-[type]/(type)/push.svelte
Outdated
Show resolved
Hide resolved
src/routes/(console)/project-[region]-[project]/messaging/create-[type]/(type)/push.svelte
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/routes/`(console)/project-[region]-[project]/messaging/create-[type]/(type)/push.svelte:
- Around line 39-45: The validation block in push.svelte exits early when title
or body are empty but doesn't clear the shared draft state set by saveAsDraft(),
causing subsequent sends to still carry draft: true; before the early return in
the if (!title?.trim() || !body?.trim()) block, reset the draft flag (the shared
state mutated by saveAsDraft(), e.g., clear or set draft = false or call the
counterpart resetDraft/clearDraft helper) so that subsequent Create actions
won't include draft: true, then keep the addNotification call and return as-is.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5e7dbb6f-d81d-4217-8d82-e6667d2fc7e6
📒 Files selected for processing (1)
src/routes/(console)/project-[region]-[project]/messaging/create-[type]/(type)/push.svelte

What does this PR do?
Fixes #968
Adds validation to prevent sending push messages when the title or body contains only whitespace.
The inputs are trimmed before submission, and if either field is empty an error notification is shown to the user.
Test Plan
Related Issues
Fixes #968
Summary by CodeRabbit