avatar_create_job.rb 595 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class AvatarCreateJob < ApplicationJob
  3. include HasActiveJobLock
  4. low_priority
  5. retry_on StandardError, attempts: 20, wait: lambda { |executions|
  6. executions * 10.seconds
  7. }
  8. def lock_key
  9. # "AvatarCreateJob/User/12"
  10. "#{self.class.name}/User/#{arguments[0].id}"
  11. end
  12. def perform(user)
  13. avatar = Avatar.auto_detection(
  14. object: 'User',
  15. o_id: user.id,
  16. url: user.email
  17. )
  18. # update user link
  19. return if !avatar
  20. user.update! image: avatar.store_hash
  21. end
  22. end