Corrected with rubocop cop 'Style/Next'.
This commit is contained in:
parent
7efe34e53b
commit
1ac1cf4184
20 changed files with 360 additions and 322 deletions
|
@ -218,8 +218,6 @@ Metrics/AbcSize:
|
||||||
|
|
||||||
Style/RedundantSelf:
|
Style/RedundantSelf:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/Next:
|
|
||||||
Enabled: false
|
|
||||||
Style/CommentIndentation:
|
Style/CommentIndentation:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
|
|
|
@ -233,7 +233,8 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
||||||
end
|
end
|
||||||
provider_map.each {|provider, settings|
|
provider_map.each {|provider, settings|
|
||||||
domains.each {|domain_to_check|
|
domains.each {|domain_to_check|
|
||||||
if domain_to_check =~ /#{settings[:domain]}/i
|
|
||||||
|
next if domain_to_check !~ /#{settings[:domain]}/i
|
||||||
|
|
||||||
# probe inbound
|
# probe inbound
|
||||||
result = email_probe_inbound( settings[:inbound] )
|
result = email_probe_inbound( settings[:inbound] )
|
||||||
|
@ -254,7 +255,6 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
||||||
setting: settings,
|
setting: settings,
|
||||||
}
|
}
|
||||||
return # rubocop:disable Lint/NonLocalExitFromIterator
|
return # rubocop:disable Lint/NonLocalExitFromIterator
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,11 +394,12 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
||||||
logger.info "INBOUND PROBE: #{config.inspect}"
|
logger.info "INBOUND PROBE: #{config.inspect}"
|
||||||
result = email_probe_inbound( config )
|
result = email_probe_inbound( config )
|
||||||
logger.info "INBOUND RESULT: #{result.inspect}"
|
logger.info "INBOUND RESULT: #{result.inspect}"
|
||||||
if result[:result] == 'ok'
|
|
||||||
|
next if result[:result] != 'ok'
|
||||||
|
|
||||||
success = true
|
success = true
|
||||||
settings[:inbound] = config
|
settings[:inbound] = config
|
||||||
break
|
break
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !success
|
if !success
|
||||||
|
@ -543,11 +544,12 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
||||||
logger.info "OUTBOUND PROBE: #{config.inspect}"
|
logger.info "OUTBOUND PROBE: #{config.inspect}"
|
||||||
result = email_probe_outbound( config, params[:email] )
|
result = email_probe_outbound( config, params[:email] )
|
||||||
logger.info "OUTBOUND RESULT: #{result.inspect}"
|
logger.info "OUTBOUND RESULT: #{result.inspect}"
|
||||||
if result[:result] == 'ok'
|
|
||||||
|
next if result[:result] != 'ok'
|
||||||
|
|
||||||
success = true
|
success = true
|
||||||
settings[:outbound] = config
|
settings[:outbound] = config
|
||||||
break
|
break
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !success
|
if !success
|
||||||
|
@ -635,7 +637,8 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
||||||
return # rubocop:disable Lint/NonLocalExitFromIterator
|
return # rubocop:disable Lint/NonLocalExitFromIterator
|
||||||
end
|
end
|
||||||
|
|
||||||
if found && found == 'verify ok'
|
next if !found
|
||||||
|
next if found != 'verify ok'
|
||||||
|
|
||||||
# remember address
|
# remember address
|
||||||
address = EmailAddress.where( email: params[:meta][:email] ).first
|
address = EmailAddress.where( email: params[:meta][:email] ).first
|
||||||
|
@ -694,7 +697,6 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
||||||
result: 'ok',
|
result: 'ok',
|
||||||
}
|
}
|
||||||
return # rubocop:disable Lint/NonLocalExitFromIterator
|
return # rubocop:disable Lint/NonLocalExitFromIterator
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# check delivery for 30 sek.
|
# check delivery for 30 sek.
|
||||||
|
@ -768,14 +770,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
||||||
'Recipient address rejected' => true,
|
'Recipient address rejected' => true,
|
||||||
}
|
}
|
||||||
white_map.each {|key, message|
|
white_map.each {|key, message|
|
||||||
if e.message =~ /#{Regexp.escape(key)}/i
|
|
||||||
|
next if e.message !~ /#{Regexp.escape(key)}/i
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
result: 'ok',
|
result: 'ok',
|
||||||
settings: params,
|
settings: params,
|
||||||
notice: e.message,
|
notice: e.message,
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
end
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
message_human = ''
|
message_human = ''
|
||||||
|
|
|
@ -107,7 +107,9 @@ returns
|
||||||
# set relations
|
# set relations
|
||||||
self.class.reflect_on_all_associations.map { |assoc|
|
self.class.reflect_on_all_associations.map { |assoc|
|
||||||
real_key = assoc.name.to_s[0, assoc.name.to_s.length - 1] + '_ids'
|
real_key = assoc.name.to_s[0, assoc.name.to_s.length - 1] + '_ids'
|
||||||
if params.key?( real_key.to_sym )
|
|
||||||
|
next if !params.key?( real_key.to_sym )
|
||||||
|
|
||||||
list_of_items = params[ real_key.to_sym ]
|
list_of_items = params[ real_key.to_sym ]
|
||||||
if params[ real_key.to_sym ].class != Array
|
if params[ real_key.to_sym ].class != Array
|
||||||
list_of_items = [ params[ real_key.to_sym ] ]
|
list_of_items = [ params[ real_key.to_sym ] ]
|
||||||
|
@ -117,7 +119,6 @@ returns
|
||||||
list.push( assoc.klass.find(item) )
|
list.push( assoc.klass.find(item) )
|
||||||
}
|
}
|
||||||
self.send( assoc.name.to_s + '=', list )
|
self.send( assoc.name.to_s + '=', list )
|
||||||
end
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -66,35 +66,37 @@ class Channel::EmailParser
|
||||||
|
|
||||||
# set all headers
|
# set all headers
|
||||||
mail.header.fields.each { |field|
|
mail.header.fields.each { |field|
|
||||||
if field.name
|
|
||||||
|
next if !field.name
|
||||||
|
|
||||||
# full line, encode, ready for storage
|
# full line, encode, ready for storage
|
||||||
data[field.name.to_s.downcase.to_sym] = Encode.conv( 'utf8', field.to_s )
|
data[field.name.to_s.downcase.to_sym] = Encode.conv( 'utf8', field.to_s )
|
||||||
|
|
||||||
# if we need to access the lines by objects later again
|
# if we need to access the lines by objects later again
|
||||||
data[ "raw-#{field.name.downcase}".to_sym ] = field
|
data[ "raw-#{field.name.downcase}".to_sym ] = field
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# get sender
|
# get sender
|
||||||
from = nil
|
from = nil
|
||||||
['from', 'reply-to', 'return-path'].each { |item|
|
['from', 'reply-to', 'return-path'].each { |item|
|
||||||
if !from
|
|
||||||
if mail[ item.to_sym ]
|
next if !mail[ item.to_sym ]
|
||||||
|
|
||||||
from = mail[ item.to_sym ].value
|
from = mail[ item.to_sym ].value
|
||||||
end
|
|
||||||
end
|
break if from
|
||||||
}
|
}
|
||||||
|
|
||||||
# set x-any-recipient
|
# set x-any-recipient
|
||||||
data['x-any-recipient'.to_sym] = ''
|
data['x-any-recipient'.to_sym] = ''
|
||||||
['to', 'cc', 'delivered-to', 'x-original-to', 'envelope-to'].each { |item|
|
['to', 'cc', 'delivered-to', 'x-original-to', 'envelope-to'].each { |item|
|
||||||
if mail[item.to_sym]
|
|
||||||
|
next if !mail[item.to_sym]
|
||||||
|
|
||||||
if data['x-any-recipient'.to_sym] != ''
|
if data['x-any-recipient'.to_sym] != ''
|
||||||
data['x-any-recipient'.to_sym] += ', '
|
data['x-any-recipient'.to_sym] += ', '
|
||||||
end
|
end
|
||||||
data['x-any-recipient'.to_sym] += mail[item.to_sym].to_s
|
data['x-any-recipient'.to_sym] += mail[item.to_sym].to_s
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# set extra headers
|
# set extra headers
|
||||||
|
@ -374,7 +376,10 @@ class Channel::EmailParser
|
||||||
|
|
||||||
# create to and cc user
|
# create to and cc user
|
||||||
['raw-to', 'raw-cc'].each { |item|
|
['raw-to', 'raw-cc'].each { |item|
|
||||||
if mail[item.to_sym] && mail[item.to_sym].tree
|
|
||||||
|
next if !mail[item.to_sym]
|
||||||
|
next if !mail[item.to_sym].tree
|
||||||
|
|
||||||
items = mail[item.to_sym].tree
|
items = mail[item.to_sym].tree
|
||||||
items.addresses.each {|item|
|
items.addresses.each {|item|
|
||||||
user_create(
|
user_create(
|
||||||
|
@ -383,7 +388,6 @@ class Channel::EmailParser
|
||||||
email: item.address,
|
email: item.address,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# set current user
|
# set current user
|
||||||
|
@ -541,7 +545,9 @@ class Channel::EmailParser
|
||||||
if mail[ header.to_sym ]
|
if mail[ header.to_sym ]
|
||||||
Rails.logger.info "header #{header} found #{mail[ header.to_sym ]}"
|
Rails.logger.info "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|
|
||||||
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 "ASSOC found #{assoc.class_name} lookup #{mail[ header.to_sym ]}"
|
||||||
item = assoc.class_name.constantize
|
item = assoc.class_name.constantize
|
||||||
|
|
||||||
|
@ -554,7 +560,6 @@ class Channel::EmailParser
|
||||||
item_object[key] = item.lookup( login: mail[ header.to_sym ] ).id
|
item_object[key] = item.lookup( login: mail[ header.to_sym ] ).id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,9 +10,9 @@ module Channel::Filter::Database
|
||||||
filters.each {|filter|
|
filters.each {|filter|
|
||||||
Rails.logger.info " proccess filter #{filter.name} ..."
|
Rails.logger.info " proccess filter #{filter.name} ..."
|
||||||
match = true
|
match = true
|
||||||
loop = false
|
looped = false
|
||||||
filter[:match].each {|key, value|
|
filter[:match].each {|key, value|
|
||||||
loop = true
|
looped = true
|
||||||
begin
|
begin
|
||||||
scan = []
|
scan = []
|
||||||
if mail
|
if mail
|
||||||
|
@ -31,12 +31,14 @@ module Channel::Filter::Database
|
||||||
Rails.logger.error e.inspect
|
Rails.logger.error e.inspect
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
if loop && match
|
|
||||||
|
next if !looped
|
||||||
|
next if !match
|
||||||
|
|
||||||
filter[:perform].each {|key, value|
|
filter[:perform].each {|key, value|
|
||||||
Rails.logger.info " perform '#{ key.downcase }' = '#{value}'"
|
Rails.logger.info " perform '#{ key.downcase }' = '#{value}'"
|
||||||
mail[ key.downcase.to_sym ] = value
|
mail[ key.downcase.to_sym ] = value
|
||||||
}
|
}
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,12 +37,14 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob
|
||||||
# add history record
|
# add history record
|
||||||
recipient_list = ''
|
recipient_list = ''
|
||||||
[:to, :cc].each { |key|
|
[:to, :cc].each { |key|
|
||||||
if record[key] && record[key] != ''
|
|
||||||
|
next if !record[key]
|
||||||
|
next if record[key] == ''
|
||||||
|
|
||||||
if recipient_list != ''
|
if recipient_list != ''
|
||||||
recipient_list += ','
|
recipient_list += ','
|
||||||
end
|
end
|
||||||
recipient_list += record[key]
|
recipient_list += record[key]
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return if recipient_list == ''
|
return if recipient_list == ''
|
||||||
|
|
|
@ -313,7 +313,9 @@ class Package < ApplicationModel
|
||||||
def self.reload_classes
|
def self.reload_classes
|
||||||
%w(app lib).each {|dir|
|
%w(app lib).each {|dir|
|
||||||
Dir.glob( Rails.root.join( dir + '/**/*') ).each {|entry|
|
Dir.glob( Rails.root.join( dir + '/**/*') ).each {|entry|
|
||||||
if entry =~ /\.rb$/
|
|
||||||
|
next if entry !~ /\.rb$/
|
||||||
|
|
||||||
begin
|
begin
|
||||||
load entry
|
load entry
|
||||||
rescue => e
|
rescue => e
|
||||||
|
@ -321,7 +323,6 @@ class Package < ApplicationModel
|
||||||
logger.error 'ERROR: ' + e.inspect
|
logger.error 'ERROR: ' + e.inspect
|
||||||
logger.error 'Traceback: ' + e.backtrace.inspect
|
logger.error 'Traceback: ' + e.backtrace.inspect
|
||||||
end
|
end
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -396,11 +397,11 @@ class Package < ApplicationModel
|
||||||
(1..position).each {|count|
|
(1..position).each {|count|
|
||||||
tmp_path = tmp_path + '/' + directories[count].to_s
|
tmp_path = tmp_path + '/' + directories[count].to_s
|
||||||
}
|
}
|
||||||
if tmp_path != ''
|
|
||||||
if !File.exist?(tmp_path)
|
next if tmp_path == ''
|
||||||
|
next if File.exist?(tmp_path)
|
||||||
|
|
||||||
Dir.mkdir(tmp_path, 0755)
|
Dir.mkdir(tmp_path, 0755)
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# install file
|
# install file
|
||||||
|
|
|
@ -46,13 +46,14 @@ class Store
|
||||||
content = item.content
|
content = item.content
|
||||||
sha = Digest::SHA256.hexdigest( content )
|
sha = Digest::SHA256.hexdigest( content )
|
||||||
logger.info "CHECK: Store::File.find(#{item.id}) "
|
logger.info "CHECK: Store::File.find(#{item.id}) "
|
||||||
if sha != item.sha
|
|
||||||
|
next if sha == item.sha
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
logger.error "DIFF: sha diff of Store::File.find(#{item.id}) "
|
logger.error "DIFF: sha diff of Store::File.find(#{item.id}) "
|
||||||
if fix_it
|
if fix_it
|
||||||
item.update_attribute( :sha, sha )
|
item.update_attribute( :sha, sha )
|
||||||
end
|
end
|
||||||
end
|
|
||||||
}
|
}
|
||||||
success
|
success
|
||||||
end
|
end
|
||||||
|
|
|
@ -189,7 +189,9 @@ returns
|
||||||
[ 'tickets.group_id', 'group_id' ]
|
[ 'tickets.group_id', 'group_id' ]
|
||||||
]
|
]
|
||||||
map.each {|item|
|
map.each {|item|
|
||||||
if sla.condition[ item[0] ]
|
|
||||||
|
next if !sla.condition[ item[0] ]
|
||||||
|
|
||||||
if sla.condition[ item[0] ].class == String
|
if sla.condition[ item[0] ].class == String
|
||||||
sla.condition[ item[0] ] = [ sla.condition[ item[0] ] ]
|
sla.condition[ item[0] ] = [ sla.condition[ item[0] ] ]
|
||||||
end
|
end
|
||||||
|
@ -198,7 +200,6 @@ returns
|
||||||
else
|
else
|
||||||
hit = false
|
hit = false
|
||||||
end
|
end
|
||||||
end
|
|
||||||
}
|
}
|
||||||
if hit
|
if hit
|
||||||
sla_selected = sla
|
sla_selected = sla
|
||||||
|
|
|
@ -73,12 +73,17 @@ returns
|
||||||
|
|
||||||
# replace e.g. 'current_user.id' with current_user.id
|
# replace e.g. 'current_user.id' with current_user.id
|
||||||
overview.condition.each { |item, value|
|
overview.condition.each { |item, value|
|
||||||
if value && value.class.to_s == 'String'
|
|
||||||
|
next if !value
|
||||||
|
next if value.class.to_s != 'String'
|
||||||
|
|
||||||
parts = value.split( '.', 2 )
|
parts = value.split( '.', 2 )
|
||||||
if parts[0] && parts[1] && parts[0] == 'current_user'
|
|
||||||
|
next if !parts[0]
|
||||||
|
next if !parts[1]
|
||||||
|
next if parts[0] != 'current_user'
|
||||||
|
|
||||||
overview.condition[item] = data[:current_user][parts[1].to_sym]
|
overview.condition[item] = data[:current_user][parts[1].to_sym]
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,12 +64,13 @@ returns
|
||||||
end
|
end
|
||||||
state_types.each {|type|
|
state_types.each {|type|
|
||||||
state_type = Ticket::StateType.where( name: type ).first
|
state_type = Ticket::StateType.where( name: type ).first
|
||||||
if state_type
|
|
||||||
|
next if !state_type
|
||||||
|
|
||||||
state_type.states.each {|state|
|
state_type.states.each {|state|
|
||||||
assets = state.assets(assets)
|
assets = state.assets(assets)
|
||||||
state_ids.push state.id
|
state_ids.push state.id
|
||||||
}
|
}
|
||||||
end
|
|
||||||
}
|
}
|
||||||
filter[:state_id] = state_ids
|
filter[:state_id] = state_ids
|
||||||
|
|
||||||
|
|
|
@ -83,21 +83,22 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
# check file size
|
# check file size
|
||||||
if attachment.content && attachment.content.size / 1024 <= attachment_max_size_in_mb * 1024
|
next if !attachment.content
|
||||||
|
next if attachment.content.size / 1024 > attachment_max_size_in_mb * 1024
|
||||||
|
|
||||||
# check ignored files
|
# check ignored files
|
||||||
if attachment.filename
|
next if !attachment.filename
|
||||||
|
|
||||||
filename_extention = attachment.filename.downcase
|
filename_extention = attachment.filename.downcase
|
||||||
filename_extention.gsub!(/^.*(\..+?)$/, '\\1')
|
filename_extention.gsub!(/^.*(\..+?)$/, '\\1')
|
||||||
if !attachments_ignore.include?( filename_extention.downcase )
|
|
||||||
|
next if attachments_ignore.include?( filename_extention.downcase )
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'_name' => attachment.filename,
|
'_name' => attachment.filename,
|
||||||
'_content' => Base64.encode64( attachment.content )
|
'_content' => Base64.encode64( attachment.content )
|
||||||
}
|
}
|
||||||
article_attributes['attachments'].push data
|
article_attributes['attachments'].push data
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
attributes['articles'].push article_attributes
|
attributes['articles'].push article_attributes
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@ returns
|
||||||
|
|
||||||
user_auth = backend.check( username, password, config_item, user )
|
user_auth = backend.check( username, password, config_item, user )
|
||||||
|
|
||||||
# auth ok
|
# auth not ok
|
||||||
if user_auth
|
next if !user_auth
|
||||||
|
|
||||||
Rails.logger.info "Authentication against #{config_item[:adapter]} for user #{user_auth.login} ok."
|
Rails.logger.info "Authentication against #{config_item[:adapter]} for user #{user_auth.login} ok."
|
||||||
|
|
||||||
|
@ -54,7 +54,6 @@ returns
|
||||||
user_auth.update_last_login
|
user_auth.update_last_login
|
||||||
|
|
||||||
return user_auth
|
return user_auth
|
||||||
end
|
|
||||||
}
|
}
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -522,7 +522,10 @@ module Import::OTRS
|
||||||
created_by_id: history['CreateBy']
|
created_by_id: history['CreateBy']
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
if history['ArticleID'] && history['ArticleID'] != 0
|
|
||||||
|
next if !history['ArticleID']
|
||||||
|
next if history['ArticleID'] == 0
|
||||||
|
|
||||||
History.add(
|
History.add(
|
||||||
id: history['HistoryID'],
|
id: history['HistoryID'],
|
||||||
o_id: history['ArticleID'],
|
o_id: history['ArticleID'],
|
||||||
|
@ -533,7 +536,6 @@ module Import::OTRS
|
||||||
created_at: history['CreateTime'],
|
created_at: history['CreateTime'],
|
||||||
created_by_id: history['CreateBy']
|
created_by_id: history['CreateBy']
|
||||||
)
|
)
|
||||||
end
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
@ -747,7 +747,10 @@ module Import::OTRS2
|
||||||
created_by_id: history['CreateBy']
|
created_by_id: history['CreateBy']
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
if history['ArticleID'] && history['ArticleID'] != 0
|
|
||||||
|
next if !history['ArticleID']
|
||||||
|
next if history['ArticleID'] == 0
|
||||||
|
|
||||||
History.add(
|
History.add(
|
||||||
id: history['HistoryID'],
|
id: history['HistoryID'],
|
||||||
o_id: history['ArticleID'],
|
o_id: history['ArticleID'],
|
||||||
|
@ -758,7 +761,6 @@ module Import::OTRS2
|
||||||
created_at: history['CreateTime'],
|
created_at: history['CreateTime'],
|
||||||
created_by_id: history['CreateBy']
|
created_by_id: history['CreateBy']
|
||||||
)
|
)
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -974,11 +976,12 @@ module Import::OTRS2
|
||||||
# lookup by groups
|
# lookup by groups
|
||||||
user['GroupIDs'].each {|group_id, permissions|
|
user['GroupIDs'].each {|group_id, permissions|
|
||||||
queues.each {|queue_lookup|
|
queues.each {|queue_lookup|
|
||||||
if queue_lookup['GroupID'] == group_id
|
|
||||||
if permissions && permissions.include?('rw')
|
next if queue_lookup['GroupID'] != group_id
|
||||||
|
next if !permissions
|
||||||
|
next if !permissions.include?('rw')
|
||||||
|
|
||||||
queue_ids.push queue_lookup['QueueID']
|
queue_ids.push queue_lookup['QueueID']
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -996,14 +999,18 @@ module Import::OTRS2
|
||||||
role_ids = []
|
role_ids = []
|
||||||
user['GroupIDs'].each {|group_id, permissions|
|
user['GroupIDs'].each {|group_id, permissions|
|
||||||
groups.each {|group_lookup|
|
groups.each {|group_lookup|
|
||||||
if group_id == group_lookup['ID']
|
|
||||||
if group_lookup['Name'] == 'admin' && permissions && permissions.include?('rw')
|
next if group_id != group_lookup['ID']
|
||||||
|
next if permissions
|
||||||
|
|
||||||
|
if group_lookup['Name'] == 'admin' && permissions.include?('rw')
|
||||||
roles.push 'Admin'
|
roles.push 'Admin'
|
||||||
end
|
end
|
||||||
if group_lookup['Name'] =~ /^(stats|report)/ && permissions && ( permissions.include?('ro') || permissions.include?('rw') )
|
|
||||||
|
next if group_lookup['Name'] !~ /^(stats|report)/
|
||||||
|
next if !( permissions.include?('ro') || permissions.include?('rw') )
|
||||||
|
|
||||||
roles.push 'Report'
|
roles.push 'Report'
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
roles.each {|role|
|
roles.each {|role|
|
||||||
|
|
|
@ -63,11 +63,12 @@ module NotificationFactory
|
||||||
object_refs = object_refs.send( method.to_sym )
|
object_refs = object_refs.send( method.to_sym )
|
||||||
|
|
||||||
# add body quote
|
# add body quote
|
||||||
if object_name == 'article' && method == 'body'
|
next if object_name != 'article'
|
||||||
if data[:objects][:article].content_type == 'text/html'
|
next if method != 'body'
|
||||||
|
|
||||||
|
next if data[:objects][:article].content_type != 'text/html'
|
||||||
|
|
||||||
object_refs = object_refs.html2text.chomp
|
object_refs = object_refs.html2text.chomp
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
if !value
|
if !value
|
||||||
placeholder = object_refs
|
placeholder = object_refs
|
||||||
|
|
|
@ -470,14 +470,16 @@ returns
|
||||||
|
|
||||||
# spool to recipient list
|
# spool to recipient list
|
||||||
if message_parsed['recipient'] && message_parsed['recipient']['user_id']
|
if message_parsed['recipient'] && message_parsed['recipient']['user_id']
|
||||||
|
|
||||||
message_parsed['recipient']['user_id'].each { |user_id|
|
message_parsed['recipient']['user_id'].each { |user_id|
|
||||||
if current_user_id == user_id
|
|
||||||
|
next if current_user_id != user_id
|
||||||
|
|
||||||
item = {
|
item = {
|
||||||
type: 'direct',
|
type: 'direct',
|
||||||
message: message_parsed,
|
message: message_parsed,
|
||||||
}
|
}
|
||||||
data.push item
|
data.push item
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# spool to every client
|
# spool to every client
|
||||||
|
@ -521,7 +523,8 @@ returns
|
||||||
next if !user
|
next if !user
|
||||||
|
|
||||||
# start client thread
|
# start client thread
|
||||||
if !@@client_threads[client_id]
|
next if @@client_threads[client_id]
|
||||||
|
|
||||||
@@client_threads[client_id] = true
|
@@client_threads[client_id] = true
|
||||||
@@client_threads[client_id] = Thread.new {
|
@@client_threads[client_id] = Thread.new {
|
||||||
thread_client(client_id)
|
thread_client(client_id)
|
||||||
|
@ -530,7 +533,6 @@ returns
|
||||||
ActiveRecord::Base.connection.close
|
ActiveRecord::Base.connection.close
|
||||||
}
|
}
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# system settings
|
# system settings
|
||||||
|
|
|
@ -56,8 +56,8 @@ returns
|
||||||
|
|
||||||
user_auth = backend.check( params, config_item )
|
user_auth = backend.check( params, config_item )
|
||||||
|
|
||||||
# auth ok
|
# auth not ok
|
||||||
if user_auth
|
next if !user_auth
|
||||||
|
|
||||||
Rails.logger.info "Authentication against #{config_item[:adapter]} for user #{user.login} ok."
|
Rails.logger.info "Authentication against #{config_item[:adapter]} for user #{user.login} ok."
|
||||||
|
|
||||||
|
@ -65,7 +65,6 @@ returns
|
||||||
user_auth.update_last_login
|
user_auth.update_last_login
|
||||||
|
|
||||||
return user_auth
|
return user_auth
|
||||||
end
|
|
||||||
}
|
}
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,7 +35,12 @@ put working hours matrix and timezone in function, returns UTC working hours mat
|
||||||
working_hours = {}
|
working_hours = {}
|
||||||
[:Mon, :Tue, :Wed, :Thu, :Fri, :Sat, :Sun].each {|day|
|
[:Mon, :Tue, :Wed, :Thu, :Fri, :Sat, :Sun].each {|day|
|
||||||
working_hours[day] = []
|
working_hours[day] = []
|
||||||
if config[day.to_s] == true || config[day.to_s] == day.to_s
|
|
||||||
|
next if !config[day.to_s]
|
||||||
|
if config[day.to_s] != true && config[day.to_s] != day.to_s
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
config_ok = true
|
config_ok = true
|
||||||
(0..23).each {|hour|
|
(0..23).each {|hour|
|
||||||
time = Time.parse("1977-10-27 #{hour}:00:00")
|
time = Time.parse("1977-10-27 #{hour}:00:00")
|
||||||
|
@ -45,7 +50,6 @@ put working hours matrix and timezone in function, returns UTC working hours mat
|
||||||
working_hours[day].push nil
|
working_hours[day].push nil
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !config_ok
|
if !config_ok
|
||||||
|
@ -67,7 +71,9 @@ put working hours matrix and timezone in function, returns UTC working hours mat
|
||||||
}
|
}
|
||||||
(1..hours_to_shift).each {|count|
|
(1..hours_to_shift).each {|count|
|
||||||
working_hours.each {|day, value|
|
working_hours.each {|day, value|
|
||||||
if working_hours[day]
|
|
||||||
|
next if !working_hours[day]
|
||||||
|
|
||||||
to_move = working_hours[day].shift
|
to_move = working_hours[day].shift
|
||||||
if day == :Mon
|
if day == :Mon
|
||||||
move_items[:Tue].push to_move
|
move_items[:Tue].push to_move
|
||||||
|
@ -84,7 +90,6 @@ put working hours matrix and timezone in function, returns UTC working hours mat
|
||||||
elsif day == :Sun
|
elsif day == :Sun
|
||||||
move_items[:Mon].push to_move
|
move_items[:Mon].push to_move
|
||||||
end
|
end
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
move_items.each {|day, value|
|
move_items.each {|day, value|
|
||||||
|
|
|
@ -198,14 +198,15 @@ EventMachine.run {
|
||||||
log 'error', "recipient.user_id attribute isn't an array '#{ data['recipient']['user_id'].inspect }'"
|
log 'error', "recipient.user_id attribute isn't an array '#{ data['recipient']['user_id'].inspect }'"
|
||||||
else
|
else
|
||||||
data['recipient']['user_id'].each { |user_id|
|
data['recipient']['user_id'].each { |user_id|
|
||||||
if local_client[:user]['id'].to_i == user_id.to_i
|
|
||||||
|
next if local_client[:user]['id'].to_i != user_id.to_i
|
||||||
|
|
||||||
log 'notice', "send broadcast from (#{client_id}) to (user_id=#{user_id})", local_client_id
|
log 'notice', "send broadcast from (#{client_id}) to (user_id=#{user_id})", local_client_id
|
||||||
if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ]
|
if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ]
|
||||||
@clients[ local_client_id ][:websocket].send( "[#{msg}]" )
|
@clients[ local_client_id ][:websocket].send( "[#{msg}]" )
|
||||||
else
|
else
|
||||||
Sessions.send( local_client_id, data )
|
Sessions.send( local_client_id, data )
|
||||||
end
|
end
|
||||||
end
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -296,7 +297,9 @@ EventMachine.run {
|
||||||
|
|
||||||
# close unused web socket sessions
|
# close unused web socket sessions
|
||||||
@clients.each { |client_id, client|
|
@clients.each { |client_id, client|
|
||||||
if ( client[:last_ping] + idle_time_in_sec ) < Time.now
|
|
||||||
|
next if ( client[:last_ping] + idle_time_in_sec ) >= Time.now
|
||||||
|
|
||||||
log 'notice', 'closing idle websocket connection', client_id
|
log 'notice', 'closing idle websocket connection', client_id
|
||||||
|
|
||||||
# remember to not use this connection anymore
|
# remember to not use this connection anymore
|
||||||
|
@ -308,7 +311,6 @@ EventMachine.run {
|
||||||
# delete session from client list
|
# delete session from client list
|
||||||
sleep 0.3
|
sleep 0.3
|
||||||
@clients.delete(client_id)
|
@clients.delete(client_id)
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# close unused ajax long polling sessions
|
# close unused ajax long polling sessions
|
||||||
|
|
Loading…
Reference in a new issue