feat: Display sent status of emails in email channel (#3125)

This commit is contained in:
Pranav Raj S
2021-10-14 12:55:46 +05:30
committed by GitHub
parent 5c30bc3e2b
commit 99abbb8158
18 changed files with 187 additions and 55 deletions

View File

@@ -61,7 +61,7 @@ class ContactInbox < ApplicationRecord
end
def validate_email_source_id
errors.add(:source_id, "invalid source id for Email inbox. valid Regex #{Device.email_regexp}") unless Devise.email_regexp.match?(source_id)
errors.add(:source_id, "invalid source id for Email inbox. valid Regex #{Devise.email_regexp}") unless Devise.email_regexp.match?(source_id)
end
def valid_source_id_format?

View File

@@ -205,17 +205,15 @@ class Message < ApplicationRecord
end
def trigger_notify_via_mail
return EmailReplyWorker.perform_in(1.second, id) if inbox.inbox_type == 'Email'
# will set a redis key for the conversation so that we don't need to send email for every new message
# last few messages coupled together is sent every 2 minutes rather than one email for each message
# if redis key exists there is an unprocessed job that will take care of delivering the email
return if Redis::Alfred.get(conversation_mail_key).present?
Redis::Alfred.setex(conversation_mail_key, Time.zone.now)
if inbox.inbox_type == 'Email'
ConversationReplyEmailWorker.perform_in(2.seconds, conversation.id, Time.zone.now)
else
ConversationReplyEmailWorker.perform_in(2.minutes, conversation.id, Time.zone.now)
end
Redis::Alfred.setex(conversation_mail_key, id)
ConversationReplyEmailWorker.perform_in(2.minutes, conversation.id, id)
end
def conversation_mail_key