Queue XmppSetAvatarJob when new avatar is uploaded
And let job do nothing in development for now
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user