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

@@ -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)

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

View File

@@ -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