PERF: avoid checking card background and user background when not supplied (#11299)

Previously we were performing a bunch of needless work when SSO failed
to supply profile and card backgrounds.
This commit is contained in:
Sam 2020-11-25 10:53:44 +11:00 committed by GitHub
parent 51f9a56137
commit 3e1b94c227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -305,8 +305,10 @@ class DiscourseSingleSignOn < SingleSignOn
end
end
if profile_background_url.present?
profile_background_missing = user.user_profile.profile_background_upload.blank? || Upload.get_from_url(user.user_profile.profile_background_upload.url).blank?
if (profile_background_missing || SiteSetting.sso_overrides_profile_background) && profile_background_url.present?
if profile_background_missing || SiteSetting.sso_overrides_profile_background
profile_background_changed = sso_record.external_profile_background_url != profile_background_url
if profile_background_changed || profile_background_missing
Jobs.enqueue(:download_profile_background_from_url,
@ -316,9 +318,11 @@ class DiscourseSingleSignOn < SingleSignOn
)
end
end
end
if card_background_url.present?
card_background_missing = user.user_profile.card_background_upload.blank? || Upload.get_from_url(user.user_profile.card_background_upload.url).blank?
if (card_background_missing || SiteSetting.sso_overrides_profile_background) && card_background_url.present?
if card_background_missing || SiteSetting.sso_overrides_profile_background
card_background_changed = sso_record.external_card_background_url != card_background_url
if card_background_changed || card_background_missing
Jobs.enqueue(:download_profile_background_from_url,
@ -328,6 +332,7 @@ class DiscourseSingleSignOn < SingleSignOn
)
end
end
end
# change external attributes for sso record
sso_record.external_username = username