FIX: Skip pulling hotlinked images for nil user bio (#16901)

This commit is contained in:
David Taylor 2022-05-24 11:52:13 +01:00 committed by GitHub
parent a5779a7d0b
commit 19f583c449
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -7,7 +7,7 @@ module Jobs
raise Discourse::InvalidParameters.new(:user_id) if @user_id.blank?
user_profile = UserProfile.find_by(user_id: @user_id)
return if user_profile.blank?
return if user_profile.blank? || user_profile.bio_cooked.nil?
large_image_urls = []
broken_image_urls = []

View File

@ -21,5 +21,10 @@ describe Jobs::PullUserProfileHotlinkedImages do
expect { Jobs::PullUserProfileHotlinkedImages.new.execute(user_id: user.id) }.to change { Upload.count }.by(1)
expect(user.user_profile.reload.bio_cooked).to include(Upload.last.url)
end
it 'handles nil bio' do
expect { Jobs::PullUserProfileHotlinkedImages.new.execute(user_id: user.id) }.to change { Upload.count }.by(0)
expect(user.user_profile.reload.bio_cooked).to eq(nil)
end
end
end