Sync Mastodon IDs/profiles to local accounts
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)
This commit is contained in:
@@ -193,7 +193,11 @@ class SettingsController < ApplicationController
|
||||
|
||||
def store_user_avatar
|
||||
io = @user.avatar_new.tempfile
|
||||
img_data = process_avatar(io)
|
||||
img_data = UserManager::ProcessAvatar.call(io: io)
|
||||
if img_data.blank?
|
||||
@user.errors.add(:avatar, "failed to process file")
|
||||
false
|
||||
end
|
||||
tempfile = Tempfile.create
|
||||
tempfile.binmode
|
||||
tempfile.write(img_data)
|
||||
@@ -212,18 +216,4 @@ class SettingsController < ApplicationController
|
||||
@user.save
|
||||
end
|
||||
end
|
||||
|
||||
def process_avatar(io)
|
||||
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.error { "Image processing failed for avatar: #{e.message}" }
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user