Feat: send fb message outside of standard messaging window (#4439)

This commit is contained in:
Tejaswini Chile
2022-04-19 12:21:20 +05:30
committed by GitHub
parent d2d838afd1
commit 1ccd29140d
6 changed files with 26 additions and 9 deletions

View File

@@ -90,10 +90,20 @@ class Conversation < ApplicationRecord
delegate :auto_resolve_duration, to: :account
def can_reply?
return last_message_less_than_24_hrs? if additional_attributes['type'] == 'instagram_direct_message'
return true unless inbox&.channel&.has_24_hour_messaging_window?
last_incoming_message = messages.incoming.last
return false if last_incoming_message.nil?
last_message_less_than_24_hrs?
end
def last_incoming_message
messages&.incoming&.last
end
def last_message_less_than_24_hrs?
return false if last_incoming_message.nil?
Time.current < last_incoming_message.created_at + 24.hours