feat: Add Instagram Channel (#2955)
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user