Chore: Add Twitter documentation (#648)
* Chore: Add Twitter documentation Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user