Merge branch 'develop' of github.com:martini/zammad into develop
This commit is contained in:
commit
3eaac7009a
88 changed files with 633 additions and 611 deletions
35
.rubocop.yml
35
.rubocop.yml
|
@ -173,43 +173,10 @@ Style/Documentation:
|
||||||
Description: 'Document classes and non-namespace modules.'
|
Description: 'Document classes and non-namespace modules.'
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Style/EmptyLineBetweenDefs:
|
|
||||||
Description: 'Use empty lines between defs.'
|
|
||||||
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#empty-lines-between-methods'
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/ActionFilter:
|
Rails/ActionFilter:
|
||||||
Description: 'Enforces consistent use of action filter methods.'
|
Description: 'Enforces consistent use of action filter methods.'
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Rails/FindBy:
|
|
||||||
Description: 'Prefer find_by over where.first.'
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/NilComparison:
|
|
||||||
Description: 'Prefer x.nil? to x == nil.'
|
|
||||||
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/SymbolProc:
|
|
||||||
Description: 'Use symbols as procs instead of blocks when possible.'
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/RedundantBegin:
|
|
||||||
Description: "Don't use begin blocks when they are not needed."
|
|
||||||
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#begin-implicit'
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Lint/UnusedBlockArgument:
|
|
||||||
Description: 'Checks for unused block arguments.'
|
|
||||||
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars'
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Lint/UnusedMethodArgument:
|
|
||||||
Description: 'Checks for unused method arguments.'
|
|
||||||
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars'
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/SignalException:
|
Style/SignalException:
|
||||||
Description: 'Checks for proper usage of fail and raise.'
|
Description: 'Checks for proper usage of fail and raise.'
|
||||||
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
|
||||||
|
@ -223,8 +190,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:
|
||||||
|
|
|
@ -64,6 +64,7 @@ class ApplicationController < ActionController::Base
|
||||||
return if !session[:user_id]
|
return if !session[:user_id]
|
||||||
@_current_user = User.find( session[:user_id] )
|
@_current_user = User.find( session[:user_id] )
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_user_set(user)
|
def current_user_set(user)
|
||||||
session[:user_id] = user.id
|
session[:user_id] = user.id
|
||||||
@_current_user = user
|
@_current_user = user
|
||||||
|
@ -282,7 +283,6 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
# model helper
|
# model helper
|
||||||
def model_create_render (object, params)
|
def model_create_render (object, params)
|
||||||
begin
|
|
||||||
|
|
||||||
# create object
|
# create object
|
||||||
generic_object = object.new( object.param_cleanup( params[object.to_app_model_url], true ) )
|
generic_object = object.new( object.param_cleanup( params[object.to_app_model_url], true ) )
|
||||||
|
@ -299,13 +299,12 @@ class ApplicationController < ActionController::Base
|
||||||
logger.error e.backtrace.inspect
|
logger.error e.backtrace.inspect
|
||||||
render json: { error: e.message }, status: :unprocessable_entity
|
render json: { error: e.message }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
|
||||||
def model_create_render_item (generic_object)
|
def model_create_render_item (generic_object)
|
||||||
render json: generic_object.attributes_with_associations, status: :created
|
render json: generic_object.attributes_with_associations, status: :created
|
||||||
end
|
end
|
||||||
|
|
||||||
def model_update_render (object, params)
|
def model_update_render (object, params)
|
||||||
begin
|
|
||||||
|
|
||||||
# find object
|
# find object
|
||||||
generic_object = object.find( params[:id] )
|
generic_object = object.find( params[:id] )
|
||||||
|
@ -322,13 +321,12 @@ class ApplicationController < ActionController::Base
|
||||||
logger.error e.backtrace.inspect
|
logger.error e.backtrace.inspect
|
||||||
render json: { error: e.message }, status: :unprocessable_entity
|
render json: { error: e.message }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
|
||||||
def model_update_render_item (generic_object)
|
def model_update_render_item (generic_object)
|
||||||
render json: generic_object.attributes_with_associations, status: :ok
|
render json: generic_object.attributes_with_associations, status: :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
def model_destory_render (object, params)
|
def model_destory_render (object, params)
|
||||||
begin
|
|
||||||
generic_object = object.find( params[:id] )
|
generic_object = object.find( params[:id] )
|
||||||
generic_object.destroy
|
generic_object.destroy
|
||||||
model_destory_render_item()
|
model_destory_render_item()
|
||||||
|
@ -337,13 +335,12 @@ class ApplicationController < ActionController::Base
|
||||||
logger.error e.backtrace.inspect
|
logger.error e.backtrace.inspect
|
||||||
render json: { error: e.message }, status: :unprocessable_entity
|
render json: { error: e.message }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
|
||||||
def model_destory_render_item ()
|
def model_destory_render_item ()
|
||||||
render json: {}, status: :ok
|
render json: {}, status: :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
def model_show_render (object, params)
|
def model_show_render (object, params)
|
||||||
begin
|
|
||||||
|
|
||||||
if params[:full]
|
if params[:full]
|
||||||
generic_object_full = object.full( params[:id] )
|
generic_object_full = object.full( params[:id] )
|
||||||
|
@ -358,13 +355,12 @@ class ApplicationController < ActionController::Base
|
||||||
logger.error e.backtrace.inspect
|
logger.error e.backtrace.inspect
|
||||||
render json: { error: e.message }, status: :unprocessable_entity
|
render json: { error: e.message }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
|
||||||
def model_show_render_item (generic_object)
|
def model_show_render_item (generic_object)
|
||||||
render json: generic_object.attributes_with_associations, status: :ok
|
render json: generic_object.attributes_with_associations, status: :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
def model_index_render (object, params)
|
def model_index_render (object, _params)
|
||||||
begin
|
|
||||||
generic_objects = object.all
|
generic_objects = object.all
|
||||||
model_index_render_result( generic_objects )
|
model_index_render_result( generic_objects )
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
@ -372,7 +368,7 @@ class ApplicationController < ActionController::Base
|
||||||
logger.error e.backtrace.inspect
|
logger.error e.backtrace.inspect
|
||||||
render json: { error: e.message }, status: :unprocessable_entity
|
render json: { error: e.message }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
|
||||||
def model_index_render_result (generic_objects)
|
def model_index_render_result (generic_objects)
|
||||||
render json: generic_objects, status: :ok
|
render json: generic_objects, status: :ok
|
||||||
end
|
end
|
||||||
|
|
|
@ -231,9 +231,10 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
||||||
if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
|
if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
|
||||||
domains.push mail_exchangers[0][0]
|
domains.push mail_exchangers[0][0]
|
||||||
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
|
||||||
|
@ -614,7 +616,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
||||||
end
|
end
|
||||||
result = email_probe_outbound( params[:outbound], params[:meta][:email], subject )
|
result = email_probe_outbound( params[:outbound], params[:meta][:email], subject )
|
||||||
|
|
||||||
(1..5).each {|loop|
|
(1..5).each {
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
# fetch mailbox
|
# fetch mailbox
|
||||||
|
@ -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.
|
||||||
|
@ -767,15 +769,16 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
||||||
white_map = {
|
white_map = {
|
||||||
'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 = ''
|
||||||
|
|
|
@ -112,7 +112,7 @@ class LongPollingController < ApplicationController
|
||||||
begin
|
begin
|
||||||
|
|
||||||
# update last ping
|
# update last ping
|
||||||
4.times {|loop|
|
4.times {
|
||||||
sleep 0.25
|
sleep 0.25
|
||||||
}
|
}
|
||||||
#sleep 1
|
#sleep 1
|
||||||
|
@ -128,7 +128,7 @@ class LongPollingController < ApplicationController
|
||||||
render json: queue
|
render json: queue
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
8.times {|loop|
|
8.times {
|
||||||
sleep 0.25
|
sleep 0.25
|
||||||
}
|
}
|
||||||
#sleep 2
|
#sleep 2
|
||||||
|
|
|
@ -20,7 +20,7 @@ curl http://localhost/api/v1/rss_fetch.json -v -u #{login}:#{password} -H "Conte
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
items = Rss.fetch(params[:url], params[:limit])
|
items = Rss.fetch(params[:url], params[:limit])
|
||||||
if items == nil
|
if items.nil?
|
||||||
render json: { message: "failed to fetch #{ params[:url] }", status: :unprocessable_entity }
|
render json: { message: "failed to fetch #{ params[:url] }", status: :unprocessable_entity }
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module ExtraCollection
|
module ExtraCollection
|
||||||
def session( collections, assets, user )
|
def session( collections, assets, _user )
|
||||||
|
|
||||||
collections[ Network.to_app_model ] = Network.all
|
collections[ Network.to_app_model ] = Network.all
|
||||||
collections[ Network::Category.to_app_model ] = Network::Category.all
|
collections[ Network::Category.to_app_model ] = Network::Category.all
|
||||||
|
|
|
@ -69,7 +69,7 @@ returns
|
||||||
|
|
||||||
def self.param_cleanup(params, newObject = false)
|
def self.param_cleanup(params, newObject = false)
|
||||||
|
|
||||||
if params == nil
|
if params.nil?
|
||||||
raise "No params for #{self}!"
|
raise "No params for #{self}!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -311,7 +312,7 @@ returns
|
||||||
cache = self.cache_get( data[:id] )
|
cache = self.cache_get( data[:id] )
|
||||||
return cache if cache
|
return cache if cache
|
||||||
|
|
||||||
record = self.where( id: data[:id] ).first
|
record = self.find_by( id: data[:id] )
|
||||||
self.cache_set( data[:id], record )
|
self.cache_set( data[:id], record )
|
||||||
return record
|
return record
|
||||||
elsif data[:name]
|
elsif data[:name]
|
||||||
|
@ -357,7 +358,7 @@ returns
|
||||||
|
|
||||||
def self.create_if_not_exists(data)
|
def self.create_if_not_exists(data)
|
||||||
if data[:id]
|
if data[:id]
|
||||||
record = self.where( id: data[:id] ).first
|
record = self.find_by( id: data[:id] )
|
||||||
return record if record
|
return record if record
|
||||||
elsif data[:name]
|
elsif data[:name]
|
||||||
records = self.where( name: data[:name] )
|
records = self.where( name: data[:name] )
|
||||||
|
@ -458,6 +459,7 @@ end
|
||||||
def latest_change_set_from_observer
|
def latest_change_set_from_observer
|
||||||
self.class.latest_change_set(self.updated_at)
|
self.class.latest_change_set(self.updated_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def latest_change_set_from_observer_destroy
|
def latest_change_set_from_observer_destroy
|
||||||
self.class.latest_change_set(nil)
|
self.class.latest_change_set(nil)
|
||||||
end
|
end
|
||||||
|
@ -466,7 +468,7 @@ end
|
||||||
key = "#{self.new.class.name}_latest_change"
|
key = "#{self.new.class.name}_latest_change"
|
||||||
expires_in = 31_536_000 # 1 year
|
expires_in = 31_536_000 # 1 year
|
||||||
|
|
||||||
if updated_at == nil
|
if updated_at.nil?
|
||||||
Cache.delete( key )
|
Cache.delete( key )
|
||||||
else
|
else
|
||||||
Cache.write( key, updated_at, { expires_in: expires_in } )
|
Cache.write( key, updated_at, { expires_in: expires_in } )
|
||||||
|
@ -760,7 +762,7 @@ log object update activity stream, if configured - will be executed automaticall
|
||||||
end
|
end
|
||||||
|
|
||||||
log = false
|
log = false
|
||||||
self.changes.each {|key, value|
|
self.changes.each {|key, _value|
|
||||||
|
|
||||||
# do not log created_at and updated_at attributes
|
# do not log created_at and updated_at attributes
|
||||||
next if ignore_attributes[key.to_sym] == true
|
next if ignore_attributes[key.to_sym] == true
|
||||||
|
@ -1029,6 +1031,7 @@ get assets of object list
|
||||||
def attachments_buffer
|
def attachments_buffer
|
||||||
@attachments_buffer_data
|
@attachments_buffer_data
|
||||||
end
|
end
|
||||||
|
|
||||||
def attachments_buffer=(attachments)
|
def attachments_buffer=(attachments)
|
||||||
@attachments_buffer_data = attachments
|
@attachments_buffer_data = attachments
|
||||||
end
|
end
|
||||||
|
@ -1036,7 +1039,7 @@ get assets of object list
|
||||||
def attachments_buffer_check
|
def attachments_buffer_check
|
||||||
|
|
||||||
# do nothing if no attachment exists
|
# do nothing if no attachment exists
|
||||||
return 1 if attachments_buffer == nil
|
return 1 if attachments_buffer.nil?
|
||||||
|
|
||||||
# store attachments
|
# store attachments
|
||||||
article_store = []
|
article_store = []
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Authorization < ApplicationModel
|
||||||
validates :provider, presence: true
|
validates :provider, presence: true
|
||||||
|
|
||||||
def self.find_from_hash(hash)
|
def self.find_from_hash(hash)
|
||||||
auth = Authorization.where( provider: hash['provider'], uid: hash['uid'] ).first
|
auth = Authorization.find_by( provider: hash['provider'], uid: hash['uid'] )
|
||||||
if auth
|
if auth
|
||||||
|
|
||||||
# update auth tokens
|
# update auth tokens
|
||||||
|
|
|
@ -89,11 +89,11 @@ add a avatar
|
||||||
# check if avatar with url already exists
|
# check if avatar with url already exists
|
||||||
avatar_already_exists = nil
|
avatar_already_exists = nil
|
||||||
if data[:source] && !data[:source].empty?
|
if data[:source] && !data[:source].empty?
|
||||||
avatar_already_exists = Avatar.where(
|
avatar_already_exists = Avatar.find_by(
|
||||||
object_lookup_id: object_id,
|
object_lookup_id: object_id,
|
||||||
o_id: data[:o_id],
|
o_id: data[:o_id],
|
||||||
source: data[:source],
|
source: data[:source],
|
||||||
).first
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# fetch image
|
# fetch image
|
||||||
|
@ -208,11 +208,11 @@ set avatars as default
|
||||||
|
|
||||||
def self.set_default( object_name, o_id, avatar_id )
|
def self.set_default( object_name, o_id, avatar_id )
|
||||||
object_id = ObjectLookup.by_name( object_name )
|
object_id = ObjectLookup.by_name( object_name )
|
||||||
avatar = Avatar.where(
|
avatar = Avatar.find_by(
|
||||||
object_lookup_id: object_id,
|
object_lookup_id: object_id,
|
||||||
o_id: o_id,
|
o_id: o_id,
|
||||||
id: avatar_id,
|
id: avatar_id,
|
||||||
).first
|
)
|
||||||
avatar.default = true
|
avatar.default = true
|
||||||
avatar.save!
|
avatar.save!
|
||||||
|
|
||||||
|
@ -308,9 +308,9 @@ returns:
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.get_by_hash(hash)
|
def self.get_by_hash(hash)
|
||||||
avatar = Avatar.where(
|
avatar = Avatar.find_by(
|
||||||
store_hash: hash,
|
store_hash: hash,
|
||||||
).first
|
)
|
||||||
return if !avatar
|
return if !avatar
|
||||||
file = Store.find(avatar.store_resize_id)
|
file = Store.find(avatar.store_resize_id)
|
||||||
end
|
end
|
||||||
|
@ -329,11 +329,11 @@ returns:
|
||||||
|
|
||||||
def self.get_default(object_name, o_id)
|
def self.get_default(object_name, o_id)
|
||||||
object_id = ObjectLookup.by_name( object_name )
|
object_id = ObjectLookup.by_name( object_name )
|
||||||
Avatar.where(
|
Avatar.find_by(
|
||||||
object_lookup_id: object_id,
|
object_lookup_id: object_id,
|
||||||
o_id: o_id,
|
o_id: o_id,
|
||||||
default: true,
|
default: true,
|
||||||
).first
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.set_default_items(object_id, o_id, avatar_id)
|
def self.set_default_items(object_id, o_id, avatar_id)
|
||||||
|
|
|
@ -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
|
||||||
|
@ -333,7 +335,7 @@ class Channel::EmailParser
|
||||||
}
|
}
|
||||||
|
|
||||||
# filter( channel, mail )
|
# filter( channel, mail )
|
||||||
filters.each {|prio, backend|
|
filters.each {|_prio, backend|
|
||||||
begin
|
begin
|
||||||
backend.run( channel, mail )
|
backend.run( channel, mail )
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
@ -358,10 +360,10 @@ class Channel::EmailParser
|
||||||
|
|
||||||
# create sender
|
# create sender
|
||||||
if mail[ 'x-zammad-customer-login'.to_sym ]
|
if mail[ 'x-zammad-customer-login'.to_sym ]
|
||||||
user = User.where( login: mail[ 'x-zammad-customer-login'.to_sym ] ).first
|
user = User.find_by( login: mail[ 'x-zammad-customer-login'.to_sym ] )
|
||||||
end
|
end
|
||||||
if !user
|
if !user
|
||||||
user = User.where( email: mail[ 'x-zammad-customer-email'.to_sym ] || mail[:from_email] ).first
|
user = User.find_by( email: mail[ 'x-zammad-customer-email'.to_sym ] || mail[:from_email] )
|
||||||
end
|
end
|
||||||
if !user
|
if !user
|
||||||
user = user_create(
|
user = user_create(
|
||||||
|
@ -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
|
||||||
|
@ -403,7 +407,7 @@ class Channel::EmailParser
|
||||||
end
|
end
|
||||||
|
|
||||||
if state_type.name != 'new'
|
if state_type.name != 'new'
|
||||||
ticket.state = Ticket::State.where( name: 'open' ).first
|
ticket.state = Ticket::State.find_by( name: 'open' )
|
||||||
ticket.save
|
ticket.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -416,8 +420,8 @@ class Channel::EmailParser
|
||||||
group_id: channel[:group_id] || 1,
|
group_id: channel[:group_id] || 1,
|
||||||
customer_id: user.id,
|
customer_id: user.id,
|
||||||
title: mail[:subject] || '',
|
title: mail[:subject] || '',
|
||||||
state_id: Ticket::State.where( name: 'new' ).first.id,
|
state_id: Ticket::State.find_by( name: 'new' ).id,
|
||||||
priority_id: Ticket::Priority.where( name: '2 normal' ).first.id,
|
priority_id: Ticket::Priority.find_by( name: '2 normal' ).id,
|
||||||
)
|
)
|
||||||
|
|
||||||
set_attributes_by_x_headers( ticket, 'ticket', mail )
|
set_attributes_by_x_headers( ticket, 'ticket', mail )
|
||||||
|
@ -431,8 +435,8 @@ class Channel::EmailParser
|
||||||
# set attributes
|
# set attributes
|
||||||
article = Ticket::Article.new(
|
article = Ticket::Article.new(
|
||||||
ticket_id: ticket.id,
|
ticket_id: ticket.id,
|
||||||
type_id: Ticket::Article::Type.where( name: 'email' ).first.id,
|
type_id: Ticket::Article::Type.find_by( name: 'email' ).id,
|
||||||
sender_id: Ticket::Article::Sender.where( name: 'Customer' ).first.id,
|
sender_id: Ticket::Article::Sender.find_by( name: 'Customer' ).id,
|
||||||
body: mail[:body],
|
body: mail[:body],
|
||||||
from: mail[:from],
|
from: mail[:from],
|
||||||
to: mail[:to],
|
to: mail[:to],
|
||||||
|
@ -480,7 +484,7 @@ class Channel::EmailParser
|
||||||
}
|
}
|
||||||
|
|
||||||
# filter( channel, mail )
|
# filter( channel, mail )
|
||||||
filters.each {|prio, backend|
|
filters.each {|_prio, backend|
|
||||||
begin
|
begin
|
||||||
backend.run( channel, mail, ticket, article, user )
|
backend.run( channel, mail, ticket, article, user )
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
@ -496,7 +500,7 @@ class Channel::EmailParser
|
||||||
def user_create(data)
|
def user_create(data)
|
||||||
|
|
||||||
# return existing
|
# return existing
|
||||||
user = User.where( login: data[:email].downcase ).first
|
user = User.find_by( login: data[:email].downcase )
|
||||||
return user if user
|
return user if user
|
||||||
|
|
||||||
# create new user
|
# create new user
|
||||||
|
@ -504,7 +508,7 @@ class Channel::EmailParser
|
||||||
|
|
||||||
# fillup
|
# fillup
|
||||||
%w(firstname lastname).each { |item|
|
%w(firstname lastname).each { |item|
|
||||||
if data[item.to_sym] == nil
|
if data[item.to_sym].nil?
|
||||||
data[item.to_sym] = ''
|
data[item.to_sym] = ''
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -525,7 +529,7 @@ class Channel::EmailParser
|
||||||
def set_attributes_by_x_headers( item_object, header_name, mail )
|
def set_attributes_by_x_headers( item_object, header_name, mail )
|
||||||
|
|
||||||
# loop all x-zammad-hedaer-* headers
|
# loop all x-zammad-hedaer-* headers
|
||||||
item_object.attributes.each {|key, value|
|
item_object.attributes.each {|key, _value|
|
||||||
|
|
||||||
# ignore read only attributes
|
# ignore read only attributes
|
||||||
next if key == 'updated_at'
|
next if key == 'updated_at'
|
||||||
|
@ -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
|
||||||
|
|
|
@ -4,7 +4,7 @@ require 'net/imap'
|
||||||
|
|
||||||
module Channel::EmailSend
|
module Channel::EmailSend
|
||||||
def self.send(attr, notification = false)
|
def self.send(attr, notification = false)
|
||||||
channel = Channel.where( area: 'Email::Outbound', active: true ).first
|
channel = Channel.find_by( area: 'Email::Outbound', active: true )
|
||||||
begin
|
begin
|
||||||
c = eval 'Channel::' + channel[:adapter] + '.new'
|
c = eval 'Channel::' + channel[:adapter] + '.new'
|
||||||
c.send(attr, channel, notification)
|
c.send(attr, channel, notification)
|
||||||
|
|
|
@ -3,16 +3,16 @@
|
||||||
# process all database filter
|
# process all database filter
|
||||||
module Channel::Filter::Database
|
module Channel::Filter::Database
|
||||||
|
|
||||||
def self.run( channel, mail )
|
def self.run( _channel, mail )
|
||||||
|
|
||||||
# process postmaster filter
|
# process postmaster filter
|
||||||
filters = PostmasterFilter.where( active: true, channel: 'email' )
|
filters = PostmasterFilter.where( active: true, channel: 'email' )
|
||||||
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
|
||||||
|
|
|
@ -7,10 +7,11 @@ module Channel::Filter::Trusted
|
||||||
|
|
||||||
# check if trust x-headers
|
# check if trust x-headers
|
||||||
if !channel[:trusted]
|
if !channel[:trusted]
|
||||||
mail.each {|key, value|
|
mail.each {|key, _value|
|
||||||
if key =~ /^x-zammad/i
|
|
||||||
|
next if key !~ /^x-zammad/i
|
||||||
|
|
||||||
mail.delete(key)
|
mail.delete(key)
|
||||||
end
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Channel::Sendmail
|
class Channel::Sendmail
|
||||||
def send(attr, channel, notification = false)
|
def send(attr, _channel, notification = false)
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Channel::TWITTER2
|
||||||
all_tweets.each do |tweet|
|
all_tweets.each do |tweet|
|
||||||
|
|
||||||
# check if tweet is already imported
|
# check if tweet is already imported
|
||||||
article = Ticket::Article.where( message_id: tweet.id.to_s ).first
|
article = Ticket::Article.find_by( message_id: tweet.id.to_s )
|
||||||
|
|
||||||
# check if sender already exists
|
# check if sender already exists
|
||||||
next if article
|
next if article
|
||||||
|
@ -137,15 +137,15 @@ class Channel::TWITTER2
|
||||||
[user, ticket, article]
|
[user, ticket, article]
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_user_create(tweet, sender)
|
def fetch_user_create(_tweet, sender)
|
||||||
# create sender in db
|
# create sender in db
|
||||||
# puts tweet.inspect
|
# puts tweet.inspect
|
||||||
# user = User.where( :login => tweet.sender.screen_name ).first
|
# user = User.where( :login => tweet.sender.screen_name ).first
|
||||||
auth = Authorization.where( uid: sender.id, provider: 'twitter' ).first
|
auth = Authorization.find_by( uid: sender.id, provider: 'twitter' )
|
||||||
user = nil
|
user = nil
|
||||||
if auth
|
if auth
|
||||||
Rails.logger.info 'user_id', auth.user_id
|
Rails.logger.info 'user_id', auth.user_id
|
||||||
user = User.where( id: auth.user_id ).first
|
user = User.find_by( id: auth.user_id )
|
||||||
end
|
end
|
||||||
if !user
|
if !user
|
||||||
Rails.logger.info 'create user...'
|
Rails.logger.info 'create user...'
|
||||||
|
@ -180,13 +180,13 @@ class Channel::TWITTER2
|
||||||
user
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_ticket_create(user, tweet, sender, channel, group)
|
def fetch_ticket_create(user, tweet, _sender, _channel, group)
|
||||||
|
|
||||||
#Rails.logger.info '+++++++++++++++++++++++++++' + tweet.inspect
|
#Rails.logger.info '+++++++++++++++++++++++++++' + tweet.inspect
|
||||||
# check if ticket exists
|
# check if ticket exists
|
||||||
if tweet.respond_to?('in_reply_to_status_id') && tweet.in_reply_to_status_id && tweet.in_reply_to_status_id.to_s != ''
|
if tweet.respond_to?('in_reply_to_status_id') && tweet.in_reply_to_status_id && tweet.in_reply_to_status_id.to_s != ''
|
||||||
Rails.logger.info 'tweet.in_reply_to_status_id found: ' + tweet.in_reply_to_status_id.to_s
|
Rails.logger.info 'tweet.in_reply_to_status_id found: ' + tweet.in_reply_to_status_id.to_s
|
||||||
article = Ticket::Article.where( message_id: tweet.in_reply_to_status_id.to_s ).first
|
article = Ticket::Article.find_by( message_id: tweet.in_reply_to_status_id.to_s )
|
||||||
if article
|
if article
|
||||||
Rails.logger.info 'article with id found tweet.in_reply_to_status_id found: ' + tweet.in_reply_to_status_id.to_s
|
Rails.logger.info 'article with id found tweet.in_reply_to_status_id found: ' + tweet.in_reply_to_status_id.to_s
|
||||||
return article.ticket
|
return article.ticket
|
||||||
|
@ -194,14 +194,14 @@ class Channel::TWITTER2
|
||||||
end
|
end
|
||||||
|
|
||||||
# find if record already exists
|
# find if record already exists
|
||||||
article = Ticket::Article.where( message_id: tweet.id.to_s ).first
|
article = Ticket::Article.find_by( message_id: tweet.id.to_s )
|
||||||
if article
|
if article
|
||||||
return article.ticket
|
return article.ticket
|
||||||
end
|
end
|
||||||
|
|
||||||
ticket = nil
|
ticket = nil
|
||||||
if @article_type == 'twitter direct-message'
|
if @article_type == 'twitter direct-message'
|
||||||
ticket = Ticket.where( customer_id: user.id ).first
|
ticket = Ticket.find_by( customer_id: user.id )
|
||||||
if ticket
|
if ticket
|
||||||
state_type = Ticket::StateType.where( ticket.state.state_type_id )
|
state_type = Ticket::StateType.where( ticket.state.state_type_id )
|
||||||
if state_type.name == 'closed' || state_type.name == 'closed'
|
if state_type.name == 'closed' || state_type.name == 'closed'
|
||||||
|
@ -210,17 +210,17 @@ class Channel::TWITTER2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if !ticket
|
if !ticket
|
||||||
group = Group.where( name: group ).first
|
group = Group.find_by( name: group )
|
||||||
group_id = 1
|
group_id = 1
|
||||||
if group
|
if group
|
||||||
group_id = group.id
|
group_id = group.id
|
||||||
end
|
end
|
||||||
state = Ticket::State.where( name: 'new' ).first
|
state = Ticket::State.find_by( name: 'new' )
|
||||||
state_id = 1
|
state_id = 1
|
||||||
if state
|
if state
|
||||||
state_id = state.id
|
state_id = state.id
|
||||||
end
|
end
|
||||||
priority = Ticket::Priority.where( name: '2 normal' ).first
|
priority = Ticket::Priority.find_by( name: '2 normal' )
|
||||||
priority_id = 1
|
priority_id = 1
|
||||||
if priority
|
if priority
|
||||||
priority_id = priority.id
|
priority_id = priority.id
|
||||||
|
@ -237,15 +237,15 @@ class Channel::TWITTER2
|
||||||
ticket
|
ticket
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_article_create( user, ticket, tweet, sender )
|
def fetch_article_create( _user, ticket, tweet, sender )
|
||||||
|
|
||||||
# find if record already exists
|
# find if record already exists
|
||||||
article = Ticket::Article.where( message_id: tweet.id.to_s ).first
|
article = Ticket::Article.find_by( message_id: tweet.id.to_s )
|
||||||
return article if article
|
return article if article
|
||||||
|
|
||||||
# set ticket state to open if not new
|
# set ticket state to open if not new
|
||||||
if ticket.state.name != 'new'
|
if ticket.state.name != 'new'
|
||||||
ticket.state = Ticket::State.where( name: 'open' ).first
|
ticket.state = Ticket::State.find_by( name: 'open' )
|
||||||
ticket.save
|
ticket.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -257,8 +257,8 @@ class Channel::TWITTER2
|
||||||
|
|
||||||
article = Ticket::Article.create(
|
article = Ticket::Article.create(
|
||||||
ticket_id: ticket.id,
|
ticket_id: ticket.id,
|
||||||
type_id: Ticket::Article::Type.where( name: @article_type ).first.id,
|
type_id: Ticket::Article::Type.find_by( name: @article_type ).id,
|
||||||
sender_id: Ticket::Article::Sender.where( name: 'Customer' ).first.id,
|
sender_id: Ticket::Article::Sender.find_by( name: 'Customer' ).id,
|
||||||
body: tweet.text,
|
body: tweet.text,
|
||||||
from: sender.name,
|
from: sender.name,
|
||||||
to: to,
|
to: to,
|
||||||
|
@ -268,9 +268,9 @@ class Channel::TWITTER2
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def send(attr, notification = false)
|
def send(attr, _notification = false)
|
||||||
# Rails.logger.debug('tweeeeettttt!!!!!!')
|
# Rails.logger.debug('tweeeeettttt!!!!!!')
|
||||||
channel = Channel.where( area: 'Twitter::Inbound', active: true ).first
|
channel = Channel.find_by( area: 'Twitter::Inbound', active: true )
|
||||||
|
|
||||||
client = Twitter::REST::Client.new do |config|
|
client = Twitter::REST::Client.new do |config|
|
||||||
config.consumer_key = channel[:options][:consumer_key]
|
config.consumer_key = channel[:options][:consumer_key]
|
||||||
|
|
|
@ -76,7 +76,7 @@ add a new history entry for an object
|
||||||
}
|
}
|
||||||
history_record = nil
|
history_record = nil
|
||||||
if data[:id]
|
if data[:id]
|
||||||
history_record = History.where( id: data[:id] ).first
|
history_record = History.find_by( id: data[:id] )
|
||||||
end
|
end
|
||||||
if history_record
|
if history_record
|
||||||
history_record.update_attributes(record)
|
history_record.update_attributes(record)
|
||||||
|
@ -98,7 +98,7 @@ remove whole history entries of an object
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.remove( requested_object, requested_object_id )
|
def self.remove( requested_object, requested_object_id )
|
||||||
history_object = History::Object.where( name: requested_object ).first
|
history_object = History::Object.find_by( name: requested_object )
|
||||||
return if !history_object
|
return if !history_object
|
||||||
History.where(
|
History.where(
|
||||||
history_object_id: history_object.id,
|
history_object_id: history_object.id,
|
||||||
|
@ -185,11 +185,11 @@ returns
|
||||||
data.delete('history_attribute_id')
|
data.delete('history_attribute_id')
|
||||||
|
|
||||||
data.delete( 'updated_at' )
|
data.delete( 'updated_at' )
|
||||||
if data['id_to'] == nil && data['id_from'] == nil
|
if data['id_to'].nil? && data['id_from'].nil?
|
||||||
data.delete( 'id_to' )
|
data.delete( 'id_to' )
|
||||||
data.delete( 'id_from' )
|
data.delete( 'id_from' )
|
||||||
end
|
end
|
||||||
if data['value_to'] == nil && data['value_from'] == nil
|
if data['value_to'].nil? && data['value_from'].nil?
|
||||||
data.delete( 'value_to' )
|
data.delete( 'value_to' )
|
||||||
data.delete( 'value_from' )
|
data.delete( 'value_from' )
|
||||||
end
|
end
|
||||||
|
@ -198,7 +198,7 @@ returns
|
||||||
end
|
end
|
||||||
data.delete( 'related_history_object_id' )
|
data.delete( 'related_history_object_id' )
|
||||||
|
|
||||||
if data['related_o_id'] == nil
|
if data['related_o_id'].nil?
|
||||||
data.delete( 'related_o_id' )
|
data.delete( 'related_o_id' )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -130,9 +130,7 @@ class Link < ApplicationModel
|
||||||
link_object_target_id: data[:link_object_target_id],
|
link_object_target_id: data[:link_object_target_id],
|
||||||
link_object_target_value: data[:link_object_target_value]
|
link_object_target_value: data[:link_object_target_value]
|
||||||
)
|
)
|
||||||
links.each { |link|
|
links.each(&:destroy)
|
||||||
link.destroy
|
|
||||||
}
|
|
||||||
|
|
||||||
# from the other site
|
# from the other site
|
||||||
if data.key?(:link_type)
|
if data.key?(:link_type)
|
||||||
|
@ -146,13 +144,11 @@ class Link < ApplicationModel
|
||||||
link_object_source_id: data[:link_object_target_id],
|
link_object_source_id: data[:link_object_target_id],
|
||||||
link_object_source_value: data[:link_object_target_value]
|
link_object_source_value: data[:link_object_target_value]
|
||||||
)
|
)
|
||||||
links.each { |link|
|
links.each(&:destroy)
|
||||||
link.destroy
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.link_type_get(data)
|
def self.link_type_get(data)
|
||||||
linktype = Link::Type.where( name: data[:name] ).first
|
linktype = Link::Type.find_by( name: data[:name] )
|
||||||
if !linktype
|
if !linktype
|
||||||
linktype = Link::Type.create(
|
linktype = Link::Type.create(
|
||||||
name: data[:name]
|
name: data[:name]
|
||||||
|
@ -162,7 +158,7 @@ class Link < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.link_object_get(data)
|
def self.link_object_get(data)
|
||||||
linkobject = Link::Object.where( name: data[:name] ).first
|
linkobject = Link::Object.find_by( name: data[:name] )
|
||||||
if !linkobject
|
if !linkobject
|
||||||
linkobject = Link::Object.create(
|
linkobject = Link::Object.create(
|
||||||
name: data[:name]
|
name: data[:name]
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Locale < ApplicationModel
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
result.data.each {|locale|
|
result.data.each {|locale|
|
||||||
exists = Locale.where(locale: locale['locale']).first
|
exists = Locale.find_by(locale: locale['locale'])
|
||||||
if exists
|
if exists
|
||||||
exists.update(locale.symbolize_keys!)
|
exists.update(locale.symbolize_keys!)
|
||||||
else
|
else
|
||||||
|
|
|
@ -112,10 +112,10 @@ add a new attribute entry for an object
|
||||||
data.delete(:object)
|
data.delete(:object)
|
||||||
|
|
||||||
# check newest entry - is needed
|
# check newest entry - is needed
|
||||||
result = ObjectManager::Attribute.where(
|
result = ObjectManager::Attribute.find_by(
|
||||||
object_lookup_id: data[:object_lookup_id],
|
object_lookup_id: data[:object_lookup_id],
|
||||||
name: data[:name],
|
name: data[:name],
|
||||||
).first
|
)
|
||||||
if result
|
if result
|
||||||
# raise "ERROR: attribute #{data[:name]} for #{data[:object]} already exists"
|
# raise "ERROR: attribute #{data[:name]} for #{data[:object]} already exists"
|
||||||
return result.update_attributes(data)
|
return result.update_attributes(data)
|
||||||
|
@ -143,10 +143,10 @@ get the attribute model based on object and name
|
||||||
data[:object_lookup_id] = ObjectLookup.by_name( data[:object] )
|
data[:object_lookup_id] = ObjectLookup.by_name( data[:object] )
|
||||||
end
|
end
|
||||||
|
|
||||||
ObjectManager::Attribute.where(
|
ObjectManager::Attribute.find_by(
|
||||||
object_lookup_id: data[:object_lookup_id],
|
object_lookup_id: data[:object_lookup_id],
|
||||||
name: data[:name],
|
name: data[:name],
|
||||||
).first
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
|
@ -6,9 +6,11 @@ class Observer::Organization::RefObjectTouch < ActiveRecord::Observer
|
||||||
def after_create(record)
|
def after_create(record)
|
||||||
ref_object_touch(record)
|
ref_object_touch(record)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_update(record)
|
def after_update(record)
|
||||||
ref_object_touch(record)
|
ref_object_touch(record)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy(record)
|
def after_destroy(record)
|
||||||
ref_object_touch(record)
|
ref_object_touch(record)
|
||||||
end
|
end
|
||||||
|
@ -19,9 +21,7 @@ class Observer::Organization::RefObjectTouch < ActiveRecord::Observer
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
|
|
||||||
# touch organizations tickets
|
# touch organizations tickets
|
||||||
Ticket.select('id').where( organization_id: record.id ).each {|ticket|
|
Ticket.select('id').where( organization_id: record.id ).each(&:touch)
|
||||||
ticket.touch
|
|
||||||
}
|
|
||||||
|
|
||||||
# touch current members
|
# touch current members
|
||||||
record.member_ids.uniq.each {|user_id|
|
record.member_ids.uniq.each {|user_id|
|
||||||
|
|
|
@ -8,6 +8,7 @@ class Observer::Session < ActiveRecord::Observer
|
||||||
def before_create(record)
|
def before_create(record)
|
||||||
check(record)
|
check(record)
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_update(record)
|
def before_update(record)
|
||||||
check(record)
|
check(record)
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,6 +19,7 @@ class Observer::Tag::TicketHistory < ActiveRecord::Observer
|
||||||
value_to: record.tag_item.name,
|
value_to: record.tag_item.name,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy(record)
|
def after_destroy(record)
|
||||||
|
|
||||||
# just process ticket object tags
|
# just process ticket object tags
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer
|
||||||
|
|
||||||
# if sender is customer, do not communication
|
# if sender is customer, do not communication
|
||||||
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
|
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
|
||||||
return 1 if sender == nil
|
return 1 if sender.nil?
|
||||||
return 1 if sender['name'] == 'Customer'
|
return 1 if sender['name'] == 'Customer'
|
||||||
|
|
||||||
# only apply on emails
|
# only apply on emails
|
||||||
|
|
|
@ -2,6 +2,7 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob
|
||||||
def initialize(id)
|
def initialize(id)
|
||||||
@article_id = id
|
@article_id = id
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
record = Ticket::Article.find( @article_id )
|
record = Ticket::Article.find( @article_id )
|
||||||
|
|
||||||
|
@ -37,12 +38,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 == ''
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer
|
||||||
|
|
||||||
# if sender is customer, do not communication
|
# if sender is customer, do not communication
|
||||||
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
|
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
|
||||||
return 1 if sender == nil
|
return 1 if sender.nil?
|
||||||
return 1 if sender['name'] == 'Customer'
|
return 1 if sender['name'] == 'Customer'
|
||||||
|
|
||||||
# only apply on emails
|
# only apply on emails
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
|
||||||
|
|
||||||
# if sender is customer, do not communication
|
# if sender is customer, do not communication
|
||||||
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
|
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
|
||||||
return 1 if sender == nil
|
return 1 if sender.nil?
|
||||||
return 1 if sender['name'] == 'Customer'
|
return 1 if sender['name'] == 'Customer'
|
||||||
|
|
||||||
# only apply on tweets
|
# only apply on tweets
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer
|
||||||
|
|
||||||
# if sender is customer, do not change anything
|
# if sender is customer, do not change anything
|
||||||
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
|
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
|
||||||
return if sender == nil
|
return if sender.nil?
|
||||||
return if sender['name'] == 'Customer'
|
return if sender['name'] == 'Customer'
|
||||||
|
|
||||||
# set email attributes
|
# set email attributes
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Observer::Ticket::Article::FillupFromGeneral < ActiveRecord::Observer
|
||||||
|
|
||||||
# if sender is customer, do not change anything
|
# if sender is customer, do not change anything
|
||||||
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
|
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
|
||||||
return if sender == nil
|
return if sender.nil?
|
||||||
return if sender['name'] == 'Customer'
|
return if sender['name'] == 'Customer'
|
||||||
|
|
||||||
# set from if not given
|
# set from if not given
|
||||||
|
|
|
@ -73,8 +73,8 @@ class Observer::Ticket::ArticleChanges < ActiveRecord::Observer
|
||||||
if sender.name == 'Customer'
|
if sender.name == 'Customer'
|
||||||
|
|
||||||
# check if last communication is done by agent, else do not set last_contact_customer
|
# check if last communication is done by agent, else do not set last_contact_customer
|
||||||
if record.ticket.last_contact_customer == nil ||
|
if record.ticket.last_contact_customer.nil? ||
|
||||||
record.ticket.last_contact_agent == nil ||
|
record.ticket.last_contact_agent.nil? ||
|
||||||
record.ticket.last_contact_agent.to_i > record.ticket.last_contact_customer.to_i
|
record.ticket.last_contact_agent.to_i > record.ticket.last_contact_customer.to_i
|
||||||
|
|
||||||
# set last_contact customer
|
# set last_contact customer
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
|
||||||
|
|
||||||
# get uniq objects
|
# get uniq objects
|
||||||
list_objects = get_uniq_changes(list)
|
list_objects = get_uniq_changes(list)
|
||||||
list_objects.each {|ticket_id, item|
|
list_objects.each {|_ticket_id, item|
|
||||||
|
|
||||||
# send background job
|
# send background job
|
||||||
Delayed::Job.enqueue( Observer::Ticket::Notification::BackgroundJob.new( item ) )
|
Delayed::Job.enqueue( Observer::Ticket::Notification::BackgroundJob.new( item ) )
|
||||||
|
@ -158,7 +158,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
|
||||||
EventBuffer.add(e)
|
EventBuffer.add(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_update(record)
|
def after_update(_record)
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
|
|
|
@ -4,6 +4,7 @@ class Observer::Ticket::Notification::BackgroundJob
|
||||||
def initialize(params)
|
def initialize(params)
|
||||||
@p = params
|
@p = params
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
ticket = Ticket.find(@p[:ticket_id])
|
ticket = Ticket.find(@p[:ticket_id])
|
||||||
if @p[:article_id]
|
if @p[:article_id]
|
||||||
|
@ -225,7 +226,7 @@ class Observer::Ticket::Notification::BackgroundJob
|
||||||
changes
|
changes
|
||||||
end
|
end
|
||||||
|
|
||||||
def template_create(user, ticket, article, ticket_changes)
|
def template_create(user, ticket, article, _ticket_changes)
|
||||||
article_content = ''
|
article_content = ''
|
||||||
if article
|
if article
|
||||||
article_content = '<snip>
|
article_content = '<snip>
|
||||||
|
@ -348,7 +349,7 @@ Changes:<br>
|
||||||
template
|
template
|
||||||
end
|
end
|
||||||
|
|
||||||
def template_header(user)
|
def template_header(_user)
|
||||||
'
|
'
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.header {
|
.header {
|
||||||
|
@ -385,7 +386,7 @@ Changes:<br>
|
||||||
'
|
'
|
||||||
end
|
end
|
||||||
|
|
||||||
def template_footer(user, ticket, article)
|
def template_footer(_user, _ticket, _article)
|
||||||
'
|
'
|
||||||
<p>
|
<p>
|
||||||
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">i18n(View this directly here)</a>
|
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">i18n(View this directly here)</a>
|
||||||
|
|
|
@ -2,6 +2,7 @@ class Observer::Ticket::OnlineNotificationSeen::BackgroundJob
|
||||||
def initialize(id)
|
def initialize(id)
|
||||||
@ticket_id = id
|
@ticket_id = id
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
|
|
||||||
# set all online notifications to seen
|
# set all online notifications to seen
|
||||||
|
|
|
@ -6,9 +6,11 @@ class Observer::Ticket::RefObjectTouch < ActiveRecord::Observer
|
||||||
def after_create(record)
|
def after_create(record)
|
||||||
ref_object_touch(record)
|
ref_object_touch(record)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_update(record)
|
def after_update(record)
|
||||||
ref_object_touch(record)
|
ref_object_touch(record)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy(record)
|
def after_destroy(record)
|
||||||
ref_object_touch(record)
|
ref_object_touch(record)
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,7 @@ class Observer::Ticket::UserTicketCounter < ActiveRecord::Observer
|
||||||
def after_create(record)
|
def after_create(record)
|
||||||
user_ticket_counter_update(record)
|
user_ticket_counter_update(record)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_update(record)
|
def after_update(record)
|
||||||
user_ticket_counter_update(record)
|
user_ticket_counter_update(record)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@ class Observer::Ticket::UserTicketCounter::BackgroundJob
|
||||||
def initialize(id)
|
def initialize(id)
|
||||||
@customer_id = id
|
@customer_id = id
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
|
|
||||||
# open ticket count
|
# open ticket count
|
||||||
|
|
|
@ -6,6 +6,7 @@ class Observer::User::Geo < ActiveRecord::Observer
|
||||||
def before_create(record)
|
def before_create(record)
|
||||||
check_geo(record)
|
check_geo(record)
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_update(record)
|
def before_update(record)
|
||||||
check_geo(record)
|
check_geo(record)
|
||||||
end
|
end
|
||||||
|
@ -17,7 +18,7 @@ class Observer::User::Geo < ActiveRecord::Observer
|
||||||
|
|
||||||
# check if geo update is needed based on old/new location
|
# check if geo update is needed based on old/new location
|
||||||
if record.id
|
if record.id
|
||||||
current = User.where( id: record.id ).first
|
current = User.find_by( id: record.id )
|
||||||
return if !current
|
return if !current
|
||||||
|
|
||||||
current_location = {}
|
current_location = {}
|
||||||
|
|
|
@ -6,9 +6,11 @@ class Observer::User::RefObjectTouch < ActiveRecord::Observer
|
||||||
def after_create(record)
|
def after_create(record)
|
||||||
ref_object_touch(record)
|
ref_object_touch(record)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_update(record)
|
def after_update(record)
|
||||||
ref_object_touch(record)
|
ref_object_touch(record)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy(record)
|
def after_destroy(record)
|
||||||
ref_object_touch(record)
|
ref_object_touch(record)
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,7 @@ class Observer::User::TicketOrganization < ActiveRecord::Observer
|
||||||
def after_create(record)
|
def after_create(record)
|
||||||
check_organization(record)
|
check_organization(record)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_update(record)
|
def after_update(record)
|
||||||
check_organization(record)
|
check_organization(record)
|
||||||
end
|
end
|
||||||
|
|
|
@ -195,7 +195,7 @@ class Package < ApplicationModel
|
||||||
}
|
}
|
||||||
|
|
||||||
# verify if package can get installed
|
# verify if package can get installed
|
||||||
package_db = Package.where( name: meta[:name] ).first
|
package_db = Package.find_by( name: meta[:name] )
|
||||||
if package_db
|
if package_db
|
||||||
if !data[:reinstall]
|
if !data[:reinstall]
|
||||||
if Gem::Version.new( package_db.version ) == Gem::Version.new( meta[:version] )
|
if Gem::Version.new( package_db.version ) == Gem::Version.new( meta[:version] )
|
||||||
|
@ -253,7 +253,7 @@ class Package < ApplicationModel
|
||||||
|
|
||||||
# Package.reinstall( package_name )
|
# Package.reinstall( package_name )
|
||||||
def self.reinstall(package_name)
|
def self.reinstall(package_name)
|
||||||
package = Package.where( name: package_name ).first
|
package = Package.find_by( name: package_name )
|
||||||
if !package
|
if !package
|
||||||
raise "No such package '#{package_name}'"
|
raise "No such package '#{package_name}'"
|
||||||
end
|
end
|
||||||
|
@ -300,10 +300,10 @@ class Package < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
# delete package
|
# delete package
|
||||||
record = Package.where(
|
record = Package.find_by(
|
||||||
name: meta[:name],
|
name: meta[:name],
|
||||||
version: meta[:version],
|
version: meta[:version],
|
||||||
).first
|
)
|
||||||
record.destroy
|
record.destroy
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -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
|
||||||
|
@ -339,10 +340,10 @@ class Package < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
def self._get_bin( name, version )
|
def self._get_bin( name, version )
|
||||||
package = Package.where(
|
package = Package.find_by(
|
||||||
name: name,
|
name: name,
|
||||||
version: version,
|
version: version,
|
||||||
).first
|
)
|
||||||
if !package
|
if !package
|
||||||
raise "No such package '#{name}' version '#{version}'"
|
raise "No such package '#{name}' version '#{version}'"
|
||||||
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 == ''
|
||||||
Dir.mkdir( tmp_path, 0755)
|
next if File.exist?(tmp_path)
|
||||||
end
|
|
||||||
end
|
Dir.mkdir(tmp_path, 0755)
|
||||||
}
|
}
|
||||||
|
|
||||||
# install file
|
# install file
|
||||||
|
@ -416,7 +417,7 @@ class Package < ApplicationModel
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self._delete_file(file, permission, data)
|
def self._delete_file(file, _permission, _data)
|
||||||
location = @@root + '/' + file
|
location = @@root + '/' + file
|
||||||
|
|
||||||
# install file
|
# install file
|
||||||
|
@ -474,20 +475,20 @@ class Package < ApplicationModel
|
||||||
|
|
||||||
# down
|
# down
|
||||||
if direction == 'reverse'
|
if direction == 'reverse'
|
||||||
done = Package::Migration.where( name: package.underscore, version: version ).first
|
done = Package::Migration.find_by( name: package.underscore, version: version )
|
||||||
next if !done
|
next if !done
|
||||||
logger.info "NOTICE: down package migration '#{migration}'"
|
logger.info "NOTICE: down package migration '#{migration}'"
|
||||||
load "#{location}/#{migration}"
|
load "#{location}/#{migration}"
|
||||||
classname = name.camelcase
|
classname = name.camelcase
|
||||||
Kernel.const_get(classname).down
|
Kernel.const_get(classname).down
|
||||||
record = Package::Migration.where( name: package.underscore, version: version ).first
|
record = Package::Migration.find_by( name: package.underscore, version: version )
|
||||||
if record
|
if record
|
||||||
record.destroy
|
record.destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
# up
|
# up
|
||||||
else
|
else
|
||||||
done = Package::Migration.where( name: package.underscore, version: version ).first
|
done = Package::Migration.find_by( name: package.underscore, version: version )
|
||||||
next if done
|
next if done
|
||||||
logger.info "NOTICE: up package migration '#{migration}'"
|
logger.info "NOTICE: up package migration '#{migration}'"
|
||||||
load "#{location}/#{migration}"
|
load "#{location}/#{migration}"
|
||||||
|
|
|
@ -124,7 +124,7 @@ class Scheduler < ApplicationModel
|
||||||
def self.check( name, time_warning = 10, time_critical = 20 )
|
def self.check( name, time_warning = 10, time_critical = 20 )
|
||||||
time_warning_time = Time.now - time_warning.minutes
|
time_warning_time = Time.now - time_warning.minutes
|
||||||
time_critical_time = Time.now - time_critical.minutes
|
time_critical_time = Time.now - time_critical.minutes
|
||||||
scheduler = Scheduler.where( name: name ).first
|
scheduler = Scheduler.find_by( name: name )
|
||||||
if !scheduler
|
if !scheduler
|
||||||
puts "CRITICAL - no such scheduler jobs '#{name}'"
|
puts "CRITICAL - no such scheduler jobs '#{name}'"
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -25,8 +25,9 @@ class Setting < ApplicationModel
|
||||||
# config lookups
|
# config lookups
|
||||||
config.each { |key, value|
|
config.each { |key, value|
|
||||||
next if value.class.to_s != 'String'
|
next if value.class.to_s != 'String'
|
||||||
config[key].gsub!( /\#\{config\.(.+?)\}/ ) { |s|
|
|
||||||
s = config[$1].to_s
|
config[key].gsub!( /\#\{config\.(.+?)\}/ ) {
|
||||||
|
config[$1].to_s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ class Setting < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.set(name, value)
|
def self.set(name, value)
|
||||||
setting = Setting.where( name: name ).first
|
setting = Setting.find_by( name: name )
|
||||||
if !setting
|
if !setting
|
||||||
raise "Can't find config setting '#{name}'"
|
raise "Can't find config setting '#{name}'"
|
||||||
end
|
end
|
||||||
|
@ -55,9 +56,11 @@ class Setting < ApplicationModel
|
||||||
def delete_cache
|
def delete_cache
|
||||||
@@current[:settings_config] = nil
|
@@current[:settings_config] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_initial
|
def set_initial
|
||||||
self.state_initial = self.state
|
self.state_initial = self.state
|
||||||
end
|
end
|
||||||
|
|
||||||
def state_check
|
def state_check
|
||||||
|
|
||||||
return if !(self.state || self.state == false)
|
return if !(self.state || self.state == false)
|
||||||
|
|
|
@ -140,7 +140,7 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
def content
|
def content
|
||||||
file = Store::File.where( id: self.store_file_id ).first
|
file = Store::File.find_by( id: self.store_file_id )
|
||||||
if !file
|
if !file
|
||||||
raise "No such file #{ self.store_file_id }!"
|
raise "No such file #{ self.store_file_id }!"
|
||||||
end
|
end
|
||||||
|
@ -148,7 +148,7 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
def provider
|
def provider
|
||||||
file = Store::File.where( id: self.store_file_id ).first
|
file = Store::File.find_by( id: self.store_file_id )
|
||||||
if !file
|
if !file
|
||||||
raise "No such file #{ self.store_file_id }!"
|
raise "No such file #{ self.store_file_id }!"
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,8 +9,8 @@ class Store
|
||||||
def self.add(data)
|
def self.add(data)
|
||||||
sha = Digest::SHA256.hexdigest( data )
|
sha = Digest::SHA256.hexdigest( data )
|
||||||
|
|
||||||
file = Store::File.where( sha: sha ).first
|
file = Store::File.find_by( sha: sha )
|
||||||
if file == nil
|
if file.nil?
|
||||||
|
|
||||||
# load backend based on config
|
# load backend based on config
|
||||||
adapter_name = Setting.get('storage_provider') || 'DB'
|
adapter_name = Setting.get('storage_provider') || 'DB'
|
||||||
|
@ -34,7 +34,7 @@ class Store
|
||||||
c = adapter.get( self.sha )
|
c = adapter.get( self.sha )
|
||||||
else
|
else
|
||||||
# fallback until migration is done
|
# fallback until migration is done
|
||||||
c = Store::Provider::DB.where( md5: self.md5 ).first.data
|
c = Store::Provider::DB.find_by( md5: self.md5 ).data
|
||||||
end
|
end
|
||||||
c
|
c
|
||||||
end
|
end
|
||||||
|
@ -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
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Store
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get(sha)
|
def self.get(sha)
|
||||||
file = Store::Provider::DB.where( sha: sha ).first
|
file = Store::Provider::DB.find_by( sha: sha )
|
||||||
return if !file
|
return if !file
|
||||||
file.data
|
file.data
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,9 +43,7 @@ class Tag < ApplicationModel
|
||||||
tag_item_id: tag_item_id,
|
tag_item_id: tag_item_id,
|
||||||
o_id: data[:o_id],
|
o_id: data[:o_id],
|
||||||
)
|
)
|
||||||
result.each { |item|
|
result.each(&:destroy)
|
||||||
item.destroy
|
|
||||||
}
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -81,7 +79,7 @@ class Tag < ApplicationModel
|
||||||
return @@cache_item[ name ] if @@cache_item[ name ]
|
return @@cache_item[ name ] if @@cache_item[ name ]
|
||||||
|
|
||||||
# lookup
|
# lookup
|
||||||
tag_item = Tag::Item.where( name: name ).first
|
tag_item = Tag::Item.find_by( name: name )
|
||||||
if tag_item
|
if tag_item
|
||||||
@@cache_item[ name ] = tag_item.id
|
@@cache_item[ name ] = tag_item.id
|
||||||
return tag_item.id
|
return tag_item.id
|
||||||
|
@ -112,7 +110,7 @@ class Tag < ApplicationModel
|
||||||
return @@cache_object[ name ] if @@cache_object[ name ]
|
return @@cache_object[ name ] if @@cache_object[ name ]
|
||||||
|
|
||||||
# lookup
|
# lookup
|
||||||
tag_object = Tag::Object.where( name: name ).first
|
tag_object = Tag::Object.find_by( name: name )
|
||||||
if tag_object
|
if tag_object
|
||||||
@@cache_object[ name ] = tag_object.id
|
@@cache_object[ name ] = tag_object.id
|
||||||
return tag_object.id
|
return tag_object.id
|
||||||
|
|
|
@ -11,6 +11,7 @@ class Taskbar < ApplicationModel
|
||||||
def update_last_contact
|
def update_last_contact
|
||||||
self.last_contact = Time.now
|
self.last_contact = Time.now
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_user
|
def set_user
|
||||||
self.user_id = UserInfo.current_user_id
|
self.user_id = UserInfo.current_user_id
|
||||||
end
|
end
|
||||||
|
|
|
@ -128,9 +128,7 @@ returns
|
||||||
def merge_to(data)
|
def merge_to(data)
|
||||||
|
|
||||||
# update articles
|
# update articles
|
||||||
Ticket::Article.where( ticket_id: self.id ).each {|article|
|
Ticket::Article.where( ticket_id: self.id ).each(&:touch)
|
||||||
article.touch
|
|
||||||
}
|
|
||||||
|
|
||||||
# quiet update of reassign of articles
|
# quiet update of reassign of articles
|
||||||
Ticket::Article.where( ticket_id: self.id ).update_all( ['ticket_id = ?', data[:ticket_id] ] )
|
Ticket::Article.where( ticket_id: self.id ).update_all( ['ticket_id = ?', data[:ticket_id] ] )
|
||||||
|
@ -166,7 +164,7 @@ returns
|
||||||
self.state_id = Ticket::State.lookup( name: 'merged' ).id
|
self.state_id = Ticket::State.lookup( name: 'merged' ).id
|
||||||
|
|
||||||
# rest owner
|
# rest owner
|
||||||
self.owner_id = User.where( login: '-' ).first.id
|
self.owner_id = User.find_by( login: '-' ).id
|
||||||
|
|
||||||
# save ticket
|
# save ticket
|
||||||
self.save
|
self.save
|
||||||
|
|
|
@ -18,9 +18,7 @@ returns
|
||||||
state_list_open = Ticket::State.by_category( 'open' )
|
state_list_open = Ticket::State.by_category( 'open' )
|
||||||
|
|
||||||
tickets = Ticket.where( state_id: state_list_open )
|
tickets = Ticket.where( state_id: state_list_open )
|
||||||
tickets.each {|ticket|
|
tickets.each(&:escalation_calculation)
|
||||||
ticket.escalation_calculation
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -175,7 +173,7 @@ returns
|
||||||
def escalation_calculation_get_sla
|
def escalation_calculation_get_sla
|
||||||
sla_selected = nil
|
sla_selected = nil
|
||||||
sla_list = Cache.get( 'SLA::List::Active' )
|
sla_list = Cache.get( 'SLA::List::Active' )
|
||||||
if sla_list == nil
|
if sla_list.nil?
|
||||||
sla_list = Sla.where( active: true )
|
sla_list = Sla.where( active: true )
|
||||||
Cache.write( 'SLA::List::Active', sla_list, { expires_in: 1.hour } )
|
Cache.write( 'SLA::List::Active', sla_list, { expires_in: 1.hour } )
|
||||||
end
|
end
|
||||||
|
@ -189,7 +187,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 +198,6 @@ returns
|
||||||
else
|
else
|
||||||
hit = false
|
hit = false
|
||||||
end
|
end
|
||||||
end
|
|
||||||
}
|
}
|
||||||
if hit
|
if hit
|
||||||
sla_selected = sla
|
sla_selected = sla
|
||||||
|
|
|
@ -18,9 +18,9 @@ returns
|
||||||
def self.generate
|
def self.generate
|
||||||
|
|
||||||
# generate number
|
# generate number
|
||||||
(1..50_000).each { |i|
|
(1..50_000).each {
|
||||||
number = adapter.generate
|
number = adapter.generate
|
||||||
ticket = Ticket.where( number: number ).first
|
ticket = Ticket.find_by( number: number )
|
||||||
return number if !ticket
|
return number if !ticket
|
||||||
}
|
}
|
||||||
raise "Can't generate new ticket number!"
|
raise "Can't generate new ticket number!"
|
||||||
|
|
|
@ -75,9 +75,9 @@ module Ticket::Number::Date
|
||||||
|
|
||||||
# probe format
|
# probe format
|
||||||
if string =~ /#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,50})/i
|
if string =~ /#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,50})/i
|
||||||
ticket = Ticket.where( number: $1 ).first
|
ticket = Ticket.find_by( number: $1 )
|
||||||
elsif string =~ /#{ticket_hook}\s{0,2}(#{system_id}\d{2,50})/i
|
elsif string =~ /#{ticket_hook}\s{0,2}(#{system_id}\d{2,50})/i
|
||||||
ticket = Ticket.where( number: $1 ).first
|
ticket = Ticket.find_by( number: $1 )
|
||||||
end
|
end
|
||||||
ticket
|
ticket
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,11 +31,12 @@ module Ticket::Number::Increment
|
||||||
min_digs = min_digs.to_i - 1
|
min_digs = min_digs.to_i - 1
|
||||||
end
|
end
|
||||||
fillup = Setting.get('system_id') || '1'
|
fillup = Setting.get('system_id') || '1'
|
||||||
( 1..100 ).each do |i|
|
( 1..100 ).each {
|
||||||
if ( fillup.length.to_i + counter_increment.to_s.length.to_i ) < min_digs.to_i
|
|
||||||
|
next if ( fillup.length.to_i + counter_increment.to_s.length.to_i ) >= min_digs.to_i
|
||||||
|
|
||||||
fillup = fillup + '0'
|
fillup = fillup + '0'
|
||||||
end
|
}
|
||||||
end
|
|
||||||
number = fillup.to_s + counter_increment.to_s
|
number = fillup.to_s + counter_increment.to_s
|
||||||
|
|
||||||
# calculate a checksum
|
# calculate a checksum
|
||||||
|
@ -78,9 +79,9 @@ module Ticket::Number::Increment
|
||||||
|
|
||||||
# probe format
|
# probe format
|
||||||
if string =~ /#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,48})/i
|
if string =~ /#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,48})/i
|
||||||
ticket = Ticket.where( number: $1 ).first
|
ticket = Ticket.find_by( number: $1 )
|
||||||
elsif string =~ /#{ticket_hook}\s{0,2}(#{system_id}\d{2,48})/i
|
elsif string =~ /#{ticket_hook}\s{0,2}(#{system_id}\d{2,48})/i
|
||||||
ticket = Ticket.where( number: $1 ).first
|
ticket = Ticket.find_by( number: $1 )
|
||||||
end
|
end
|
||||||
ticket
|
ticket
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,13 +63,14 @@ returns
|
||||||
state_ids.push params[:ticket].state.id
|
state_ids.push params[:ticket].state.id
|
||||||
end
|
end
|
||||||
state_types.each {|type|
|
state_types.each {|type|
|
||||||
state_type = Ticket::StateType.where( name: type ).first
|
state_type = Ticket::StateType.find_by( name: type )
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Token < ActiveRecord::Base
|
||||||
def self.check( data )
|
def self.check( data )
|
||||||
|
|
||||||
# fetch token
|
# fetch token
|
||||||
token = Token.where( action: data[:action], name: data[:name] ).first
|
token = Token.find_by( action: data[:action], name: data[:name] )
|
||||||
return if !token
|
return if !token
|
||||||
|
|
||||||
# check if token is still valid
|
# check if token is still valid
|
||||||
|
|
|
@ -172,6 +172,7 @@ translate strings in ruby context, e. g. for notifications
|
||||||
return if target_initial
|
return if target_initial
|
||||||
self.target_initial = self.target
|
self.target_initial = self.target
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_clear
|
def cache_clear
|
||||||
Cache.delete( 'Translation::' + self.locale.downcase )
|
Cache.delete( 'Translation::' + self.locale.downcase )
|
||||||
end
|
end
|
||||||
|
|
|
@ -184,11 +184,11 @@ returns
|
||||||
return if !password || password == ''
|
return if !password || password == ''
|
||||||
|
|
||||||
# try to find user based on login
|
# try to find user based on login
|
||||||
user = User.where( login: username.downcase, active: true ).first
|
user = User.find_by( login: username.downcase, active: true )
|
||||||
|
|
||||||
# try second lookup with email
|
# try second lookup with email
|
||||||
if !user
|
if !user
|
||||||
user = User.where( email: username.downcase, active: true ).first
|
user = User.find_by( email: username.downcase, active: true )
|
||||||
end
|
end
|
||||||
|
|
||||||
# check failed logins
|
# check failed logins
|
||||||
|
@ -280,11 +280,11 @@ returns
|
||||||
return if !username || username == ''
|
return if !username || username == ''
|
||||||
|
|
||||||
# try to find user based on login
|
# try to find user based on login
|
||||||
user = User.where( login: username.downcase, active: true ).first
|
user = User.find_by( login: username.downcase, active: true )
|
||||||
|
|
||||||
# try second lookup with email
|
# try second lookup with email
|
||||||
if !user
|
if !user
|
||||||
user = User.where( email: username.downcase, active: true ).first
|
user = User.find_by( email: username.downcase, active: true )
|
||||||
end
|
end
|
||||||
|
|
||||||
# check if email address exists
|
# check if email address exists
|
||||||
|
@ -377,7 +377,7 @@ returns
|
||||||
user.update_attributes( password: password )
|
user.update_attributes( password: password )
|
||||||
|
|
||||||
# delete token
|
# delete token
|
||||||
Token.where( action: 'PasswordReset', name: token ).first.destroy
|
Token.find_by( action: 'PasswordReset', name: token ).destroy
|
||||||
user
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -476,7 +476,7 @@ returns
|
||||||
self.login = self.login.downcase
|
self.login = self.login.downcase
|
||||||
check = true
|
check = true
|
||||||
while check
|
while check
|
||||||
exists = User.where( login: self.login ).first
|
exists = User.find_by( login: self.login )
|
||||||
if exists && exists.id != self.id
|
if exists && exists.id != self.id
|
||||||
self.login = self.login + rand(999).to_s
|
self.login = self.login + rand(999).to_s
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,6 +3,7 @@ class UpdateSession < ActiveRecord::Migration
|
||||||
add_column :sessions, :request_type, :integer, null: true
|
add_column :sessions, :request_type, :integer, null: true
|
||||||
add_index :sessions, :request_type
|
add_index :sessions, :request_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,6 +28,7 @@ class UpdateTicketNumber < ActiveRecord::Migration
|
||||||
frontend: false
|
frontend: false
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,6 +47,7 @@ class UpdateAuth < ActiveRecord::Migration
|
||||||
frontend: false
|
frontend: false
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,6 +53,7 @@ class AddSearchIndex < ActiveRecord::Migration
|
||||||
User.search_index_reload
|
User.search_index_reload
|
||||||
Organization.search_index_reload
|
Organization.search_index_reload
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@ class RenameAvatarTypo < ActiveRecord::Migration
|
||||||
def up
|
def up
|
||||||
rename_column :avatars, :inital, :initial
|
rename_column :avatars, :inital, :initial
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
rename_column :avatars, :initial, :inital
|
rename_column :avatars, :initial, :inital
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module Auth::Developer
|
module Auth::Developer
|
||||||
def self.check( username, password, config, user )
|
def self.check( _username, password, _config, user )
|
||||||
|
|
||||||
# development systems
|
# development systems
|
||||||
if Setting.get('developer_mode') == true
|
if Setting.get('developer_mode') == true
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module Auth::Internal
|
module Auth::Internal
|
||||||
def self.check( username, password, config, user )
|
def self.check( _username, password, _config, user )
|
||||||
|
|
||||||
# return if no user exists
|
# return if no user exists
|
||||||
return nil if !user
|
return nil if !user
|
||||||
|
|
|
@ -46,7 +46,7 @@ module Auth::Ldap
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if user_dn == nil
|
if user_dn.nil?
|
||||||
Rails.logger.info "ldap entry found for user '#{username}' with filter #{filter} failed!"
|
Rails.logger.info "ldap entry found for user '#{username}' with filter #{filter} failed!"
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,7 @@ class Class
|
||||||
.tr('-', '_')
|
.tr('-', '_')
|
||||||
.downcase
|
.downcase
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_app_model
|
def to_app_model
|
||||||
camel_cased_word = self.to_s
|
camel_cased_word = self.to_s
|
||||||
camel_cased_word.gsub(/::/, '').to_sym
|
camel_cased_word.gsub(/::/, '').to_sym
|
||||||
|
|
|
@ -7,6 +7,7 @@ class String
|
||||||
end
|
end
|
||||||
body_quote
|
body_quote
|
||||||
end
|
end
|
||||||
|
|
||||||
def word_wrap(*args)
|
def word_wrap(*args)
|
||||||
options = args.extract_options!
|
options = args.extract_options!
|
||||||
unless args.blank?
|
unless args.blank?
|
||||||
|
@ -66,13 +67,13 @@ class String
|
||||||
# see also test/fixtures/mail21.box
|
# see also test/fixtures/mail21.box
|
||||||
# note: string.encode!('UTF-8', 'UTF-8', :invalid => :replace, :replace => '?') was not detecting invalid chars
|
# note: string.encode!('UTF-8', 'UTF-8', :invalid => :replace, :replace => '?') was not detecting invalid chars
|
||||||
if !string.valid_encoding?
|
if !string.valid_encoding?
|
||||||
string = string.chars.select { |c| c.valid_encoding? }.join
|
string = string.chars.select(&:valid_encoding?).join
|
||||||
end
|
end
|
||||||
|
|
||||||
# find <a href=....> and replace it with [x]
|
# find <a href=....> and replace it with [x]
|
||||||
link_list = ''
|
link_list = ''
|
||||||
counter = 0
|
counter = 0
|
||||||
string.gsub!( /<a\s.*?href=("|')(.+?)("|').*?>/ix ) { |item|
|
string.gsub!( /<a\s.*?href=("|')(.+?)("|').*?>/ix ) {
|
||||||
link = $2
|
link = $2
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
link_list += "[#{counter}] #{link}\n"
|
link_list += "[#{counter}] #{link}\n"
|
||||||
|
@ -121,12 +122,12 @@ class String
|
||||||
string.gsub!( ' ', ' ' )
|
string.gsub!( ' ', ' ' )
|
||||||
|
|
||||||
# encode html entities like "–"
|
# encode html entities like "–"
|
||||||
string.gsub!( /(&\#(\d+);?)/x ) { |item|
|
string.gsub!( /(&\#(\d+);?)/x ) {
|
||||||
$2.chr
|
$2.chr
|
||||||
}
|
}
|
||||||
|
|
||||||
# encode html entities like "d;"
|
# encode html entities like "d;"
|
||||||
string.gsub!( /(&\#[xX]([0-9a-fA-F]+);?)/x ) { |item|
|
string.gsub!( /(&\#[xX]([0-9a-fA-F]+);?)/x ) {
|
||||||
chr_orig = $1
|
chr_orig = $1
|
||||||
hex = $2.hex
|
hex = $2.hex
|
||||||
if hex
|
if hex
|
||||||
|
|
|
@ -14,7 +14,7 @@ module FillDB
|
||||||
# organizations
|
# organizations
|
||||||
organization_pool = []
|
organization_pool = []
|
||||||
if organizations && !organizations.zero?
|
if organizations && !organizations.zero?
|
||||||
(1..organizations).each {|count|
|
(1..organizations).each {
|
||||||
organization = Organization.create( name: 'FillOrganization::' + rand(999_999).to_s, active: true )
|
organization = Organization.create( name: 'FillOrganization::' + rand(999_999).to_s, active: true )
|
||||||
organization_pool.push organization
|
organization_pool.push organization
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ module FillDB
|
||||||
if agents && !agents.zero?
|
if agents && !agents.zero?
|
||||||
roles = Role.where( name: [ 'Agent'] )
|
roles = Role.where( name: [ 'Agent'] )
|
||||||
groups_all = Group.all
|
groups_all = Group.all
|
||||||
(1..agents).each {|count|
|
(1..agents).each {
|
||||||
suffix = rand(99_999).to_s
|
suffix = rand(99_999).to_s
|
||||||
user = User.create_or_update(
|
user = User.create_or_update(
|
||||||
login: "filldb-agent-#{suffix}",
|
login: "filldb-agent-#{suffix}",
|
||||||
|
@ -51,7 +51,7 @@ module FillDB
|
||||||
if customers && !customers.zero?
|
if customers && !customers.zero?
|
||||||
roles = Role.where( name: [ 'Customer'] )
|
roles = Role.where( name: [ 'Customer'] )
|
||||||
groups_all = Group.all
|
groups_all = Group.all
|
||||||
(1..customers).each {|count|
|
(1..customers).each {
|
||||||
suffix = rand(99_999).to_s
|
suffix = rand(99_999).to_s
|
||||||
organization = nil
|
organization = nil
|
||||||
if !organization_pool.empty? && rand(2) == 1
|
if !organization_pool.empty? && rand(2) == 1
|
||||||
|
@ -77,7 +77,7 @@ module FillDB
|
||||||
group_pool = []
|
group_pool = []
|
||||||
if groups && !groups.zero?
|
if groups && !groups.zero?
|
||||||
puts "1..#{groups}"
|
puts "1..#{groups}"
|
||||||
(1..groups).each {|count|
|
(1..groups).each {
|
||||||
group = Group.create( name: 'FillGroup::' + rand(999_999).to_s, active: true )
|
group = Group.create( name: 'FillGroup::' + rand(999_999).to_s, active: true )
|
||||||
group_pool.push group
|
group_pool.push group
|
||||||
Role.where(name: 'Agent').first.users.where(active: true).each {|user|
|
Role.where(name: 'Agent').first.users.where(active: true).each {|user|
|
||||||
|
@ -95,7 +95,7 @@ module FillDB
|
||||||
priority_pool = Ticket::Priority.all
|
priority_pool = Ticket::Priority.all
|
||||||
state_pool = Ticket::State.all
|
state_pool = Ticket::State.all
|
||||||
if tickets && !tickets.zero?
|
if tickets && !tickets.zero?
|
||||||
(1..tickets).each {|count|
|
(1..tickets).each {
|
||||||
customer = customer_pool[ rand(customer_pool.length - 1) ]
|
customer = customer_pool[ rand(customer_pool.length - 1) ]
|
||||||
agent = agent_pool[ rand(agent_pool.length - 1) ]
|
agent = agent_pool[ rand(agent_pool.length - 1) ]
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create(
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -480,7 +480,7 @@ module Import::OTRS2
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self._ticket_result(result, locks, thread = '-')
|
def self._ticket_result(result, locks, _thread = '-')
|
||||||
# puts result.inspect
|
# puts result.inspect
|
||||||
map = {
|
map = {
|
||||||
Ticket: {
|
Ticket: {
|
||||||
|
@ -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
|
||||||
|
@ -968,17 +970,18 @@ module Import::OTRS2
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_queue_ids(user, groups, roles, queues)
|
def self.get_queue_ids(user, _groups, _roles, queues)
|
||||||
queue_ids = []
|
queue_ids = []
|
||||||
|
|
||||||
# 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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -991,19 +994,23 @@ module Import::OTRS2
|
||||||
queue_ids
|
queue_ids
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_roles_ids(user, groups, roles, queues)
|
def self.get_roles_ids(user, groups, roles, _queues)
|
||||||
roles = ['Agent']
|
roles = ['Agent']
|
||||||
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
|
||||||
|
@ -80,10 +81,11 @@ module NotificationFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
# translate
|
# translate
|
||||||
data[:string].gsub!( /i18n\((|.+?)\)/ ) { |placeholder|
|
data[:string].gsub!( /i18n\((|.+?)\)/ ) {
|
||||||
string = $1
|
string = $1
|
||||||
locale = data[:locale] || 'en'
|
locale = data[:locale] || 'en'
|
||||||
placeholder = Translation.translate( locale, string )
|
|
||||||
|
Translation.translate( locale, string )
|
||||||
}
|
}
|
||||||
|
|
||||||
data[:string]
|
data[:string]
|
||||||
|
|
|
@ -150,7 +150,7 @@ return search result
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.search( query, limit = 10, index = nil, query_extention = {} )
|
def self.search( query, _limit = 10, index = nil, query_extention = {} )
|
||||||
return [] if !query
|
return [] if !query
|
||||||
|
|
||||||
url = build_url()
|
url = build_url()
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -36,8 +36,8 @@ class Sessions::Client
|
||||||
user_id_last_run = user.id
|
user_id_last_run = user.id
|
||||||
|
|
||||||
# release old objects
|
# release old objects
|
||||||
backend_pool.each {|pool|
|
backend_pool.collect! {
|
||||||
pool = nil
|
nil
|
||||||
}
|
}
|
||||||
|
|
||||||
# create new pool
|
# create new pool
|
||||||
|
@ -52,9 +52,7 @@ class Sessions::Client
|
||||||
self.log "---client - looking for data of user #{user.id}"
|
self.log "---client - looking for data of user #{user.id}"
|
||||||
|
|
||||||
# push messages from backends
|
# push messages from backends
|
||||||
backend_pool.each {|pool|
|
backend_pool.each(&:push)
|
||||||
pool.push
|
|
||||||
}
|
|
||||||
|
|
||||||
self.log '---/client-'
|
self.log '---/client-'
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module Sso::Env
|
module Sso::Env
|
||||||
def self.check( params, config_item )
|
def self.check( _params, _config_item )
|
||||||
|
|
||||||
# try to find user based on login
|
# try to find user based on login
|
||||||
if ENV['REMOTE_USER']
|
if ENV['REMOTE_USER']
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module Sso::Otrs
|
module Sso::Otrs
|
||||||
def self.check( params, config_item )
|
def self.check( params, _config_item )
|
||||||
|
|
||||||
endpoint = Setting.get('import_otrs_endpoint')
|
endpoint = Setting.get('import_otrs_endpoint')
|
||||||
return false if !endpoint
|
return false if !endpoint
|
||||||
|
|
|
@ -2,7 +2,7 @@ $LOAD_PATH << './lib'
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
|
|
||||||
namespace :searchindex do
|
namespace :searchindex do
|
||||||
task :drop, [:opts] => :environment do |t, args|
|
task :drop, [:opts] => :environment do |_t, _args|
|
||||||
|
|
||||||
# drop indexes
|
# drop indexes
|
||||||
puts 'drop indexes...'
|
puts 'drop indexes...'
|
||||||
|
@ -12,7 +12,7 @@ namespace :searchindex do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
task :create, [:opts] => :environment do |t, args|
|
task :create, [:opts] => :environment do |_t, _args|
|
||||||
|
|
||||||
# create indexes
|
# create indexes
|
||||||
puts 'create indexes...'
|
puts 'create indexes...'
|
||||||
|
@ -39,7 +39,7 @@ namespace :searchindex do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
task :reload, [:opts] => :environment do |t, args|
|
task :reload, [:opts] => :environment do |_t, _args|
|
||||||
|
|
||||||
puts 'reload data...'
|
puts 'reload data...'
|
||||||
User.search_index_reload
|
User.search_index_reload
|
||||||
|
@ -48,7 +48,7 @@ namespace :searchindex do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
task :rebuild, [:opts] => :environment do |t, args|
|
task :rebuild, [:opts] => :environment do |_t, _args|
|
||||||
|
|
||||||
Rake::Task['searchindex:drop'].execute
|
Rake::Task['searchindex:drop'].execute
|
||||||
Rake::Task['searchindex:create'].execute
|
Rake::Task['searchindex:create'].execute
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'rubygems'
|
||||||
|
|
||||||
namespace :test do
|
namespace :test do
|
||||||
desc 'Start browser tests'
|
desc 'Start browser tests'
|
||||||
task :browser, [:opts] => :environment do |t, args|
|
task :browser, [:opts] => :environment do |_t, args|
|
||||||
|
|
||||||
start = Time.now()
|
start = Time.now()
|
||||||
if !args.opts
|
if !args.opts
|
||||||
|
|
|
@ -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
|
||||||
|
@ -65,9 +69,11 @@ put working hours matrix and timezone in function, returns UTC working hours mat
|
||||||
Sat: [],
|
Sat: [],
|
||||||
Sun: [],
|
Sun: [],
|
||||||
}
|
}
|
||||||
(1..hours_to_shift).each {|count|
|
(1..hours_to_shift).each {
|
||||||
working_hours.each {|day, value|
|
working_hours.each {|day, value|
|
||||||
if working_hours[day]
|
|
||||||
|
next if !value
|
||||||
|
|
||||||
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
|
||||||
|
@ -242,14 +243,14 @@ EventMachine.run {
|
||||||
|
|
||||||
# websocket
|
# websocket
|
||||||
log 'notice', "Status: websocket clients: #{ @clients.size }"
|
log 'notice', "Status: websocket clients: #{ @clients.size }"
|
||||||
@clients.each { |client_id, client|
|
@clients.each { |client_id, _client|
|
||||||
log 'notice', 'working...', client_id
|
log 'notice', 'working...', client_id
|
||||||
}
|
}
|
||||||
|
|
||||||
# ajax
|
# ajax
|
||||||
client_list = Sessions.list
|
client_list = Sessions.list
|
||||||
clients = 0
|
clients = 0
|
||||||
client_list.each {|client_id, client|
|
client_list.each {|_client_id, client|
|
||||||
next if client[:meta][:type] == 'websocket'
|
next if client[:meta][:type] == 'websocket'
|
||||||
clients = clients + 1
|
clients = clients + 1
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
|
|
@ -11,6 +11,7 @@ class AAbUnitTest < TestCase
|
||||||
value: '0',
|
value: '0',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ui
|
def test_ui
|
||||||
@browser = browser_instance
|
@browser = browser_instance
|
||||||
location( url: browser_url + '/tests-ui' )
|
location( url: browser_url + '/tests-ui' )
|
||||||
|
@ -34,6 +35,7 @@ class AAbUnitTest < TestCase
|
||||||
value: '0',
|
value: '0',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_form
|
def test_form
|
||||||
@browser = browser_instance
|
@browser = browser_instance
|
||||||
location( url: browser_url + '/tests-form' )
|
location( url: browser_url + '/tests-form' )
|
||||||
|
@ -57,6 +59,7 @@ class AAbUnitTest < TestCase
|
||||||
value: '0',
|
value: '0',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_table
|
def test_table
|
||||||
@browser = browser_instance
|
@browser = browser_instance
|
||||||
location( url: browser_url + '/tests-table' )
|
location( url: browser_url + '/tests-table' )
|
||||||
|
|
|
@ -20,6 +20,7 @@ class TaskbarTaskTest < TestCase
|
||||||
)
|
)
|
||||||
sleep 10
|
sleep 10
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_persistant_task_b
|
def test_persistant_task_b
|
||||||
@browser = browser_instance
|
@browser = browser_instance
|
||||||
login(
|
login(
|
||||||
|
@ -41,6 +42,7 @@ class TaskbarTaskTest < TestCase
|
||||||
|
|
||||||
exists_not( css: '.active .newTicket input[name="title"]' )
|
exists_not( css: '.active .newTicket input[name="title"]' )
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_persistant_task_with_relogin
|
def test_persistant_task_with_relogin
|
||||||
@browser = browser_instance
|
@browser = browser_instance
|
||||||
login(
|
login(
|
||||||
|
|
|
@ -68,7 +68,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
return if !@browsers
|
return if !@browsers
|
||||||
@browsers.each { |hash, local_browser|
|
@browsers.each { |_hash, local_browser|
|
||||||
screenshot( browser: local_browser, comment: 'teardown' )
|
screenshot( browser: local_browser, comment: 'teardown' )
|
||||||
browser_instance_close(local_browser)
|
browser_instance_close(local_browser)
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
instance.find_elements( { css: 'a[href="#current_user"]' } )[0].click
|
instance.find_elements( { css: 'a[href="#current_user"]' } )[0].click
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
instance.find_elements( { css: 'a[href="#logout"]' } )[0].click
|
instance.find_elements( { css: 'a[href="#logout"]' } )[0].click
|
||||||
(1..6).each {|loop|
|
(1..6).each {
|
||||||
sleep 1
|
sleep 1
|
||||||
login = instance.find_elements( { css: '#login' } )[0]
|
login = instance.find_elements( { css: '#login' } )[0]
|
||||||
if login
|
if login
|
||||||
|
@ -696,7 +696,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def open_task(params = {}, fallback = false)
|
def open_task(params = {}, _fallback = false)
|
||||||
log('open_task', params)
|
log('open_task', params)
|
||||||
|
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
|
@ -760,7 +760,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
loops = (timeout).to_i * 2
|
loops = (timeout).to_i * 2
|
||||||
text = ''
|
text = ''
|
||||||
(1..loops).each { |loop|
|
(1..loops).each {
|
||||||
element = instance.find_elements( { css: params[:css] } )[0]
|
element = instance.find_elements( { css: params[:css] } )[0]
|
||||||
if element #&& element.displayed?
|
if element #&& element.displayed?
|
||||||
begin
|
begin
|
||||||
|
@ -820,7 +820,7 @@ wait untill text in selector disabppears
|
||||||
end
|
end
|
||||||
loops = (timeout).to_i
|
loops = (timeout).to_i
|
||||||
text = ''
|
text = ''
|
||||||
(1..loops).each { |loop|
|
(1..loops).each {
|
||||||
element = instance.find_elements( { css: params[:css] } )[0]
|
element = instance.find_elements( { css: params[:css] } )[0]
|
||||||
if !element #|| element.displayed?
|
if !element #|| element.displayed?
|
||||||
assert( true, 'not found' )
|
assert( true, 'not found' )
|
||||||
|
@ -942,7 +942,7 @@ wait untill text in selector disabppears
|
||||||
end
|
end
|
||||||
|
|
||||||
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
||||||
(1..12).each {|loop|
|
(1..12).each {
|
||||||
element = instance.find_elements( { css: 'body' } )[0]
|
element = instance.find_elements( { css: 'body' } )[0]
|
||||||
text = element.text
|
text = element.text
|
||||||
if text =~ /#{Regexp.quote(data[:name])}/
|
if text =~ /#{Regexp.quote(data[:name])}/
|
||||||
|
@ -1063,7 +1063,7 @@ wait untill text in selector disabppears
|
||||||
#instance.execute_script( '$(".content.active .newTicket form").submit();' )
|
#instance.execute_script( '$(".content.active .newTicket form").submit();' )
|
||||||
instance.find_elements( { css: '.active .newTicket button.submit' } )[0].click
|
instance.find_elements( { css: '.active .newTicket button.submit' } )[0].click
|
||||||
sleep 1
|
sleep 1
|
||||||
(1..10).each {|loop|
|
(1..10).each {
|
||||||
if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
|
if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
|
||||||
assert( true, 'ticket created' )
|
assert( true, 'ticket created' )
|
||||||
sleep 2.5
|
sleep 2.5
|
||||||
|
@ -1220,7 +1220,7 @@ wait untill text in selector disabppears
|
||||||
|
|
||||||
if data[:state] || data[:group] || data[:body]
|
if data[:state] || data[:group] || data[:body]
|
||||||
found = nil
|
found = nil
|
||||||
(1..5).each {|loop|
|
(1..5).each {
|
||||||
if !found
|
if !found
|
||||||
begin
|
begin
|
||||||
text = instance.find_elements( { css: '.content.active .js-reset' } )[0].text
|
text = instance.find_elements( { css: '.content.active .js-reset' } )[0].text
|
||||||
|
@ -1246,7 +1246,7 @@ wait untill text in selector disabppears
|
||||||
|
|
||||||
instance.find_elements( { css: '.content.active button.js-submit' } )[0].click
|
instance.find_elements( { css: '.content.active button.js-submit' } )[0].click
|
||||||
|
|
||||||
(1..10).each {|loop|
|
(1..10).each {
|
||||||
begin
|
begin
|
||||||
text = instance.find_elements( { css: '.content.active .js-reset' } )[0].text
|
text = instance.find_elements( { css: '.content.active .js-reset' } )[0].text
|
||||||
if !text || text.empty?
|
if !text || text.empty?
|
||||||
|
@ -1408,7 +1408,7 @@ wait untill text in selector disabppears
|
||||||
#puts url.inspect
|
#puts url.inspect
|
||||||
#puts element.inspect
|
#puts element.inspect
|
||||||
}
|
}
|
||||||
overviews.each {|url, value|
|
overviews.each {|url, _value|
|
||||||
count = instance.find_elements( { css: ".content.active .sidebar a[href=\"#{url}\"] .badge" } )[0].text
|
count = instance.find_elements( { css: ".content.active .sidebar a[href=\"#{url}\"] .badge" } )[0].text
|
||||||
overviews[url] = count.to_i
|
overviews[url] = count.to_i
|
||||||
}
|
}
|
||||||
|
@ -1576,7 +1576,7 @@ wait untill text in selector disabppears
|
||||||
element.clear
|
element.clear
|
||||||
element.send_keys( data[:first_response_time] )
|
element.send_keys( data[:first_response_time] )
|
||||||
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
||||||
(1..8).each {|loop|
|
(1..8).each {
|
||||||
element = instance.find_elements( { css: 'body' } )[0]
|
element = instance.find_elements( { css: 'body' } )[0]
|
||||||
text = element.text
|
text = element.text
|
||||||
if text =~ /#{Regexp.quote(data[:name])}/
|
if text =~ /#{Regexp.quote(data[:name])}/
|
||||||
|
@ -1623,7 +1623,7 @@ wait untill text in selector disabppears
|
||||||
element.clear
|
element.clear
|
||||||
element.send_keys( data[:content] )
|
element.send_keys( data[:content] )
|
||||||
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
||||||
(1..8).each {|loop|
|
(1..8).each {
|
||||||
element = instance.find_elements( { css: 'body' } )[0]
|
element = instance.find_elements( { css: 'body' } )[0]
|
||||||
text = element.text
|
text = element.text
|
||||||
if text =~ /#{Regexp.quote(data[:name])}/
|
if text =~ /#{Regexp.quote(data[:name])}/
|
||||||
|
@ -1667,7 +1667,7 @@ wait untill text in selector disabppears
|
||||||
element.clear
|
element.clear
|
||||||
element.send_keys( data[:body] )
|
element.send_keys( data[:body] )
|
||||||
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
||||||
(1..12).each {|loop|
|
(1..12).each {
|
||||||
element = instance.find_elements( { css: 'body' } )[0]
|
element = instance.find_elements( { css: 'body' } )[0]
|
||||||
text = element.text
|
text = element.text
|
||||||
if text =~ /#{Regexp.quote(data[:name])}/
|
if text =~ /#{Regexp.quote(data[:name])}/
|
||||||
|
@ -1719,7 +1719,7 @@ wait untill text in selector disabppears
|
||||||
dropdown.select_by( :text, data[:signature])
|
dropdown.select_by( :text, data[:signature])
|
||||||
end
|
end
|
||||||
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
||||||
(1..12).each {|loop|
|
(1..12).each {
|
||||||
element = instance.find_elements( { css: 'body' } )[0]
|
element = instance.find_elements( { css: 'body' } )[0]
|
||||||
text = element.text
|
text = element.text
|
||||||
if text =~ /#{Regexp.quote(data[:name])}/
|
if text =~ /#{Regexp.quote(data[:name])}/
|
||||||
|
|
|
@ -30,9 +30,7 @@ class TwitterTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# add channel
|
# add channel
|
||||||
current = Channel.where( adapter: 'Twitter2' )
|
current = Channel.where( adapter: 'Twitter2' )
|
||||||
current.each {|r|
|
current.each(&:destroy)
|
||||||
r.destroy
|
|
||||||
}
|
|
||||||
Channel.create(
|
Channel.create(
|
||||||
adapter: 'Twitter2',
|
adapter: 'Twitter2',
|
||||||
area: 'Twitter::Inbound',
|
area: 'Twitter::Inbound',
|
||||||
|
@ -165,7 +163,7 @@ class TwitterTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# fetch check system account
|
# fetch check system account
|
||||||
article = nil
|
article = nil
|
||||||
(1..4).each {|loop|
|
(1..4).each {
|
||||||
next if article
|
next if article
|
||||||
sleep 25
|
sleep 25
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class ActiveSupport::TestCase
|
||||||
return if Delayed::Job.all.empty?
|
return if Delayed::Job.all.empty?
|
||||||
|
|
||||||
Delayed::Job.where('failed_at != NULL').each {|job|
|
Delayed::Job.where('failed_at != NULL').each {|job|
|
||||||
assert( false, "not processable job #{jobs.inspect}" )
|
assert( false, "not processable job #{job.inspect}" )
|
||||||
}
|
}
|
||||||
Delayed::Job.all.destroy_all
|
Delayed::Job.all.destroy_all
|
||||||
end
|
end
|
||||||
|
|
|
@ -300,7 +300,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
if message['event'] == 'resetCollection'
|
if message['event'] == 'resetCollection'
|
||||||
#puts "rc: "
|
#puts "rc: "
|
||||||
if message['data']
|
if message['data']
|
||||||
message['data'].each {|key, value|
|
message['data'].each {|key, _value|
|
||||||
#puts "rc: #{key}"
|
#puts "rc: #{key}"
|
||||||
collections_result[key] = true
|
collections_result[key] = true
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
#puts "c: #{collections_result.inspect}"
|
#puts "c: #{collections_result.inspect}"
|
||||||
collections_orig.each {|key, value|
|
collections_orig.each {|key, _value|
|
||||||
assert_equal( collections_orig[key], collections_result[key], "collection message for #{key} #{type}-check (client_id #{client_id})" )
|
assert_equal( collections_orig[key], collections_result[key], "collection message for #{key} #{type}-check (client_id #{client_id})" )
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue