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:
parent
e9bbff97a9
commit
866c31587e
5 changed files with 28 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
||||||
class Sessions::Backend::ActivityStream
|
class Sessions::Backend::ActivityStream
|
||||||
|
|
||||||
|
attr_writer :user
|
||||||
|
|
||||||
def initialize(user, asset_lookup, client = nil, client_id = nil, ttl = 25)
|
def initialize(user, asset_lookup, client = nil, client_id = nil, ttl = 25)
|
||||||
@user = user
|
@user = user
|
||||||
@client = client
|
@client = client
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
class Sessions::Backend::Base
|
class Sessions::Backend::Base
|
||||||
|
|
||||||
|
attr_writer :user
|
||||||
|
|
||||||
def initialize(user, asset_lookup, client, client_id, ttl = 10)
|
def initialize(user, asset_lookup, client, client_id, ttl = 10)
|
||||||
@user = user
|
@user = user
|
||||||
@client = client
|
@client = client
|
||||||
|
|
|
@ -22,6 +22,15 @@ class Sessions::Backend::Collections < Sessions::Backend::Base
|
||||||
results
|
results
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user=(user)
|
||||||
|
@user = user
|
||||||
|
|
||||||
|
# update stored user in backends, too
|
||||||
|
@backends.each do |backend|
|
||||||
|
backend.user = user
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def backend
|
def backend
|
||||||
|
|
||||||
# auto population collections
|
# auto population collections
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
class Sessions::Backend::Collections::Base < Sessions::Backend::Base
|
class Sessions::Backend::Collections::Base < Sessions::Backend::Base
|
||||||
class << self; attr_accessor :model, :permissions end
|
class << self; attr_accessor :model, :permissions end
|
||||||
|
|
||||||
|
attr_writer :user
|
||||||
|
|
||||||
def initialize(user, asset_lookup, client, client_id, ttl)
|
def initialize(user, asset_lookup, client, client_id, ttl)
|
||||||
@user = user
|
@user = user
|
||||||
@client = client
|
@client = client
|
||||||
|
|
|
@ -17,10 +17,11 @@ class Sessions::Client
|
||||||
'Sessions::Backend::TicketCreate',
|
'Sessions::Backend::TicketCreate',
|
||||||
]
|
]
|
||||||
|
|
||||||
asset_lookup = {}
|
asset_lookup = {}
|
||||||
backend_pool = []
|
backend_pool = []
|
||||||
user_id_last_run = nil
|
user_id_last_run = nil
|
||||||
loop_count = 0
|
user_updated_at_last_run = nil
|
||||||
|
loop_count = 0
|
||||||
loop do
|
loop do
|
||||||
|
|
||||||
# check if session still exists
|
# check if session still exists
|
||||||
|
@ -50,6 +51,14 @@ class Sessions::Client
|
||||||
item = backend.constantize.new(user, asset_lookup, self, @client_id)
|
item = backend.constantize.new(user, asset_lookup, self, @client_id)
|
||||||
backend_pool.push item
|
backend_pool.push item
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
loop_count += 1
|
loop_count += 1
|
||||||
|
|
Loading…
Reference in a new issue