Add a new service to import some data from Mastodon accounts: * Find users by username, store Mastodon account ID in local db when found * Import display name (don't overwrite existing) * Import avatar (don't overwrite existing)
22 lines
494 B
Ruby
22 lines
494 B
Ruby
module UserManager
|
|
class ProcessAvatar < UserManagerService
|
|
def initialize(io:)
|
|
@io = io
|
|
end
|
|
|
|
def call
|
|
processed = ImageProcessing::Vips
|
|
.source(@io)
|
|
.resize_to_fill(400, 400)
|
|
.saver(strip: true)
|
|
.call
|
|
@io.rewind
|
|
processed.read
|
|
rescue Vips::Error => e
|
|
Sentry.capture_exception(e) if Setting.sentry_enabled?
|
|
Rails.logger.warn { "Image processing failed for avatar: #{e.message}" }
|
|
nil
|
|
end
|
|
end
|
|
end
|