Chore: Add Twitter documentation (#648)

* Chore: Add Twitter documentation

Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
Pranav Raj S
2020-03-28 11:51:42 +05:30
committed by GitHub
parent a3c2d4e5bd
commit 50ebbc13b6
20 changed files with 103 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
class Twitter::CallbacksController < Twitter::BaseController
def show
return redirect_to app_new_twitter_inbox_url if permitted_params[:denied]
return redirect_to twitter_app_redirect_url if permitted_params[:denied]
@response = twitter_client.access_token(
oauth_token: permitted_params[:oauth_token],
@@ -10,9 +10,9 @@ class Twitter::CallbacksController < Twitter::BaseController
inbox = build_inbox
::Redis::Alfred.delete(permitted_params[:oauth_token])
::Twitter::WebhookSubscribeService.new(inbox_id: inbox.id).perform
redirect_to app_twitter_inbox_agents_url(inbox_id: inbox.id)
redirect_to app_twitter_inbox_agents_url(account_id: account.id, inbox_id: inbox.id)
else
redirect_to app_new_twitter_inbox_url
redirect_to twitter_app_redirect_url
end
end
@@ -30,6 +30,10 @@ class Twitter::CallbacksController < Twitter::BaseController
@account ||= Account.find_by!(id: account_id)
end
def twitter_app_redirect_url
app_new_twitter_inbox_url(account_id: account.id)
end
def build_inbox
ActiveRecord::Base.transaction do
twitter_profile = account.twitter_profiles.create(

View File

@@ -10,7 +10,7 @@
"PLACEHOLDER": "Password"
},
"API": {
"SUCCESS_MESSAGE": "Login Successfull",
"SUCCESS_MESSAGE": "Login Successful",
"ERROR_MESSAGE": "Could not connect to Woot Server, Please try again later",
"UNAUTH": "Username / Password Incorrect. Please try again"
},
@@ -18,4 +18,4 @@
"CREATE_NEW_ACCOUNT": "Create new account",
"SUBMIT": "Sign In"
}
}
}

View File

@@ -4,7 +4,7 @@ class Twitter::WebhookSubscribeService
pattr_initialize [:inbox_id]
def perform
register_response = twitter_client.register_webhook(url: webhooks_twitter_url)
register_response = twitter_client.register_webhook(url: webhooks_twitter_url(protocol: 'https'))
twitter_client.subscribe_webhook if register_response.status == '200'
Rails.logger.info 'TWITTER_REGISTER_WEBHOOK_FAILURE: ' + register_response.body.to_s
end