Fixed race condition in asset generation of session "/show".

This commit is contained in:
Martin Edenhofer 2015-11-30 11:50:02 +01:00
parent 435517071b
commit 7710c1232e
8 changed files with 48 additions and 51 deletions

View file

@ -235,10 +235,6 @@ job_integration_browser_ff_3:
- browser-ff - browser-ff
script: script:
- export BROWSER_URL=http://$IP:3031 - export BROWSER_URL=http://$IP:3031
- unset MAILBOX_AUTO1
- unset MAILBOX_AUTO2
- unset MAILBOX_MANUAL1
- unset MAILBOX_MANUAL2
- script/build/test_db_config.sh production ci_zammad_browser_ff_3 - script/build/test_db_config.sh production ci_zammad_browser_ff_3
- script/build/test_db_config.sh test ci_zammad_browser_ff_3_test - script/build/test_db_config.sh test ci_zammad_browser_ff_3_test
- script/build/test_slice_tests.sh 3 - script/build/test_slice_tests.sh 3

View file

@ -61,7 +61,7 @@ class ApplicationController < ActionController::Base
def current_user def current_user
return @_current_user if @_current_user return @_current_user if @_current_user
return if !session[:user_id] return if !session[:user_id]
@_current_user = User.find( session[:user_id] ) @_current_user = User.lookup(id: session[:user_id])
end end
def current_user_set(user) def current_user_set(user)
@ -159,7 +159,7 @@ class ApplicationController < ActionController::Base
# already logged in, early exit # already logged in, early exit
if session.id && session[:user_id] if session.id && session[:user_id]
userdata = User.find(session[:user_id]) userdata = User.lookup(id: session[:user_id])
current_user_set(userdata) current_user_set(userdata)
return { return {

View file

@ -36,12 +36,13 @@ class SessionsController < ApplicationController
# log new session # log new session
user.activity_stream_log('session started', user.id, true) user.activity_stream_log('session started', user.id, true)
# auto population of default collections
collections, assets = SessionHelper.default_collections(user)
# add session user assets # add session user assets
assets = {}
assets = user.assets(assets) assets = user.assets(assets)
# auto population of default collections
collections, assets = SessionHelper.default_collections(user, assets)
# get models # get models
models = SessionHelper.models(user) models = SessionHelper.models(user)
@ -91,12 +92,13 @@ class SessionsController < ApplicationController
# log device # log device
return if !user_device_log(user, 'session') return if !user_device_log(user, 'session')
# auto population of default collections
collections, assets = SessionHelper.default_collections(user)
# add session user assets # add session user assets
assets = {}
assets = user.assets(assets) assets = user.assets(assets)
# auto population of default collections
collections, assets = SessionHelper.default_collections(user, assets)
# get models # get models
models = SessionHelper.models(user) models = SessionHelper.models(user)
@ -194,7 +196,7 @@ class SessionsController < ApplicationController
return false return false
end end
user = User.lookup( id: params[:id] ) user = User.find(params[:id])
if !user if !user
render( render(
json: {}, json: {},

View file

@ -376,7 +376,7 @@ class TicketsController < ApplicationController
user_tickets_closed_ids = [] user_tickets_closed_ids = []
user_ticket_volume_by_year = [] user_ticket_volume_by_year = []
if params[:user_id] if params[:user_id]
user = User.find( params[:user_id] ) user = User.lookup(id: params[:user_id])
condition = { condition = {
'ticket.state_id' => { 'ticket.state_id' => {
operator: 'is', operator: 'is',

View file

@ -15,7 +15,7 @@ class Chat < ApplicationModel
if chat_session.state == 'running' if chat_session.state == 'running'
user = nil user = nil
if chat_session.user_id if chat_session.user_id
chat_user = User.find(chat_session.user_id) chat_user = User.lookup(id: chat_session.user_id)
url = nil url = nil
if chat_user.image && chat_user.image != 'none' if chat_user.image && chat_user.image != 'none'
url = "#{Setting.get('http_type')}://#{Setting.get('fqdn')}/api/v1/users/image/#{chat_user.image}" url = "#{Setting.get('http_type')}://#{Setting.get('fqdn')}/api/v1/users/image/#{chat_user.image}"

View file

@ -1,9 +1,8 @@
module SessionHelper module SessionHelper
def self.default_collections(user) def self.default_collections(user, assets = {})
# auto population collections, store all here # auto population collections, store all here
default_collection = {} default_collection = {}
assets = {}
# load collections to deliver from external files # load collections to deliver from external files
dir = File.expand_path('../../', __FILE__) dir = File.expand_path('../../', __FILE__)

View file

@ -6,7 +6,7 @@ class Sessions::Event::ChatSessionClose < Sessions::Event::ChatBase
realname = 'Anonymous' realname = 'Anonymous'
if @session && @session['id'] if @session && @session['id']
realname = User.find(@session['id']).fullname realname = User.lookup(id: @session['id']).fullname
end end
# check count of participents # check count of participents

View file

@ -20,7 +20,7 @@ class Sessions::Event::ChatSessionStart < Sessions::Event::ChatBase
chat_session.save chat_session.save
# send chat_session_init to client # send chat_session_init to client
chat_user = User.find(chat_session.user_id) chat_user = User.lookup(id: chat_session.user_id)
url = nil url = nil
if chat_user.image && chat_user.image != 'none' if chat_user.image && chat_user.image != 'none'
url = "#{Setting.get('http_type')}://#{Setting.get('fqdn')}/api/v1/users/image/#{chat_user.image}" url = "#{Setting.get('http_type')}://#{Setting.get('fqdn')}/api/v1/users/image/#{chat_user.image}"