akkounts/app/services/ldap_manager/fetch_avatar.rb
Râu Cao 9e2210c45b
All checks were successful
continuous-integration/drone/push Build is passing
Store avatars as binary instead of base64
2025-05-10 20:58:36 +04:00

17 lines
402 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 = client.search(base: treebase, filter: filter, attributes: attributes).first
entry&.jpegPhoto ? entry.jpegPhoto.first : nil
end
end
end