Queue XmppSetAvatarJob when new avatar is uploaded
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Failing after 10m9s

And let job do nothing in development for now
This commit is contained in:
2025-05-15 22:04:25 +04:00
parent 5916969447
commit 5f276ff349
3 changed files with 19 additions and 7 deletions

View File

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

View File

@@ -5,11 +5,12 @@ class XmppSetAvatarJob < ApplicationJob
queue_as :default
def perform(user:, overwrite: false)
return if Rails.env.development?
@user = user
unless overwrite
current_avatar = get_current_avatar
Rails.logger.debug { "User #{user.cn} already has an avatar set. Nothing to do." }
Rails.logger.info { "User #{user.cn} already has an avatar set" }
return if current_avatar.present?
end
@@ -56,6 +57,7 @@ class XmppSetAvatarJob < ApplicationJob
end
end
# See https://xmpp.org/extensions/xep-0084.html
def build_xep0084_stanzas
img_data = process_avatar
sha1_hash = Digest::SHA1.hexdigest(img_data)