image.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Service
  3. class Image
  4. include ApplicationLib
  5. =begin
  6. lookup user image based on email address
  7. file = Service::Image.user('skywalker@zammad.org')
  8. returns
  9. {
  10. content: content,
  11. mime_type: mime_type,
  12. }
  13. =end
  14. def self.user(address)
  15. # load backend
  16. backend = load_adapter_by_setting('image_backend')
  17. return if !backend
  18. backend.user(address)
  19. end
  20. =begin
  21. lookup organization image based on domain
  22. file = Service::Image.organization('edenhofer.de')
  23. file = Service::Image.organization('user@edenhofer.de') # will just use domain
  24. returns
  25. {
  26. content: content,
  27. mime_type: mime_type,
  28. }
  29. =end
  30. def self.organization(domain)
  31. # load backend
  32. backend = load_adapter_by_setting('image_backend')
  33. return if !backend
  34. backend.organization(domain)
  35. end
  36. =begin
  37. find organization image suggestion and store it as app logo
  38. result = Service::Image.organization_suggest('edenhofer.de')
  39. returns
  40. true # or false
  41. =end
  42. def self.organization_suggest(domain)
  43. # load backend
  44. backend = load_adapter_by_setting('image_backend')
  45. return if !backend
  46. backend.organization_suggest(domain)
  47. end
  48. end
  49. end