Only use spool messages for authenticated users.
This commit is contained in:
parent
0dad3bbcf3
commit
c986db8b37
2 changed files with 26 additions and 22 deletions
|
@ -33,6 +33,7 @@ class LongPollingController < ApplicationController
|
||||||
if params['data']['action'] == 'spool'
|
if params['data']['action'] == 'spool'
|
||||||
log 'notice', "request spool data", client_id
|
log 'notice', "request spool data", client_id
|
||||||
|
|
||||||
|
if current_user
|
||||||
spool = Session.spool_list( params['data']['timestamp'], current_user.id )
|
spool = Session.spool_list( params['data']['timestamp'], current_user.id )
|
||||||
spool.each { |item|
|
spool.each { |item|
|
||||||
if item[:type] == 'direct'
|
if item[:type] == 'direct'
|
||||||
|
@ -43,6 +44,7 @@ class LongPollingController < ApplicationController
|
||||||
Session.send( client_id, item[:message]['data'] )
|
Session.send( client_id, item[:message]['data'] )
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
# send spool:sent event to client
|
# send spool:sent event to client
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
|
|
|
@ -139,6 +139,7 @@ EventMachine.run {
|
||||||
if data['action'] == 'spool'
|
if data['action'] == 'spool'
|
||||||
log 'notice', "request spool data", client_id
|
log 'notice', "request spool data", client_id
|
||||||
|
|
||||||
|
if @clients[client_id][:session]['id']
|
||||||
spool = Session.spool_list( data['timestamp'], @clients[client_id][:session]['id'] )
|
spool = Session.spool_list( data['timestamp'], @clients[client_id][:session]['id'] )
|
||||||
spool.each { |item|
|
spool.each { |item|
|
||||||
|
|
||||||
|
@ -153,6 +154,7 @@ EventMachine.run {
|
||||||
@clients[client_id][:websocket].send( "[#{ msg }]" )
|
@clients[client_id][:websocket].send( "[#{ msg }]" )
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
# send spool:sent event to client
|
# send spool:sent event to client
|
||||||
log 'notice', "send spool:sent event", client_id
|
log 'notice', "send spool:sent event", client_id
|
||||||
|
|
Loading…
Reference in a new issue