-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
- Fixed reaction to deleted message bug #961
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Warning Rate limit exceeded@Gamius00 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 47 seconds before requesting another review. ⌛ 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. 📒 Files selected for processing (1)
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
convex/messages.ts
(2 hunks)
🔇 Additional comments (1)
convex/messages.ts (1)
168-176
: LGTM! Good addition of user verification.The added user verification ensures proper authentication and authorization before proceeding with message deletion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
convex/messages.ts (1)
179-181
:⚠️ Potential issueFix incorrect error message.
The error message refers to "chatId" when validating "messageId".
Apply this fix:
if (!parsedMessageId) { - throw new ConvexError("chatId was invalid"); + throw new ConvexError("messageId was invalid"); }
🧹 Nitpick comments (1)
convex/messages.ts (1)
184-192
: Optimize operation order.The code currently deletes reactions before verifying message ownership. This could lead to unnecessary database operations if the user is not authorized to delete the message. Consider moving the reaction deletion after the ownership verification.
Apply this reordering:
const message = await ctx.table("messages").getX(parsedMessageId); if ((await message.edge("user")).clerkId !== identity.tokenIdentifier) { throw new ConvexError( "UNAUTHORIZED REQUEST: User tried to delete a message from another person.", ); } + + const messageReactions = await ctx + .table("reactions", "messageId", (q) => + q.eq("messageId", parsedMessageId) + ) + .collect(); + + await Promise.all( + messageReactions.map((reaction) => reaction.delete()) + ); const chatId = message.privateChatId; const chat = await ctx.table("privateChats").getX(chatId); const usersInChat = await chat.edge("users");
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
convex/messages.ts
(2 hunks)
🔇 Additional comments (1)
convex/messages.ts (1)
168-176
: LGTM! Good security enhancement.The added user verification ensures proper authentication and prevents unauthorized access by checking both Clerk and Convex identities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to update the optimistic updates aswell
…o reaction-on-deleted-message
Summary by CodeRabbit