Fix: save twitter profile for inbox (#6667)

Fixes: #737
This commit is contained in:
Tejaswini Chile
2023-04-12 14:16:24 +05:30
committed by GitHub
parent d04344c094
commit 44837aa657
4 changed files with 26 additions and 4 deletions

View File

@@ -49,10 +49,22 @@ class Twitter::CallbacksController < Twitter::BaseController
twitter_access_token_secret: parsed_body['oauth_token_secret'],
profile_id: parsed_body['user_id']
)
account.inboxes.create!(
inbox = account.inboxes.create!(
name: parsed_body['screen_name'],
channel: twitter_profile
)
save_profile_image(inbox)
inbox
end
def save_profile_image(inbox)
response = twitter_client.user_show(screen_name: inbox.name)
return unless response.success?
parsed_user_profile = JSON.parse(response.read_body)
::Avatar::AvatarFromUrlJob.perform_later(inbox, parsed_user_profile['profile_image_url_https'])
end
def permitted_params