feat: Add Instagram Channel (#2955)

This commit is contained in:
Tejaswini Chile
2021-10-05 14:35:32 +05:30
committed by GitHub
parent 30244f79a6
commit 40d0b2faf3
30 changed files with 825 additions and 50 deletions

View File

@@ -8,6 +8,7 @@
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer not null
# instagram_id :string
# page_id :string not null
#
# Indexes
@@ -35,6 +36,19 @@ class Channel::FacebookPage < ApplicationRecord
true
end
def create_contact_inbox(instagram_id, name)
ActiveRecord::Base.transaction do
contact = inbox.account.contacts.create!(name: name)
::ContactInbox.create(
contact_id: contact.id,
inbox_id: inbox.id,
source_id: instagram_id
)
rescue StandardError => e
Rails.logger.info e
end
end
def subscribe
# ref https://developers.facebook.com/docs/messenger-platform/reference/webhook-events
response = Facebook::Messenger::Subscriptions.subscribe(