akkounts/app/services/ldap_manager/fetch_avatar.rb
Râu Cao 179a82d2dd
Use keyword arguments for ApplicationService calls
Not all services are using keywords, which breaks those calls in Ruby 3
2024-02-02 15:50:25 +02:00

17 lines
418 B
Ruby

module LdapManager
class FetchAvatar < LdapManagerService
def initialize(cn:)
@cn = cn
end
def call
treebase = ldap_config["base"]
attributes = %w{ jpegPhoto }
filter = Net::LDAP::Filter.eq("cn", @cn)
entry = ldap_client.search(base: treebase, filter: filter, attributes: attributes).first
entry.try(:jpegPhoto) ? entry.jpegPhoto.first : nil
end
end
end