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