Feature: SignIn with Twitter (#479)

* Add Twitter SignIn flow

Co-authored-by: Sojan Jose <sojan@pepalo.com>
This commit is contained in:
Pranav Raj S
2020-02-11 14:27:38 +05:30
committed by GitHub
parent 272c481464
commit 30f4c08143
14 changed files with 249 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ class Account < ApplicationRecord
has_many :conversations, dependent: :destroy
has_many :contacts, dependent: :destroy
has_many :facebook_pages, dependent: :destroy, class_name: '::Channel::FacebookPage'
has_many :twitter_profiles, dependent: :destroy, class_name: '::Channel::TwitterProfile'
has_many :web_widgets, dependent: :destroy, class_name: '::Channel::WebWidget'
has_many :telegram_bots, dependent: :destroy
has_many :canned_responses, dependent: :destroy

View File

@@ -41,9 +41,21 @@ class Channel::TwitterProfile < ApplicationRecord
end
end
def twitter_client
Twitty::Facade.new do |config|
config.consumer_key = ENV.fetch('TWITTER_CONSUMER_KEY', nil)
config.consumer_secret = ENV.fetch('TWITTER_CONSUMER_SECRET', nil)
config.access_token = twitter_access_token
config.access_token_secret = twitter_access_token_secret
config.base_url = 'https://api.twitter.com'
config.environment = ENV.fetch('TWITTER_ENVIRONMENT', '')
end
end
private
def unsubscribe
# to implement
webhooks_list = twitter_client.fetch_webhooks.body
twitter_client.unsubscribe_webhook(id: webhooks_list.first['id']) if webhooks_list.present?
end
end