* try out chat blast with no inactivity. fix 5 instrument validation pain

This commit is contained in:
Seth Call 2016-02-08 06:56:54 -06:00
parent 853d359a7e
commit 2e81bafb01
9 changed files with 47 additions and 26 deletions

View File

@ -2,11 +2,14 @@ module JamRuby
class BaseManager
attr_accessor :pg_conn
@@in_websocket_gateway = Rails.env != 'test' && Object.const_defined?("JamRuby::UserManager") == false
def initialize(options={})
@log = Logging.logger[self]
@pg_conn = options[:conn]
unless PG.threadsafe?
raise Exception, "a non-threadsafe build of libpq is present."
end
@ -22,12 +25,19 @@ module JamRuby
# across Rails ActiveRecord and the pg-gem based code in ConnectionManager.
manager.pg_conn = connection.instance_variable_get("@connection")
begin
if @@in_websocket_gateway
# it only necessary to catch exceptions in websocket-gateway, which has only one AR connection and does not clean it up like a Rails context does
begin
connection.transaction do
yield manager
end
rescue Exception => e
ActiveRecord::Base.connection.execute('ROLLBACK')
end
else
connection.transaction do
yield manager
end
rescue Exception => e
ActiveRecord::Base.connection.execute('ROLLBACK')
end
end
end

View File

@ -41,7 +41,7 @@ module JamRuby
attr_accessible :first_name, :last_name, :email, :city, :password, :password_confirmation, :state, :country, :birth_date, :subscribe_email, :terms_of_service, :original_fpfile, :cropped_fpfile, :cropped_large_fpfile, :cropped_s3_path, :cropped_large_s3_path, :photo_url, :large_photo_url, :crop_selection
# updating_password corresponds to a lost_password
attr_accessor :updating_password, :updating_email, :updated_email, :update_email_confirmation_url, :administratively_created, :current_password, :setting_password, :confirm_current_password, :updating_avatar, :updating_progression_field, :mods_json, :expecting_gift_card
attr_accessor :validate_instruments, :updating_password, :updating_email, :updated_email, :update_email_confirmation_url, :administratively_created, :current_password, :setting_password, :confirm_current_password, :updating_avatar, :updating_progression_field, :mods_json, :expecting_gift_card
belongs_to :icecast_server_group, class_name: "JamRuby::IcecastServerGroup", inverse_of: :users, foreign_key: 'icecast_server_group_id'
@ -226,7 +226,7 @@ module JamRuby
validates_numericality_of :paid_sessions_daily_rate, greater_than: 0, less_than: 5000000, :if => :paid_sessions
# custom validators
validate :validate_musician_instruments
validate :validate_musician_instruments, if: :validate_instruments
validate :validate_current_password
validate :validate_update_email
validate :validate_avatar_info
@ -1068,7 +1068,7 @@ module JamRuby
gift_card = options[:gift_card]
user = User.new
user.validate_instruments = true
UserManager.active_record_transaction do |user_manager|
user.first_name = first_name
user.last_name = last_name
@ -1441,7 +1441,7 @@ module JamRuby
# there are plenty of confirmed users with nil signup_tokens, so we can't look on it
raise ActiveRecord::RecordNotFound
else
UserManager.active_record_transaction do |user_manager|
User.transaction do
# throws ActiveRecord::RecordNotFound if invalid
user = User.find_by_signup_token!(signup_token)
user.signup_confirm

View File

@ -24,19 +24,21 @@ SessionStore = context.SessionStore
@fetchHistory()
onUserActivityChanged: (state) ->
systemMsg = {}
@systemMsgId = @systemMsgId + 1
systemMsg.sender_name = 'System'
systemMsg.sender_id = 'system'
systemMsg.msg_id = @systemMsgId
systemMsg.created_at = new Date().toISOString()
systemMsg.channel = 'global'
if state.active
systemMsg.msg = "You've come back!"
else
systemMsg.msg = "You've become inactive. Any global chat messages while away will be missed."
@onMsgReceived(systemMsg)
if !gon.chat_blast
systemMsg = {}
@systemMsgId = @systemMsgId + 1
systemMsg.sender_name = 'System'
systemMsg.sender_id = 'system'
systemMsg.msg_id = @systemMsgId
systemMsg.created_at = new Date().toISOString()
systemMsg.channel = 'global'
if state.active
systemMsg.msg = "You've come back!"
else
systemMsg.msg = "You've become inactive. Any global chat messages while away will be missed."
@onMsgReceived(systemMsg)
# after the animation to open the chat panel is done, do it!
onFullyOpened: () ->

View File

@ -71,6 +71,7 @@ module ClientHelper
gon.band_search_meta = BandSearch.search_filter_meta
gon.session_stat_thresholds = Rails.application.config.session_stat_thresholds
gon.midi_enabled = Rails.application.config.midi_enabled
gon.chat_blast = Rails.application.config.chat_blast
# is this the native client or browser?
@nativeClient = is_native_client?

