Only update avatars in one place
Some checks are pending
continuous-integration/drone/push Build is running

Prevent future mistakes
This commit is contained in:
Râu Cao 2025-05-17 17:55:14 +04:00
parent c3b845b18f
commit c2550bccec
Signed by: raucao
GPG Key ID: 37036C356E56CC51
3 changed files with 17 additions and 4 deletions

View File

@ -35,8 +35,7 @@ class SettingsController < ApplicationController
if @user.avatar_new.present? if @user.avatar_new.present?
if store_user_avatar if store_user_avatar
LdapManager::UpdateAvatar.call(user: @user) UserManager::UpdateAvatar.call(user: @user)
XmppSetAvatarJob.perform_later(user: @user) if Setting.ejabberd_enabled?
else else
@validation_errors = @user.errors @validation_errors = @user.errors
render :show, status: :unprocessable_entity and return render :show, status: :unprocessable_entity and return

View File

@ -7,8 +7,7 @@ module UserManager
def call def call
if import_remote_avatar if import_remote_avatar
LdapManager::UpdateAvatar.call(user: @user) UserManager::UpdateAvatar.call(user: @user)
XmppSetAvatarJob.perform_later(user: @user) if Setting.ejabberd_enabled?
end end
end end

View File

@ -0,0 +1,15 @@
module UserManager
class UpdateAvatar < UserManagerService
def initialize(user:)
@user = user
end
def call
LdapManager::UpdateAvatar.call(user: @user)
if Setting.ejabberd_enabled?
XmppSetAvatarJob.perform_later(user: @user)
end
end
end
end