Fixed bug: Outdated data is used for Websocket session data gathering and is send to the frontend in some cases.

This commit is contained in:
Thorsten Eckel 2018-06-29 19:04:39 +02:00
parent e9bbff97a9
commit 866c31587e
5 changed files with 28 additions and 4 deletions

View file

@ -1,5 +1,7 @@
class Sessions::Backend::ActivityStream
attr_writer :user
def initialize(user, asset_lookup, client = nil, client_id = nil, ttl = 25)
@user = user
@client = client

View file

@ -1,5 +1,7 @@
class Sessions::Backend::Base
attr_writer :user
def initialize(user, asset_lookup, client, client_id, ttl = 10)
@user = user
@client = client

View file

@ -22,6 +22,15 @@ class Sessions::Backend::Collections < Sessions::Backend::Base
results
end
def user=(user)
@user = user
# update stored user in backends, too
@backends.each do |backend|
backend.user = user
end
end
def backend
# auto population collections

View file

@ -1,6 +1,8 @@
class Sessions::Backend::Collections::Base < Sessions::Backend::Base
class << self; attr_accessor :model, :permissions end
attr_writer :user
def initialize(user, asset_lookup, client, client_id, ttl)
@user = user
@client = client

View file

@ -17,10 +17,11 @@ class Sessions::Client
'Sessions::Backend::TicketCreate',
]
asset_lookup = {}
backend_pool = []
user_id_last_run = nil
loop_count = 0
asset_lookup = {}
backend_pool = []
user_id_last_run = nil
user_updated_at_last_run = nil
loop_count = 0
loop do
# check if session still exists
@ -50,6 +51,14 @@ class Sessions::Client
item = backend.constantize.new(user, asset_lookup, self, @client_id)
backend_pool.push item
end
# update user if required
elsif user_updated_at_last_run != user.updated_at
user_updated_at_last_run = user.updated_at
log "---client - updating user #{user.id} - #{user_updated_at_last_run}"
backend_pool.each do |backend|
backend.user = user
end
end
loop_count += 1