Class: Panda::Core::AttachAvatarService
- Inherits:
-
Services::BaseService
- Object
- Services::BaseService
- Panda::Core::AttachAvatarService
- Defined in:
- app/services/panda/core/attach_avatar_service.rb
Constant Summary collapse
- MAX_FILE_SIZE =
5.megabytes
- MAX_DIMENSION =
Max width/height for optimization
800
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(user:, avatar_url:) ⇒ AttachAvatarService
constructor
A new instance of AttachAvatarService.
Methods inherited from Services::BaseService
Constructor Details
#initialize(user:, avatar_url:) ⇒ AttachAvatarService
11 12 13 14 |
# File 'app/services/panda/core/attach_avatar_service.rb', line 11 def initialize(user:, avatar_url:) @user = user @avatar_url = avatar_url end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/services/panda/core/attach_avatar_service.rb', line 16 def call return success if @avatar_url.blank? return success if @avatar_url == @user.oauth_avatar_url && @user.avatar.attached? begin download_and_attach_avatar @user.update_column(:oauth_avatar_url, @avatar_url) success(avatar_attached: true) rescue => e Rails.logger.error("Failed to attach avatar for user #{@user.id}: #{e.message}") failure(["Failed to attach avatar: #{e.message}"]) end end |