chore: add human agent check in instagram channel
This commit is contained in:
@@ -117,7 +117,9 @@ class Conversation < ApplicationRecord
|
||||
def can_reply?
|
||||
channel = inbox&.channel
|
||||
|
||||
return can_reply_on_instagram? if additional_attributes['type'] == 'instagram_direct_message'
|
||||
return can_reply_on_instagram_via_messenger? if additional_attributes['type'] == 'instagram_direct_message'
|
||||
|
||||
return can_reply_on_instagram? if inbox.instagram_direct?
|
||||
|
||||
return true unless channel&.messaging_window_enabled?
|
||||
|
||||
@@ -143,7 +145,7 @@ class Conversation < ApplicationRecord
|
||||
Time.current < last_incoming_message.created_at + time.hours
|
||||
end
|
||||
|
||||
def can_reply_on_instagram?
|
||||
def can_reply_on_instagram_via_messenger?
|
||||
global_config = GlobalConfig.get('ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT')
|
||||
|
||||
return false if last_incoming_message.nil?
|
||||
@@ -155,6 +157,18 @@ class Conversation < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def can_reply_on_instagram?
|
||||
global_config = GlobalConfig.get('ENABLE_INSTAGRAM_CHANNEL_HUMAN_AGENT')
|
||||
|
||||
return false if last_incoming_message.nil?
|
||||
|
||||
if global_config['ENABLE_INSTAGRAM_CHANNEL_HUMAN_AGENT']
|
||||
Time.current < last_incoming_message.created_at + 7.days
|
||||
else
|
||||
last_message_in_messaging_window?(24)
|
||||
end
|
||||
end
|
||||
|
||||
def toggle_status
|
||||
# FIXME: implement state machine with aasm
|
||||
self.status = open? ? :resolved : :open
|
||||
|
||||
Reference in New Issue
Block a user