View File

@ -417,5 +417,6 @@ if defined?(Bundler)
config.check_bounced_emails = false
config.ban_jamtrack_downloaders = true
config.chat_opened_by_default = true
config.chat_blast = true
end
end

View File

@ -60,7 +60,7 @@ Object.send(:remove_const, :Rails) # this is to 'fool' new relic into not thinki
gateway_name = ENV['GATEWAY_NAME'] || 'default'
gateway_name = "#{gateway_name}-#{jam_instance}"
Server.new.run(:port => config["port"] + (jam_instance-1 ) * 2,
Server.new.run(:port => config["port"] + (jam_instance - 1 ) * 2,
:emwebsocket_debug => config["emwebsocket_debug"],
:connect_time_stale_client => config["connect_time_stale_client"],
:connect_time_expire_client => config["connect_time_expire_client"],
@ -76,4 +76,6 @@ Server.new.run(:port => config["port"] + (jam_instance-1 ) * 2,
:influxdb_port => config['influxdb_port'],
:allow_dynamic_registration => config['allow_dynamic_registration'],
:cidr => config['cidr'],
:gateway_name => gateway_name)
:gateway_name => gateway_name,
:chat_enabled => config['chat_enabled'],
:chat_blast => config['chat_blast'])

View File

@ -11,6 +11,8 @@ Defaults: &defaults
influxdb_hosts: ["localhost"]
influxdb_port: 8086
allow_dynamic_registration: true
chat_enabled: true
chat_blast: true
development:
port: 6767

View File

@ -68,7 +68,8 @@ module JamWebsockets
@profile_it_sums = {}
@heartbeat_tracker = {}
@temp_ban = {}
@chat_enabled = {}
@chat_enabled = true
@chat_blast = true
@login_success_count = 0
@login_fail_count = 0
@ -81,7 +82,7 @@ module JamWebsockets
end
def start(connect_time_stale_client, connect_time_expire_client, connect_time_stale_browser, connect_time_expire_browser, options={:host => "localhost", :port => 5672, :max_connections_per_user => 10, :gateway => 'default', :allow_dynamic_registration => true, chat_enabled => true}, &block)
def start(connect_time_stale_client, connect_time_expire_client, connect_time_stale_browser, connect_time_expire_browser, options={:host => "localhost", :port => 5672, :max_connections_per_user => 10, :gateway => 'default', :allow_dynamic_registration => true, :chat_enabled => true, :chat_blast => true}, &block)
@log.info "startup"
@ -95,6 +96,7 @@ module JamWebsockets
@gateway_name = options[:gateway]
@allow_dynamic_registration = options[:allow_dynamic_registration]
@chat_enabled = options[:chat_enabled]
@chat_blast = options[:chat_blast]
# determine the maximum amount of heartbeats we should get per user
@maximum_minutely_heartbeat_rate_client = ((@heartbeat_interval_client / 60.0) * 2).ceil + 3
@ -244,7 +246,7 @@ module JamWebsockets
msg = Jampb::ClientMessage.parse(msg)
@log.debug "client-directed message received from #{msg.from} to all chat clients"
@client_lookup.each do |client_id, client_context|
if client_context.active
if @chat_blast || client_context.active
client = client_context.client
if client

View File

@ -24,6 +24,7 @@ module JamWebsockets
connect_time_expire_browser = options[:connect_time_expire_browser].to_i
max_connections_per_user = options[:max_connections_per_user].to_i
chat_enabled = options[:chat_enabled].nil? ? true : options[:chat_enabled]
chat_blast = options[:chat_blast].nil? ? true : options[:chat_blast]
gateway_name = options[:gateway_name]
rabbitmq_host = options[:rabbitmq_host]
rabbitmq_port = options[:rabbitmq_port].to_i
@ -44,7 +45,7 @@ module JamWebsockets
}
EventMachine.run do
@router.start(connect_time_stale_client, connect_time_expire_client, connect_time_stale_browser, connect_time_expire_browser, host: rabbitmq_host, port: rabbitmq_port, max_connections_per_user: max_connections_per_user, gateway: gateway_name, allow_dynamic_registration: allow_dynamic_registration, chat_enabled: chat_enabled) do
@router.start(connect_time_stale_client, connect_time_expire_client, connect_time_stale_browser, connect_time_expire_browser, host: rabbitmq_host, port: rabbitmq_port, max_connections_per_user: max_connections_per_user, gateway: gateway_name, allow_dynamic_registration: allow_dynamic_registration, chat_enabled: chat_enabled, chat_blast: chat_blast) do
start_connection_expiration
start_client_expiration
start_connection_flagger