Chore: Refactor round robin logic (#1015)
Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
This commit is contained in:
@@ -153,7 +153,6 @@ class Message < ApplicationRecord
|
||||
end
|
||||
|
||||
def notify_via_mail
|
||||
conversation_mail_key = Redis::Alfred::CONVERSATION_MAILER_KEY % conversation.id
|
||||
if Redis::Alfred.get(conversation_mail_key).nil? && conversation.contact.email? && outgoing?
|
||||
# set a redis key for the conversation so that we don't need to send email for every
|
||||
# new message that comes in and we dont enque the delayed sidekiq job for every message
|
||||
@@ -165,6 +164,10 @@ class Message < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def conversation_mail_key
|
||||
format(::Redis::Alfred::CONVERSATION_MAILER_KEY, conversation_id: conversation.id)
|
||||
end
|
||||
|
||||
def validate_attachments_limit(_attachment)
|
||||
errors.add(attachments: 'exceeded maximum allowed') if attachments.size >= NUMBER_OF_PERMITTED_ATTACHMENTS
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user