Small code layout improvements.
This commit is contained in:
parent
1f83f3b358
commit
b76be9eebc
5 changed files with 20 additions and 22 deletions
|
@ -22,7 +22,7 @@ class CtiController < ApplicationController
|
||||||
def done
|
def done
|
||||||
log = Cti::Log.find(params['id'])
|
log = Cti::Log.find(params['id'])
|
||||||
log.done = params['done']
|
log.done = params['done']
|
||||||
log.save
|
log.save!
|
||||||
render json: {}
|
render json: {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ add avatar by url
|
||||||
data[:full][:mime_type] = mime_type
|
data[:full][:mime_type] = mime_type
|
||||||
|
|
||||||
# try zammad backend to find image based on email
|
# try zammad backend to find image based on email
|
||||||
elsif data[:url] && data[:url] =~ /@/
|
elsif data[:url].present? && data[:url] =~ /@/
|
||||||
|
|
||||||
# check if source ist already updated within last 3 minutes
|
# check if source ist already updated within last 3 minutes
|
||||||
if avatar_already_exists && avatar_already_exists.source_url == data[:url]
|
if avatar_already_exists && avatar_already_exists.source_url == data[:url]
|
||||||
|
|
|
@ -693,7 +693,7 @@ returns
|
||||||
|
|
||||||
def set_attributes_by_x_headers(item_object, header_name, mail, suffix = false)
|
def set_attributes_by_x_headers(item_object, header_name, mail, suffix = false)
|
||||||
|
|
||||||
# loop all x-zammad-hedaer-* headers
|
# loop all x-zammad-header-* headers
|
||||||
item_object.attributes.each { |key, _value|
|
item_object.attributes.each { |key, _value|
|
||||||
|
|
||||||
# ignore read only attributes
|
# ignore read only attributes
|
||||||
|
@ -711,37 +711,33 @@ returns
|
||||||
|
|
||||||
# only set value on _id if value/reference lookup exists
|
# only set value on _id if value/reference lookup exists
|
||||||
if mail[ header.to_sym ]
|
if mail[ header.to_sym ]
|
||||||
Rails.logger.info "header #{header} found #{mail[header.to_sym]}"
|
Rails.logger.info "set_attributes_by_x_headers header #{header} found #{mail[header.to_sym]}"
|
||||||
item_object.class.reflect_on_all_associations.map { |assoc|
|
item_object.class.reflect_on_all_associations.map { |assoc|
|
||||||
|
|
||||||
next if assoc.name.to_s != key_short
|
next if assoc.name.to_s != key_short
|
||||||
|
|
||||||
Rails.logger.info "ASSOC found #{assoc.class_name} lookup #{mail[header.to_sym]}"
|
Rails.logger.info "set_attributes_by_x_headers found #{assoc.class_name} lookup for '#{mail[header.to_sym]}'"
|
||||||
item = assoc.class_name.constantize
|
item = assoc.class_name.constantize
|
||||||
|
|
||||||
assoc_object = nil
|
assoc_object = nil
|
||||||
assoc_has_object = false
|
|
||||||
if item.respond_to?(:name)
|
if item.respond_to?(:name)
|
||||||
assoc_has_object = true
|
assoc_object = item.lookup(name: mail[header.to_sym])
|
||||||
if item.lookup(name: mail[header.to_sym])
|
end
|
||||||
assoc_object = item.lookup(name: mail[header.to_sym])
|
if !assoc_object && item.respond_to?(:login)
|
||||||
end
|
assoc_object = item.lookup(login: mail[header.to_sym])
|
||||||
elsif item.respond_to?(:login)
|
|
||||||
assoc_has_object = true
|
|
||||||
if item.lookup(login: mail[header.to_sym])
|
|
||||||
assoc_object = item.lookup(login: mail[header.to_sym])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
next if assoc_has_object == false
|
if assoc_object.blank?
|
||||||
|
|
||||||
if assoc_object
|
# no assoc exists, remove header
|
||||||
item_object[key] = assoc_object.id
|
mail.delete(header.to_sym)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
# no assoc exists, remove header
|
Rails.logger.info "set_attributes_by_x_headers assign #{item_object.class} #{key}=#{assoc_object.id}"
|
||||||
mail.delete(header.to_sym)
|
|
||||||
|
item_object[key] = assoc_object.id
|
||||||
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -752,7 +748,7 @@ returns
|
||||||
header = "x-zammad-#{header_name}-#{suffix}-#{key}"
|
header = "x-zammad-#{header_name}-#{suffix}-#{key}"
|
||||||
end
|
end
|
||||||
if mail[header.to_sym]
|
if mail[header.to_sym]
|
||||||
Rails.logger.info "header #{header} found #{mail[header.to_sym]}"
|
Rails.logger.info "set_attributes_by_x_headers header #{header} found. Assign #{key}=#{mail[header.to_sym]}"
|
||||||
item_object[key] = mail[header.to_sym]
|
item_object[key] = mail[header.to_sym]
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,8 @@ module Channel::Filter::Database
|
||||||
match_rule = $2
|
match_rule = $2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
value ||= ''
|
||||||
|
|
||||||
if regexp == false
|
if regexp == false
|
||||||
match_rule_quoted = Regexp.quote(match_rule).gsub(/\\\*/, '.*')
|
match_rule_quoted = Regexp.quote(match_rule).gsub(/\\\*/, '.*')
|
||||||
return true if value =~ /#{match_rule_quoted}/i
|
return true if value =~ /#{match_rule_quoted}/i
|
||||||
|
|
|
@ -124,7 +124,7 @@ returns
|
||||||
UserInfo.current_user_id = admin_user.id
|
UserInfo.current_user_id = admin_user.id
|
||||||
|
|
||||||
# fetch org logo
|
# fetch org logo
|
||||||
if admin_user.email
|
if admin_user.email.present?
|
||||||
Service::Image.organization_suggest(admin_user.email)
|
Service::Image.organization_suggest(admin_user.email)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue