Class: Panda::Core::AttachAvatarService
- Inherits:
-
Services::BaseService
- Object
- Services::BaseService
- Panda::Core::AttachAvatarService
- Defined in:
- app/services/panda/core/attach_avatar_service.rb
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
Returns a new instance of AttachAvatarService.
8 9 10 11 |
# File 'app/services/panda/core/attach_avatar_service.rb', line 8 def initialize(user:, avatar_url:) @user = user @avatar_url = avatar_url end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/panda/core/attach_avatar_service.rb', line 13 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.}") failure(["Failed to attach avatar: #{e.}"]) end end |