-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
chore: Add validation to prevent message flooding #9254
Conversation
sojan-official
commented
Apr 17, 2024
- Add a validation to limit messages created per minute to avoid message flooding cases.
Co-authored-by: Pranav <pranav@chatwoot.com>
app/models/message.rb
Outdated
return if conversation.blank? | ||
|
||
# there are cases where automations can result in message loops, we need to prevent such cases. | ||
errors.add(:base, 'Too many messages') if conversation.messages.where('created_at >= ?', |
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.
- Extend the limit to 200 per minute.
- Add Rails.logger for the error.
- Create an alert on NewRelic for this error.
|
||
# there are cases where automations can result in message loops, we need to prevent such cases. | ||
if conversation.messages.where('created_at >= ?', 1.minute.ago).count >= Limits.conversation_message_per_minute_limit | ||
Rails.logger.error "Too many message: Account Id - #{account_id} : Conversation id - #{conversation_id}" |
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.
@vishnu-narayanan Could you add a trigger for this one ?
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |