mirror of
https://github.com/discourse/discourse.git
synced 2026-09-05 04:40:41 -05:00
FEATURE: Pull hotlinked images in user bios (#14726)
This commit is contained in:
@@ -12,6 +12,7 @@ class UserProfile < ActiveRecord::Base
|
||||
validates :user, presence: true
|
||||
before_save :cook
|
||||
after_save :trigger_badges
|
||||
after_save :pull_hotlinked_image
|
||||
|
||||
validate :website_domain_validator, if: Proc.new { |c| c.new_record? || c.website_changed? }
|
||||
|
||||
@@ -19,6 +20,8 @@ class UserProfile < ActiveRecord::Base
|
||||
|
||||
BAKED_VERSION = 1
|
||||
|
||||
attr_accessor :skip_pull_hotlinked_image
|
||||
|
||||
def bio_excerpt(length = 350, opts = {})
|
||||
return nil if bio_cooked.blank?
|
||||
excerpt = PrettyText.excerpt(bio_cooked, length, opts).sub(/<br>$/, '')
|
||||
@@ -113,6 +116,16 @@ class UserProfile < ActiveRecord::Base
|
||||
BadgeGranter.queue_badge_grant(Badge::Trigger::UserChange, user: self)
|
||||
end
|
||||
|
||||
def pull_hotlinked_image
|
||||
if !skip_pull_hotlinked_image && saved_change_to_bio_raw?
|
||||
Jobs.enqueue_in(
|
||||
SiteSetting.editing_grace_period,
|
||||
:pull_user_profile_hotlinked_images,
|
||||
user_id: self.user_id
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def cooked
|
||||
|
||||
Reference in New Issue
Block a user