fix: Add a check for 24 hour window before sending a message (#1084)
Co-authored-by: Sojan Jose <sojan@pepalo.com>
This commit is contained in:
@@ -58,6 +58,16 @@ class Conversation < ApplicationRecord
|
||||
|
||||
acts_as_taggable_on :labels
|
||||
|
||||
def can_reply?
|
||||
return true unless inbox&.channel&.has_24_hour_messaging_window?
|
||||
|
||||
last_incoming_message = messages.incoming.last
|
||||
|
||||
return false if last_incoming_message.nil?
|
||||
|
||||
Time.current < last_incoming_message.created_at + 24.hours
|
||||
end
|
||||
|
||||
def update_assignee(agent = nil)
|
||||
update!(assignee: agent)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user