Applied rubocop cop 'Style/SpaceInsideStringInterpolation'.
This commit is contained in:
parent
f259dd3459
commit
54fd62487c
29 changed files with 74 additions and 74 deletions
|
@ -38,7 +38,7 @@ class LongPollingController < ApplicationController
|
||||||
spool = Sessions.spool_list( params['data']['timestamp'], current_user.id )
|
spool = Sessions.spool_list( params['data']['timestamp'], current_user.id )
|
||||||
spool.each { |item|
|
spool.each { |item|
|
||||||
if item[:type] == 'direct'
|
if item[:type] == 'direct'
|
||||||
log "send spool to (user_id=#{ current_user.id })", client_id
|
log "send spool to (user_id=#{current_user.id})", client_id
|
||||||
Sessions.send( client_id, item[:message] )
|
Sessions.send( client_id, item[:message] )
|
||||||
else
|
else
|
||||||
log 'send spool', client_id
|
log 'send spool', client_id
|
||||||
|
@ -159,6 +159,6 @@ class LongPollingController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def log( data, client_id = '-' )
|
def log( data, client_id = '-' )
|
||||||
logger.info "client(#{ client_id }) #{ data }"
|
logger.info "client(#{client_id}) #{data}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,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
|
||||||
render json: { items: items }
|
render json: { items: items }
|
||||||
|
|
|
@ -44,7 +44,7 @@ class TicketOverviewsController < ApplicationController
|
||||||
array: true,
|
array: true,
|
||||||
)
|
)
|
||||||
if !overview
|
if !overview
|
||||||
render json: { error: "No such view #{ params[:view] }!" }, status: :unprocessable_entity
|
render json: { error: "No such view #{params[:view]}!" }, status: :unprocessable_entity
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -524,7 +524,7 @@ class OwnModel < ApplicationModel
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
logger.debug "#{ self.class.name }.find(#{ id }) notify created " + created_at.to_s
|
logger.debug "#{self.class.name}.find(#{id}) notify created " + created_at.to_s
|
||||||
class_name = self.class.name
|
class_name = self.class.name
|
||||||
class_name.gsub!(/::/, '')
|
class_name.gsub!(/::/, '')
|
||||||
Sessions.broadcast(
|
Sessions.broadcast(
|
||||||
|
@ -553,7 +553,7 @@ class OwnModel < ApplicationModel
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
logger.debug "#{ self.class.name }.find(#{ id }) notify UPDATED " + updated_at.to_s
|
logger.debug "#{self.class.name}.find(#{id}) notify UPDATED " + updated_at.to_s
|
||||||
class_name = self.class.name
|
class_name = self.class.name
|
||||||
class_name.gsub!(/::/, '')
|
class_name.gsub!(/::/, '')
|
||||||
Sessions.broadcast(
|
Sessions.broadcast(
|
||||||
|
@ -582,7 +582,7 @@ class OwnModel < ApplicationModel
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
logger.debug "#{ self.class.name }.find(#{ id }) notify TOUCH " + updated_at.to_s
|
logger.debug "#{self.class.name}.find(#{id}) notify TOUCH " + updated_at.to_s
|
||||||
class_name = self.class.name
|
class_name = self.class.name
|
||||||
class_name.gsub!(/::/, '')
|
class_name.gsub!(/::/, '')
|
||||||
Sessions.broadcast(
|
Sessions.broadcast(
|
||||||
|
@ -610,7 +610,7 @@ class OwnModel < ApplicationModel
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
logger.debug "#{ self.class.name }.find(#{ id }) notify DESTOY " + updated_at.to_s
|
logger.debug "#{self.class.name}.find(#{id}) notify DESTOY " + updated_at.to_s
|
||||||
class_name = self.class.name
|
class_name = self.class.name
|
||||||
class_name.gsub!(/::/, '')
|
class_name.gsub!(/::/, '')
|
||||||
Sessions.broadcast(
|
Sessions.broadcast(
|
||||||
|
|
|
@ -288,7 +288,7 @@ return all avatars of an user
|
||||||
data = avatar.attributes
|
data = avatar.attributes
|
||||||
if avatar.store_resize_id
|
if avatar.store_resize_id
|
||||||
file = Store.find(avatar.store_resize_id)
|
file = Store.find(avatar.store_resize_id)
|
||||||
data['content'] = "data:#{ file.preferences['Mime-Type'] };base64,#{ Base64.strict_encode64( file.content ) }"
|
data['content'] = "data:#{file.preferences['Mime-Type']};base64,#{Base64.strict_encode64( file.content )}"
|
||||||
end
|
end
|
||||||
avatar_list.push data
|
avatar_list.push data
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,10 +19,10 @@ module Channel::Filter::Database
|
||||||
scan = mail[ key.downcase.to_sym ].scan(/#{value}/i)
|
scan = mail[ key.downcase.to_sym ].scan(/#{value}/i)
|
||||||
end
|
end
|
||||||
if match && scan[0]
|
if match && scan[0]
|
||||||
Rails.logger.info " matching #{ key.downcase }:'#{ mail[ key.downcase.to_sym ] }' on #{value}"
|
Rails.logger.info " matching #{key.downcase}:'#{mail[ key.downcase.to_sym ]}' on #{value}"
|
||||||
match = true
|
match = true
|
||||||
else
|
else
|
||||||
Rails.logger.info " is not matching #{ key.downcase }:'#{ mail[ key.downcase.to_sym ] }' on #{value}"
|
Rails.logger.info " is not matching #{key.downcase}:'#{mail[ key.downcase.to_sym ]}' on #{value}"
|
||||||
match = false
|
match = false
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
|
@ -36,7 +36,7 @@ module Channel::Filter::Database
|
||||||
next if !match
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Scheduler < ApplicationModel
|
||||||
begin
|
begin
|
||||||
ActiveRecord::Base.connection.reconnect!
|
ActiveRecord::Base.connection.reconnect!
|
||||||
rescue => e
|
rescue => e
|
||||||
logger.error "Can't reconnect to database #{ e.inspect }"
|
logger.error "Can't reconnect to database #{e.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# read/load jobs and check if it is alredy started
|
# read/load jobs and check if it is alredy started
|
||||||
|
@ -89,13 +89,13 @@ class Scheduler < ApplicationModel
|
||||||
logger.info "execute #{job.method} (try_count #{try_count})..."
|
logger.info "execute #{job.method} (try_count #{try_count})..."
|
||||||
eval job.method() # rubocop:disable Lint/Eval
|
eval job.method() # rubocop:disable Lint/Eval
|
||||||
rescue => e
|
rescue => e
|
||||||
logger.error "execute #{job.method} (try_count #{try_count}) exited with error #{ e.inspect }"
|
logger.error "execute #{job.method} (try_count #{try_count}) exited with error #{e.inspect}"
|
||||||
|
|
||||||
# reconnect in case db connection is lost
|
# reconnect in case db connection is lost
|
||||||
begin
|
begin
|
||||||
ActiveRecord::Base.connection.reconnect!
|
ActiveRecord::Base.connection.reconnect!
|
||||||
rescue => e
|
rescue => e
|
||||||
logger.error "Can't reconnect to database #{ e.inspect }"
|
logger.error "Can't reconnect to database #{e.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
try_run_max = 10
|
try_run_max = 10
|
||||||
|
|
|
@ -142,7 +142,7 @@ returns
|
||||||
def content
|
def content
|
||||||
file = Store::File.find_by( id: store_file_id )
|
file = Store::File.find_by( id: store_file_id )
|
||||||
if !file
|
if !file
|
||||||
fail "No such file #{ store_file_id }!"
|
fail "No such file #{store_file_id}!"
|
||||||
end
|
end
|
||||||
file.content
|
file.content
|
||||||
end
|
end
|
||||||
|
@ -150,7 +150,7 @@ returns
|
||||||
def provider
|
def provider
|
||||||
file = Store::File.find_by( id: store_file_id )
|
file = Store::File.find_by( id: store_file_id )
|
||||||
if !file
|
if !file
|
||||||
fail "No such file #{ store_file_id }!"
|
fail "No such file #{store_file_id}!"
|
||||||
end
|
end
|
||||||
file.provider
|
file.provider
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Store
|
||||||
if !adapter_name
|
if !adapter_name
|
||||||
fail 'Missing storage_provider setting option'
|
fail 'Missing storage_provider setting option'
|
||||||
end
|
end
|
||||||
adapter = load_adapter( "Store::Provider::#{ adapter_name }" )
|
adapter = load_adapter( "Store::Provider::#{adapter_name}" )
|
||||||
adapter.add( data, sha )
|
adapter.add( data, sha )
|
||||||
file = Store::File.create(
|
file = Store::File.create(
|
||||||
provider: adapter_name,
|
provider: adapter_name,
|
||||||
|
@ -29,7 +29,7 @@ class Store
|
||||||
|
|
||||||
# read content
|
# read content
|
||||||
def content
|
def content
|
||||||
adapter = self.class.load_adapter("Store::Provider::#{ provider }")
|
adapter = self.class.load_adapter("Store::Provider::#{provider}")
|
||||||
if sha
|
if sha
|
||||||
c = adapter.get( sha )
|
c = adapter.get( sha )
|
||||||
else
|
else
|
||||||
|
@ -62,8 +62,8 @@ class Store
|
||||||
# e. g. Store::File.move('File', 'DB')
|
# e. g. Store::File.move('File', 'DB')
|
||||||
# e. g. Store::File.move('DB', 'File')
|
# e. g. Store::File.move('DB', 'File')
|
||||||
def self.move(source, target)
|
def self.move(source, target)
|
||||||
adapter_source = load_adapter("Store::Provider::#{ source }")
|
adapter_source = load_adapter("Store::Provider::#{source}")
|
||||||
adapter_target = load_adapter("Store::Provider::#{ target }")
|
adapter_target = load_adapter("Store::Provider::#{target}")
|
||||||
|
|
||||||
Store::File.all.each {|item|
|
Store::File.all.each {|item|
|
||||||
next if item.provider == target
|
next if item.provider == target
|
||||||
|
@ -86,7 +86,7 @@ class Store
|
||||||
private
|
private
|
||||||
|
|
||||||
def destroy_provider
|
def destroy_provider
|
||||||
adapter = self.class.load_adapter("Store::Provider::#{ provider }")
|
adapter = self.class.load_adapter("Store::Provider::#{provider}")
|
||||||
adapter.delete( sha )
|
adapter.delete( sha )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Store::Provider::File
|
||||||
# install file
|
# install file
|
||||||
permission = '600'
|
permission = '600'
|
||||||
if !File.exist?( get_locaton(sha) )
|
if !File.exist?( get_locaton(sha) )
|
||||||
Rails.logger.debug "storge write '#{ get_locaton(sha) }' (#{permission})"
|
Rails.logger.debug "storge write '#{get_locaton(sha)}' (#{permission})"
|
||||||
file = File.new( get_locaton(sha), 'wb' )
|
file = File.new( get_locaton(sha), 'wb' )
|
||||||
file.write( data )
|
file.write( data )
|
||||||
file.close
|
file.close
|
||||||
|
@ -19,7 +19,7 @@ class Store::Provider::File
|
||||||
# check sha
|
# check sha
|
||||||
local_sha = Digest::SHA256.hexdigest( get(sha) )
|
local_sha = Digest::SHA256.hexdigest( get(sha) )
|
||||||
if sha != local_sha
|
if sha != local_sha
|
||||||
fail "ERROR: Corrupt file in fs #{ get_locaton(sha) }, sha should be #{sha} but is #{local_sha}"
|
fail "ERROR: Corrupt file in fs #{get_locaton(sha)}, sha should be #{sha} but is #{local_sha}"
|
||||||
end
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -27,9 +27,9 @@ class Store::Provider::File
|
||||||
|
|
||||||
# read file from fs
|
# read file from fs
|
||||||
def self.get(sha)
|
def self.get(sha)
|
||||||
Rails.logger.debug "read from fs #{ get_locaton(sha) }"
|
Rails.logger.debug "read from fs #{get_locaton(sha)}"
|
||||||
if !File.exist?( get_locaton(sha) )
|
if !File.exist?( get_locaton(sha) )
|
||||||
fail "ERROR: No such file #{ get_locaton(sha) }"
|
fail "ERROR: No such file #{get_locaton(sha)}"
|
||||||
end
|
end
|
||||||
data = File.open( get_locaton(sha), 'rb' )
|
data = File.open( get_locaton(sha), 'rb' )
|
||||||
content = data.read
|
content = data.read
|
||||||
|
@ -37,7 +37,7 @@ class Store::Provider::File
|
||||||
# check sha
|
# check sha
|
||||||
local_sha = Digest::SHA256.hexdigest( content )
|
local_sha = Digest::SHA256.hexdigest( content )
|
||||||
if local_sha != sha
|
if local_sha != sha
|
||||||
fail "ERROR: Corrupt file in fs #{ get_locaton(sha) }, sha should be #{sha} but is #{local_sha}"
|
fail "ERROR: Corrupt file in fs #{get_locaton(sha)}, sha should be #{sha} but is #{local_sha}"
|
||||||
end
|
end
|
||||||
content
|
content
|
||||||
end
|
end
|
||||||
|
@ -45,7 +45,7 @@ class Store::Provider::File
|
||||||
# unlink file from fs
|
# unlink file from fs
|
||||||
def self.delete(sha)
|
def self.delete(sha)
|
||||||
if File.exist?( get_locaton(sha) )
|
if File.exist?( get_locaton(sha) )
|
||||||
Rails.logger.info "storge remove '#{ get_locaton(sha) }'"
|
Rails.logger.info "storge remove '#{get_locaton(sha)}'"
|
||||||
File.delete( get_locaton(sha) )
|
File.delete( get_locaton(sha) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -88,7 +88,7 @@ returns
|
||||||
}
|
}
|
||||||
|
|
||||||
if data[:view] && !overview_selected
|
if data[:view] && !overview_selected
|
||||||
fail "No such view '#{ data[:view] }'"
|
fail "No such view '#{data[:view]}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
# sortby
|
# sortby
|
||||||
|
|
|
@ -17,7 +17,7 @@ returns
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def search_index_data
|
def search_index_data
|
||||||
attributes = { 'fullname' => "#{ self['firstname'] } #{ self['lastname'] }" }
|
attributes = { 'fullname' => "#{self['firstname']} #{self['lastname']}" }
|
||||||
%w(login firstname lastname phone email address city country note created_at).each { |key|
|
%w(login firstname lastname phone email address city country note created_at).each { |key|
|
||||||
if self[key] && (!self.respond_to?('empty?') || !self[key].empty?)
|
if self[key] && (!self.respond_to?('empty?') || !self[key].empty?)
|
||||||
attributes[key] = self[key]
|
attributes[key] = self[key]
|
||||||
|
|
|
@ -57,7 +57,7 @@ class String
|
||||||
return if ActiveRecord::Base.connection_config[:adapter] != 'mysql2'
|
return if ActiveRecord::Base.connection_config[:adapter] != 'mysql2'
|
||||||
each_char.select {|c|
|
each_char.select {|c|
|
||||||
if c.bytes.count > 3
|
if c.bytes.count > 3
|
||||||
Rails.logger.warn "strip out 4 bytes utf8 chars '#{c}' of '#{ self }'"
|
Rails.logger.warn "strip out 4 bytes utf8 chars '#{c}' of '#{self}'"
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
c
|
c
|
||||||
|
|
|
@ -295,7 +295,7 @@ returns
|
||||||
|
|
||||||
def self.send( client_id, data )
|
def self.send( client_id, data )
|
||||||
path = "#{@path}/#{client_id}/"
|
path = "#{@path}/#{client_id}/"
|
||||||
filename = "send-#{ Time.now.utc.to_f }"
|
filename = "send-#{Time.now.utc.to_f}"
|
||||||
check = true
|
check = true
|
||||||
count = 0
|
count = 0
|
||||||
while check
|
while check
|
||||||
|
@ -458,7 +458,7 @@ returns
|
||||||
begin
|
begin
|
||||||
message_parsed = JSON.parse( spool['msg'] )
|
message_parsed = JSON.parse( spool['msg'] )
|
||||||
rescue => e
|
rescue => e
|
||||||
log('error', "can't parse spool message: #{ message }, #{ e.inspect }")
|
log('error', "can't parse spool message: #{message}, #{e.inspect}")
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -579,13 +579,13 @@ returns
|
||||||
begin
|
begin
|
||||||
Sessions::Client.new(client_id)
|
Sessions::Client.new(client_id)
|
||||||
rescue => e
|
rescue => e
|
||||||
log('error', "thread_client #{client_id} exited with error #{ e.inspect }")
|
log('error', "thread_client #{client_id} exited with error #{e.inspect}")
|
||||||
log('error', e.backtrace.join("\n ") )
|
log('error', e.backtrace.join("\n ") )
|
||||||
sleep 10
|
sleep 10
|
||||||
begin
|
begin
|
||||||
ActiveRecord::Base.connection_pool.release_connection
|
ActiveRecord::Base.connection_pool.release_connection
|
||||||
rescue => e
|
rescue => e
|
||||||
log('error', "Can't reconnect to database #{ e.inspect }")
|
log('error', "Can't reconnect to database #{e.inspect}")
|
||||||
end
|
end
|
||||||
|
|
||||||
try_run_max = 10
|
try_run_max = 10
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Sessions::Backend::ActivityStream
|
||||||
end
|
end
|
||||||
|
|
||||||
def client_key
|
def client_key
|
||||||
"as::load::#{ self.class }::#{ @user.id }::#{ @client_id }"
|
"as::load::#{self.class}::#{@user.id}::#{@client_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def push
|
def push
|
||||||
|
@ -53,7 +53,7 @@ class Sessions::Backend::ActivityStream
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@client.log "push activity_stream #{ data.first.class } for user #{ @user.id }"
|
@client.log "push activity_stream #{data.first.class} for user #{@user.id}"
|
||||||
@client.send(
|
@client.send(
|
||||||
event: 'activity_stream_rebuild',
|
event: 'activity_stream_rebuild',
|
||||||
collection: 'activity_stream',
|
collection: 'activity_stream',
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Sessions::Backend::Collections::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def client_key
|
def client_key
|
||||||
"collections::load::#{ self.class }::#{ @user.id }::#{ @client_id }"
|
"collections::load::#{self.class}::#{@user.id}::#{@client_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def push
|
def push
|
||||||
|
@ -77,13 +77,13 @@ class Sessions::Backend::Collections::Base
|
||||||
assets: assets,
|
assets: assets,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@client.log "push assets for push_collection #{ items.first.class } for user #{ @user.id }"
|
@client.log "push assets for push_collection #{items.first.class} for user #{@user.id}"
|
||||||
@client.send(
|
@client.send(
|
||||||
data: assets,
|
data: assets,
|
||||||
event: [ 'loadAssets' ],
|
event: [ 'loadAssets' ],
|
||||||
)
|
)
|
||||||
|
|
||||||
@client.log "push push_collection #{ items.first.class } for user #{ @user.id }"
|
@client.log "push push_collection #{items.first.class} for user #{@user.id}"
|
||||||
@client.send(
|
@client.send(
|
||||||
event: 'resetCollection',
|
event: 'resetCollection',
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Sessions::Backend::Rss
|
||||||
end
|
end
|
||||||
|
|
||||||
def collection_key
|
def collection_key
|
||||||
"rss::load::#{ self.class }::#{ @user.id }"
|
"rss::load::#{self.class}::#{@user.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def load
|
def load
|
||||||
|
@ -29,7 +29,7 @@ class Sessions::Backend::Rss
|
||||||
end
|
end
|
||||||
|
|
||||||
def client_key
|
def client_key
|
||||||
"rss::load::#{ self.class }::#{ @user.id }::#{ @client_id }"
|
"rss::load::#{self.class}::#{@user.id}::#{@client_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def push
|
def push
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Sessions::Backend::TicketCreate
|
||||||
end
|
end
|
||||||
|
|
||||||
def client_key
|
def client_key
|
||||||
"as::load::#{ self.class }::#{ @user.id }::#{ @client_id }"
|
"as::load::#{self.class}::#{@user.id}::#{@client_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def push
|
def push
|
||||||
|
@ -58,7 +58,7 @@ class Sessions::Backend::TicketCreate
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@client.log "push ticket_create for user #{ @user.id }"
|
@client.log "push ticket_create for user #{@user.id}"
|
||||||
@client.send(
|
@client.send(
|
||||||
collection: 'ticket_create_attributes',
|
collection: 'ticket_create_attributes',
|
||||||
data: data,
|
data: data,
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Sessions::Backend::TicketOverviewIndex
|
||||||
end
|
end
|
||||||
|
|
||||||
def client_key
|
def client_key
|
||||||
"as::load::#{ self.class }::#{ @user.id }::#{ @client_id }"
|
"as::load::#{self.class}::#{@user.id}::#{@client_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def push
|
def push
|
||||||
|
@ -56,7 +56,7 @@ class Sessions::Backend::TicketOverviewIndex
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@client.log "push overview_index for user #{ @user.id }"
|
@client.log "push overview_index for user #{@user.id}"
|
||||||
@client.send(
|
@client.send(
|
||||||
event: ['ticket_overview_index'],
|
event: ['ticket_overview_index'],
|
||||||
data: data,
|
data: data,
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Sessions::Backend::TicketOverviewList
|
||||||
end
|
end
|
||||||
|
|
||||||
def client_key
|
def client_key
|
||||||
"as::load::#{ self.class }::#{ @user.id }::#{ @client_id }"
|
"as::load::#{self.class}::#{@user.id}::#{@client_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def push
|
def push
|
||||||
|
@ -102,7 +102,7 @@ class Sessions::Backend::TicketOverviewList
|
||||||
results.push result
|
results.push result
|
||||||
else
|
else
|
||||||
|
|
||||||
@client.log "push overview_list for user #{ @user.id }"
|
@client.log "push overview_list for user #{@user.id}"
|
||||||
|
|
||||||
# send update to browser
|
# send update to browser
|
||||||
@client.send(
|
@client.send(
|
||||||
|
|
|
@ -71,6 +71,6 @@ class Sessions::Client
|
||||||
end
|
end
|
||||||
|
|
||||||
def log( msg )
|
def log( msg )
|
||||||
Rails.logger.debug "client(#{ @client_id }) #{ msg }"
|
Rails.logger.debug "client(#{@client_id}) #{msg}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -59,7 +59,7 @@ if ARGV[0] != 'start' && ARGV[0] != 'stop'
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Starting websocket server on #{ @options[:b] }:#{ @options[:p] } (secure:#{ @options[:s] },pid:#{@options[:i]})"
|
puts "Starting websocket server on #{@options[:b]}:#{@options[:p]} (secure:#{@options[:s]},pid:#{@options[:i]})"
|
||||||
#puts options.inspect
|
#puts options.inspect
|
||||||
|
|
||||||
if ARGV[0] == 'stop'
|
if ARGV[0] == 'stop'
|
||||||
|
@ -119,11 +119,11 @@ EventMachine.run {
|
||||||
ws.onmessage { |msg|
|
ws.onmessage { |msg|
|
||||||
|
|
||||||
client_id = ws.object_id.to_s
|
client_id = ws.object_id.to_s
|
||||||
log 'debug', "received: #{ msg } ", client_id
|
log 'debug', "received: #{msg} ", client_id
|
||||||
begin
|
begin
|
||||||
data = JSON.parse(msg)
|
data = JSON.parse(msg)
|
||||||
rescue => e
|
rescue => e
|
||||||
log 'error', "can't parse message: #{ msg }, #{ e.inspect }", client_id
|
log 'error', "can't parse message: #{msg}, #{e.inspect}", client_id
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ EventMachine.run {
|
||||||
|
|
||||||
# create new msg to push to client
|
# create new msg to push to client
|
||||||
if item[:type] == 'direct'
|
if item[:type] == 'direct'
|
||||||
log 'notice', "send spool to (user_id=#{ @clients[client_id][:session]['id'] })", client_id
|
log 'notice', "send spool to (user_id=#{@clients[client_id][:session]['id']})", client_id
|
||||||
websocket_send(client_id, item[:message])
|
websocket_send(client_id, item[:message])
|
||||||
else
|
else
|
||||||
log 'notice', 'send spool', client_id
|
log 'notice', 'send spool', client_id
|
||||||
|
@ -198,13 +198,13 @@ EventMachine.run {
|
||||||
# broadcast to recipient list
|
# broadcast to recipient list
|
||||||
if data['recipient']
|
if data['recipient']
|
||||||
if data['recipient'].class != Hash
|
if data['recipient'].class != Hash
|
||||||
log 'error', "recipient attribute isn't a hash '#{ data['recipient'].inspect }'"
|
log 'error', "recipient attribute isn't a hash '#{data['recipient'].inspect}'"
|
||||||
else
|
else
|
||||||
if !data['recipient'].key?('user_id')
|
if !data['recipient'].key?('user_id')
|
||||||
log 'error', "need recipient.user_id attribute '#{ data['recipient'].inspect }'"
|
log 'error', "need recipient.user_id attribute '#{data['recipient'].inspect}'"
|
||||||
else
|
else
|
||||||
if data['recipient']['user_id'].class != Array
|
if data['recipient']['user_id'].class != Array
|
||||||
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|
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ EventMachine.run {
|
||||||
EventMachine.add_periodic_timer(20) {
|
EventMachine.add_periodic_timer(20) {
|
||||||
|
|
||||||
# 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
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ EventMachine.run {
|
||||||
next if client[:meta][:type] == 'websocket'
|
next if client[:meta][:type] == 'websocket'
|
||||||
clients = clients + 1
|
clients = clients + 1
|
||||||
}
|
}
|
||||||
log 'notice', "Status: ajax clients: #{ clients }"
|
log 'notice', "Status: ajax clients: #{clients}"
|
||||||
client_list.each {|client_id, client|
|
client_list.each {|client_id, client|
|
||||||
next if client[:meta][:type] == 'websocket'
|
next if client[:meta][:type] == 'websocket'
|
||||||
log 'notice', 'working...', client_id
|
log 'notice', 'working...', client_id
|
||||||
|
@ -346,7 +346,7 @@ EventMachine.run {
|
||||||
if !@options[:v]
|
if !@options[:v]
|
||||||
return if level == 'debug'
|
return if level == 'debug'
|
||||||
end
|
end
|
||||||
puts "#{Time.now.utc.iso8601}:client(#{ client_id }) #{ data }"
|
puts "#{Time.now.utc.iso8601}:client(#{client_id}) #{data}"
|
||||||
#puts "#{Time.now.utc.iso8601}:#{ level }:client(#{ client_id }) #{ data }"
|
#puts "#{Time.now.utc.iso8601}:#{ level }:client(#{ client_id }) #{ data }"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ class AgentUserManageTest < TestCase
|
||||||
customer_user_email = 'customer-test-' + rand(999_999).to_s + '@example.com'
|
customer_user_email = 'customer-test-' + rand(999_999).to_s + '@example.com'
|
||||||
firstname = 'Customer Firstname'
|
firstname = 'Customer Firstname'
|
||||||
lastname = 'Customer Lastname'
|
lastname = 'Customer Lastname'
|
||||||
fullname = "#{ firstname } #{ lastname } <#{ customer_user_email }>"
|
fullname = "#{firstname} #{lastname} <#{customer_user_email}>"
|
||||||
|
|
||||||
@browser = browser_instance
|
@browser = browser_instance
|
||||||
login(
|
login(
|
||||||
|
|
|
@ -1095,7 +1095,7 @@ wait untill text in selector disabppears
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
screenshot( browser: instance, comment: 'ticket_create_failed' )
|
screenshot( browser: instance, comment: 'ticket_create_failed' )
|
||||||
fail "ticket creation failed, can't get zoom url (current url is '#{ instance.current_url }')"
|
fail "ticket creation failed, can't get zoom url (current url is '#{instance.current_url}')"
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
|
@ -385,7 +385,7 @@ class ActivityStreamTest < ActiveSupport::TestCase
|
||||||
assert_equal( check_item[:o_id], item['o_id'] )
|
assert_equal( check_item[:o_id], item['o_id'] )
|
||||||
else
|
else
|
||||||
if check_item[:object] == item['object'] && check_item[:type] == item['type'] && check_item[:o_id] == item['o_id']
|
if check_item[:object] == item['object'] && check_item[:type] == item['type'] && check_item[:o_id] == item['o_id']
|
||||||
assert( false, "entry should not exist #{ item['object'] }/#{ item['type'] }/#{ item['o_id'] }" )
|
assert( false, "entry should not exist #{item['object']}/#{item['type']}/#{item['o_id']}" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
@ -337,7 +337,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
#puts "--- #{onine_notifications.inspect}"
|
#puts "--- #{onine_notifications.inspect}"
|
||||||
assert( hit, "online notification exists not #{ check_item.inspect }" )
|
assert( hit, "online notification exists not #{check_item.inspect}" )
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ class StoreTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# sha check
|
# sha check
|
||||||
sha_new = Digest::SHA256.hexdigest( attachments[0].content )
|
sha_new = Digest::SHA256.hexdigest( attachments[0].content )
|
||||||
assert_equal( sha, sha_new, "check file #{ file[:filename] }")
|
assert_equal( sha, sha_new, "check file #{file[:filename]}")
|
||||||
|
|
||||||
# filename check
|
# filename check
|
||||||
assert_equal( file[:filename], attachments[0].filename )
|
assert_equal( file[:filename], attachments[0].filename )
|
||||||
|
@ -75,7 +75,7 @@ class StoreTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# sha check
|
# sha check
|
||||||
sha_new = Digest::SHA256.hexdigest( attachments[0].content )
|
sha_new = Digest::SHA256.hexdigest( attachments[0].content )
|
||||||
assert_equal( sha, sha_new, "check file #{ file[:filename] }")
|
assert_equal( sha, sha_new, "check file #{file[:filename]}")
|
||||||
|
|
||||||
# filename check
|
# filename check
|
||||||
assert_equal( file[:filename], attachments[0].filename )
|
assert_equal( file[:filename], attachments[0].filename )
|
||||||
|
@ -101,7 +101,7 @@ class StoreTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# sha check
|
# sha check
|
||||||
sha_new = Digest::SHA256.hexdigest( attachments[0].content )
|
sha_new = Digest::SHA256.hexdigest( attachments[0].content )
|
||||||
assert_equal( sha, sha_new, "check file #{ file[:filename] }")
|
assert_equal( sha, sha_new, "check file #{file[:filename]}")
|
||||||
|
|
||||||
# filename check
|
# filename check
|
||||||
assert_equal( file[:filename], attachments[0].filename )
|
assert_equal( file[:filename], attachments[0].filename )
|
||||||
|
|
|
@ -106,9 +106,9 @@ class TagTest < ActiveSupport::TestCase
|
||||||
list = Tag.tag_list( tags )
|
list = Tag.tag_list( tags )
|
||||||
test[:verify][:items].each {|key, value|
|
test[:verify][:items].each {|key, value|
|
||||||
if value == true
|
if value == true
|
||||||
assert( list.include?( key ), "Tag verify - should exists but exists #{ key }")
|
assert( list.include?( key ), "Tag verify - should exists but exists #{key}")
|
||||||
else
|
else
|
||||||
assert( !list.include?( key ), "Tag verify - exists but should not #{ key }")
|
assert( !list.include?( key ), "Tag verify - exists but should not #{key}")
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,15 +255,15 @@ class UserTest < ActiveSupport::TestCase
|
||||||
test[:create_verify].each { |key, value|
|
test[:create_verify].each { |key, value|
|
||||||
next if key == :image_md5
|
next if key == :image_md5
|
||||||
if user.respond_to?( key )
|
if user.respond_to?( key )
|
||||||
assert_equal( value, user.send(key), "create check #{ key } in (#{ test[:name] })" )
|
assert_equal( value, user.send(key), "create check #{key} in (#{test[:name]})" )
|
||||||
else
|
else
|
||||||
assert_equal( value, user[key], "create check #{ key } in (#{ test[:name] })" )
|
assert_equal( value, user[key], "create check #{key} in (#{test[:name]})" )
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
if test[:create_verify][:image_md5]
|
if test[:create_verify][:image_md5]
|
||||||
file = Avatar.get_by_hash( user.image )
|
file = Avatar.get_by_hash( user.image )
|
||||||
file_md5 = Digest::MD5.hexdigest( file.content )
|
file_md5 = Digest::MD5.hexdigest( file.content )
|
||||||
assert_equal( test[:create_verify][:image_md5], file_md5, "create avatar md5 check in (#{ test[:name] })" )
|
assert_equal( test[:create_verify][:image_md5], file_md5, "create avatar md5 check in (#{test[:name]})" )
|
||||||
end
|
end
|
||||||
if test[:update]
|
if test[:update]
|
||||||
user.update_attributes( test[:update] )
|
user.update_attributes( test[:update] )
|
||||||
|
@ -271,16 +271,16 @@ class UserTest < ActiveSupport::TestCase
|
||||||
test[:update_verify].each { |key, value|
|
test[:update_verify].each { |key, value|
|
||||||
next if key == :image_md5
|
next if key == :image_md5
|
||||||
if user.respond_to?( key )
|
if user.respond_to?( key )
|
||||||
assert_equal( value, user.send(key), "update check #{ key } in (#{ test[:name] })" )
|
assert_equal( value, user.send(key), "update check #{key} in (#{test[:name]})" )
|
||||||
else
|
else
|
||||||
assert_equal( value, user[key], "update check #{ key } in (#{ test[:name] })" )
|
assert_equal( value, user[key], "update check #{key} in (#{test[:name]})" )
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
if test[:update_verify][:image_md5]
|
if test[:update_verify][:image_md5]
|
||||||
file = Avatar.get_by_hash( user.image )
|
file = Avatar.get_by_hash( user.image )
|
||||||
file_md5 = Digest::MD5.hexdigest( file.content )
|
file_md5 = Digest::MD5.hexdigest( file.content )
|
||||||
assert_equal( test[:update_verify][:image_md5], file_md5, "update avatar md5 check in (#{ test[:name] })" )
|
assert_equal( test[:update_verify][:image_md5], file_md5, "update avatar md5 check in (#{test[:name]})" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue