akkounts/app/services/ldap_manager/update_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

28 lines
513 B
Ruby

require "image_processing/vips"
module LdapManager
class UpdateAvatar < LdapManagerService
def initialize(dn:, file:)
@dn = dn
@img_data = process(file)
end
def call
result = replace_attribute @dn, :jpegPhoto, @img_data
result
end
private
def process(file)
processed = ImageProcessing::Vips
.resize_to_fill(256, 256)
.source(file)
.convert("jpeg")
.saver(strip: true)
.call
processed.read
end
end
end