Feat: send fb message outside of standard messaging window (#4439)
This commit is contained in:
@@ -33,7 +33,7 @@ class Channel::FacebookPage < ApplicationRecord
|
||||
end
|
||||
|
||||
def has_24_hour_messaging_window?
|
||||
true
|
||||
false
|
||||
end
|
||||
|
||||
def create_contact_inbox(instagram_id, name)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,7 +22,9 @@ class Facebook::SendOnFacebookService < Base::SendOnChannelService
|
||||
def fb_text_message_params
|
||||
{
|
||||
recipient: { id: contact.get_source_id(inbox.id) },
|
||||
message: { text: message.content }
|
||||
message: { text: message.content },
|
||||
messaging_type: 'MESSAGE_TAG',
|
||||
tag: 'ACCOUNT_UPDATE'
|
||||
}
|
||||
end
|
||||
|
||||
@@ -37,7 +39,9 @@ class Facebook::SendOnFacebookService < Base::SendOnChannelService
|
||||
url: attachment.file_url
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
messaging_type: 'MESSAGE_TAG',
|
||||
tag: 'ACCOUNT_UPDATE'
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user