2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2015-07-15 19:45:40 +00:00
|
|
|
|
|
|
|
module Service
|
|
|
|
class Image
|
|
|
|
include ApplicationLib
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
lookup user image based on email address
|
|
|
|
|
2016-01-14 09:39:52 +00:00
|
|
|
file = Service::Image.user('skywalker@zammad.org')
|
2015-07-15 19:45:40 +00:00
|
|
|
|
|
|
|
returns
|
|
|
|
|
|
|
|
{
|
|
|
|
content: content,
|
|
|
|
mime_type: mime_type,
|
|
|
|
}
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def self.user(address)
|
|
|
|
|
|
|
|
# load backend
|
2016-01-14 09:39:52 +00:00
|
|
|
backend = load_adapter_by_setting('image_backend')
|
2015-07-15 19:45:40 +00:00
|
|
|
return if !backend
|
|
|
|
|
|
|
|
backend.user(address)
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
lookup organization image based on domain
|
|
|
|
|
|
|
|
file = Service::Image.organization('edenhofer.de')
|
|
|
|
|
|
|
|
file = Service::Image.organization('user@edenhofer.de') # will just use domain
|
|
|
|
|
|
|
|
returns
|
|
|
|
|
|
|
|
{
|
|
|
|
content: content,
|
|
|
|
mime_type: mime_type,
|
|
|
|
}
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def self.organization(domain)
|
|
|
|
|
|
|
|
# load backend
|
2016-01-14 09:39:52 +00:00
|
|
|
backend = load_adapter_by_setting('image_backend')
|
2015-07-15 19:45:40 +00:00
|
|
|
return if !backend
|
|
|
|
|
|
|
|
backend.organization(domain)
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
2015-08-03 09:30:45 +00:00
|
|
|
find organization image suggestion and store it as app logo
|
2015-07-15 19:45:40 +00:00
|
|
|
|
|
|
|
result = Service::Image.organization_suggest('edenhofer.de')
|
|
|
|
|
|
|
|
returns
|
|
|
|
|
|
|
|
true # or false
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def self.organization_suggest(domain)
|
|
|
|
|
|
|
|
# load backend
|
2016-01-14 09:39:52 +00:00
|
|
|
backend = load_adapter_by_setting('image_backend')
|
2015-07-15 19:45:40 +00:00
|
|
|
return if !backend
|
|
|
|
|
2015-08-03 09:30:45 +00:00
|
|
|
result = backend.organization_suggest(domain)
|
|
|
|
|
|
|
|
# sync logo to assets folder
|
|
|
|
if result
|
|
|
|
StaticAssets.sync
|
|
|
|
end
|
|
|
|
|
|
|
|
result
|
2015-07-15 19:45:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|