chore: Ability to Disable Gravatars (#5027)
fixes: #3853 - Introduced DISABLE_GRAVATAR Global Config, which will stop chatwoot from making API requests to gravatar - Cleaned up avatar-related logic and centralized it into the avatarable concern - Added specs for the missing cases - Added migration for existing installations to move the avatar to attachment, rather than making the API that results in 404.
This commit is contained in:
13
app/jobs/avatar/avatar_from_gravatar_job.rb
Normal file
13
app/jobs/avatar/avatar_from_gravatar_job.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class Avatar::AvatarFromGravatarJob < ApplicationJob
|
||||
queue_as :low
|
||||
|
||||
def perform(avatarable, email)
|
||||
return if GlobalConfigService.load('DISABLE_GRAVATAR', '').present?
|
||||
return if email.blank?
|
||||
return if avatarable.avatar_url.present?
|
||||
|
||||
hash = Digest::MD5.hexdigest(email)
|
||||
gravatar_url = "https://www.gravatar.com/avatar/#{hash}?d=404"
|
||||
Avatar::AvatarFromUrlJob.perform_later(avatarable, gravatar_url)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user