conflict merge

This commit is contained in:
Jonathan Kolyer 2014-01-29 23:05:09 -06:00
commit c22331c010
145 changed files with 2544 additions and 1105 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
.idea
*~
*.swp
HTML
HTML
.DS_Store

View File

@ -11,6 +11,7 @@ else
gem 'jam_db', "0.1.#{ENV["BUILD_NUMBER"]}"
gem 'jampb', "0.1.#{ENV["BUILD_NUMBER"]}"
gem 'jam_ruby', "0.1.#{ENV["BUILD_NUMBER"]}"
ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] ||= "true"
end
gem 'rails'

View File

@ -92,3 +92,6 @@ mixes_drop_manifest_add_retry.sql
music_sessions_unlogged.sql
integrate_icecast_into_sessions.sql
invited_users_facebook_support.sql
ms_recording_anonymous_likes.sql
ms_user_history_add_instruments.sql
icecast_config_changed.sql

View File

@ -0,0 +1,2 @@
-- track when config_changed is set to 0, so that we know roughly which music_sessions (mounts) are valid
ALTER TABLE icecast_servers ADD COLUMN config_updated_at TIMESTAMP;

View File

@ -0,0 +1,23 @@
alter table music_sessions_comments
add column ip_address inet;
alter table music_sessions_likers
add column ip_address inet;
alter table music_sessions_likers
alter column liker_id drop not null;
alter table recordings_comments
add column ip_address inet;
alter table recordings_likers
add column ip_address inet;
alter table recordings_likers
alter column liker_id drop not null;
alter table recordings_plays
add column ip_address inet;
alter table recordings_plays
alter column player_id drop not null;

View File

@ -0,0 +1 @@
alter table music_sessions_user_history add column instruments varchar(255);

View File

@ -6,4 +6,4 @@ ON UPDATE NO ACTION ON DELETE CASCADE;
alter table music_sessions_likers drop constraint music_sessions_likers_music_session_id_fkey;
alter table music_sessions_likers add constraint ms_likers_ms_history_fkey foreign key (music_session_id)
references music_sessions_history(music_session_id) match simple
ON UPDATE NO ACTION ON DELETE CASCADE;
ON UPDATE NO ACTION ON DELETE CASCADE;

View File

@ -109,7 +109,6 @@ message ClientMessage {
optional SessionJoin session_join = 190;
optional SessionDepart session_depart = 195;
optional MusicianSessionJoin musician_session_join = 196;
optional BandSessionJoin band_session_join = 197;
// recording notifications
optional MusicianRecordingSaved musician_recording_saved = 200;

View File

@ -6,6 +6,15 @@ end
devenv = ENV["BUILD_NUMBER"].nil? # Jenkins sets a build number environment variable
if devenv
gem 'jam_db', :path=> "../db/target/ruby_package"
gem 'jampb', :path => "../pb/target/ruby/jampb"
else
gem 'jam_db'
gem 'jampb'
ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] ||= "true"
end
gem 'pg', '0.15.1', :platform => [:mri, :mswin, :mingw]
gem 'jdbc_postgres', :platform => [:jruby]
@ -33,13 +42,7 @@ gem 'resque-lonely_job', '~> 1.0.0'
gem 'oj'
gem 'builder'
if devenv
gem 'jam_db', :path=> "../db/target/ruby_package"
gem 'jampb', :path => "../pb/target/ruby/jampb"
else
gem 'jam_db'
gem 'jampb'
end
group :test do
gem "factory_girl", '4.1.0'

View File

@ -311,7 +311,7 @@ SQL
else
blk.call(db_conn, connection) unless blk.nil?
user.update_progression_field(:first_music_session_at)
MusicSessionUserHistory.save(music_session_id, user_id, client_id)
MusicSessionUserHistory.save(music_session_id, user_id, client_id, tracks)
end
end

View File

@ -18,7 +18,7 @@ module JamWebEventMachine
# After the supplied block is done,
# waits until all EM tasks scheduled in the supplied block are done, or timeout
def self.run_wait_stop(timeout = 30, &blk)
JamWebEventMachine.start
JamWebEventMachine.run
thread = Thread.current
@ -62,6 +62,12 @@ module JamWebEventMachine
Signal.trap("TERM") { EM.stop }
end
def self.run
Thread.new do
run_em
end
end
def self.start
if defined?(PhusionPassenger)
@@log.debug("PhusionPassenger detected")
@ -85,9 +91,7 @@ module JamWebEventMachine
Thread.abort_on_exception = true
# create a new thread separate from the Rails main thread that EventMachine can run on
Thread.new do
run_em
end
run
end
end
end

View File

@ -62,6 +62,20 @@ module JamRuby
return self.music_sessions.size
end
def recent_history
recordings = ClaimedRecording.joins(:recordings)
.where(:recordings => {:band_id => "#{self.id}"})
.order('created_at DESC')
.limit(10)
msh = MusicSessionHistory.where(:band_id => self.id)
.order('created_at DESC')
.limit(10)
recordings.concat(msh)
recordings.sort! {|a,b| b.created_at <=> a.created_at}.first(5)
end
def location
loc = self.city.blank? ? '' : self.city
loc = loc.blank? ? self.state : "#{loc}, #{self.state}" unless self.state.blank?

View File

@ -191,10 +191,10 @@ module JamRuby
end
def get_media_url
raise "Unassociated server to mount" if self.server_mount.nil?
def url
raise "Unassociated server to mount" if self.server.nil?
"http://" + server_mount.server.hostname + self.name
"http://#{server.hostname}:#{server.pick_listen_socket(:port)}#{self.name}"
end

View File

@ -51,7 +51,7 @@ module JamRuby
mount.name = "/" + SecureRandom.urlsafe_base64
mount.music_session_id = music_session.id
mount.source_username = 'source'
mount.source_pass = SecureRandom.urlsafe_base64
mount.source_pass = APP_CONFIG.icecast_hardcoded_source_password || SecureRandom.urlsafe_base64
mount.stream_name = "JamKazam music session created by #{music_session.creator.name}"
mount.stream_description = music_session.description
mount.stream_url = "http://www.jamkazam.com" ## TODO/XXX, the jamkazam url should be the page hosting the widget

View File

@ -4,7 +4,7 @@ module JamRuby
attr_accessor :skip_config_changed_flag
attr_accessible :template_id, :mount_template_id, :limit_id, :admin_auth_id, :directory_id, :master_relay_id, :path_id, :logging_id,
:security_id, :config_changed, :hostname, :location, :admin_email, :fileserve, :icecast_server_group_id, as: :admin
:security_id, :config_changed, :config_updated_at, :hostname, :location, :admin_email, :fileserve, :icecast_server_group_id, as: :admin
belongs_to :template, class_name: "JamRuby::IcecastTemplate", foreign_key: 'template_id', inverse_of: :servers
@ -58,7 +58,7 @@ module JamRuby
def after_save
# if we set config_changed, then queue up a job
if config_changed_was == 0 && config_changed == 1
if config_changed == 1
IcecastConfigWriter.enqueue(self.server_id)
end
end
@ -70,6 +70,7 @@ module JamRuby
self.skip_config_changed_flag = true
self.config_changed = 0
self.config_updated_at = Time.now
begin
self.save!
rescue
@ -83,7 +84,7 @@ module JamRuby
def pick_listen_socket(field)
current_listen_sockets = listen_sockets.length > 0 ? listen_sockets : template.listen_sockets
socket = current_listen_sockets.first
socket[:field] if socket
socket[field] if socket
end

View File

@ -75,7 +75,13 @@ module JamRuby
# This is a little confusing. You can specify *BOTH* friends_only and my_bands_only to be true
# If so, then it's an OR condition. If both are false, you can get sessions with anyone.
def self.index(current_user, participants = nil, genres = nil, friends_only = false, my_bands_only = false, keyword = nil)
def self.index(current_user, options = {})
participants = options[:participants]
genres = options[:genres]
keyword = options[:keyword]
friends_only = options[:friends_only].nil? ? false : options[:friends_only]
my_bands_only = options[:my_bands_only].nil? ? false : options[:my_bands_only]
as_musician = options[:as_musician].nil? ? true : options[:as_musician]
query = MusicSession
.joins(
@ -118,13 +124,23 @@ module JamRuby
music_sessions.created_at DESC
}
)
.where(
%Q{
musician_access = true
OR
invitations.id IS NOT NULL
}
if as_musician
query = query.where(
%Q{
musician_access = true
OR
invitations.id IS NOT NULL
}
)
else
# if you are trying to join the session as a fan/listener,
# we have to have a mount, fan_access has to be true, and we have to allow for the reload of icecast to have taken effect
query = query.joins('INNER JOIN icecast_mounts ON icecast_mounts.music_session_id = music_sessions.id INNER JOIN icecast_servers ON icecast_mounts.icecast_server_id = icecast_servers.id')
query = query.where(:fan_access => true)
query = query.where("
(music_sessions.created_at < icecast_servers.config_updated_at AND NOW() - icecast_servers.config_updated_at > interval '#{APP_CONFIG.icecast_reload_slush} seconds')")
end
query = query.where("music_sessions.description like '%#{keyword}%'") unless keyword.nil?
query = query.where("connections.user_id" => participants.split(',')) unless participants.nil?

View File

@ -5,8 +5,15 @@ module JamRuby
self.primary_key = 'id'
belongs_to :music_session, :class_name => "JamRuby::MusicSessionHistory", :foreign_key => "music_session_id"
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "creator_id"
default_scope order('created_at DESC')
belongs_to(:music_session_history,
:class_name => "JamRuby::MusicSessionHistory",
:foreign_key => "music_session_id")
belongs_to(:user,
:class_name => "JamRuby::User",
:foreign_key => "creator_id")
end
end

View File

@ -15,10 +15,11 @@ module JamRuby
:foreign_key => :band_id,
:inverse_of => :music_session_history)
has_many :music_session_user_histories, :class_name => "JamRuby::MusicSessionUserHistory", :foreign_key => "music_session_id"
has_many :comments, :class_name => "JamRuby::MusicSessionComment", :foreign_key => "music_session_id"
has_many :likes, :class_name => "JamRuby::MusicSessionLiker", :foreign_key => "music_session_id"
GENRE_SEPARATOR = '|'
SEPARATOR = '|'
def comment_count
self.comments.size
@ -28,6 +29,21 @@ module JamRuby
self.likes.size
end
def tracks
tracks = []
self.music_session_user_histories.each do |msuh|
user = User.find(msuh.user_id)
instruments = msuh.instruments.split(SEPARATOR)
instruments.each do |instrument|
t = Track.new
t.musician = user
t.instrument_id = instrument
tracks << t
end
end
tracks
end
def self.index(current_user, user_id, band_id = nil, genre = nil)
hide_private = false
if current_user.id != user_id
@ -74,7 +90,7 @@ module JamRuby
session_history.description = music_session.description unless music_session.description.nil?
session_history.user_id = music_session.creator.id
session_history.band_id = music_session.band.id unless music_session.band.nil?
session_history.genres = music_session.genres.map { |g| g.id }.join GENRE_SEPARATOR
session_history.genres = music_session.genres.map { |g| g.id }.join SEPARATOR
session_history.save!
end
@ -114,5 +130,16 @@ module JamRuby
.order('created_at DESC')
end
def comments
@comments ||= JamRuby::MusicSessionComment
.where(:music_session_id => self.music_session_id)
.order('created_at DESC')
end
def likes
@likes ||= JamRuby::MusicSessionLiker
.where(:music_session_id => self.music_session_id)
end
end
end

View File

@ -5,8 +5,13 @@ module JamRuby
self.primary_key = 'id'
belongs_to :music_session, :class_name => "JamRuby::MusicSessionHistory", :foreign_key => "music_session_id"
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "liker_id"
belongs_to(:music_session_history,
:class_name => "JamRuby::MusicSessionHistory",
:foreign_key => "music_session_id")
belongs_to(:user,
:class_name => "JamRuby::User",
:foreign_key => "liker_id")
end
end

View File

@ -12,6 +12,10 @@ module JamRuby
:foreign_key => "user_id",
:inverse_of => :music_session_user_histories)
belongs_to(:music_session_history,
:class_name => "MusicSessionHistory",
:foreign_key => "music_session_id")
validates_inclusion_of :rating, :in => 0..2, :allow_nil => true
after_save :track_user_progression
@ -23,7 +27,7 @@ module JamRuby
@perfdata ||= JamRuby::MusicSessionPerfData.find_by_client_id(self.client_id)
end
def self.save(music_session_id, user_id, client_id)
def self.save(music_session_id, user_id, client_id, tracks)
return true if 0 < self.where(:music_session_id => music_session_id,
:user_id => user_id,
:client_id => client_id).count
@ -31,6 +35,7 @@ module JamRuby
session_user_history.music_session_id = music_session_id
session_user_history.user_id = user_id
session_user_history.client_id = client_id
session_user_history.instruments = tracks.map {|t| t[:instrument_id]}.join("|")
session_user_history.save
end

View File

@ -785,7 +785,7 @@ module JamRuby
end
def send_source_down(music_session)
msg = @@message_factory.source_up(music_session.id)
msg = @@message_factory.source_down(music_session.id)
@@mq_router.server_publish_to_everyone_in_session(music_session, msg)
end

View File

@ -29,6 +29,9 @@ module JamRuby
validate :validate_part_complete
validate :validate_too_many_upload_failures
def musician
self.user
end
def can_download?(some_user)
!ClaimedRecording.find_by_user_id_and_recording_id(some_user.id, recording.id).nil?

View File

@ -5,6 +5,8 @@ module JamRuby
self.primary_key = 'id'
default_scope order('created_at DESC')
belongs_to :recording, :class_name => "JamRuby::Recording", :foreign_key => "recording_id"
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "creator_id"

View File

@ -7,6 +7,8 @@ module JamRuby
default_scope order('created_at ASC')
attr_accessor :musician
SOUND = %w(mono stereo)
belongs_to :connection, :class_name => "JamRuby::Connection", :inverse_of => :tracks
@ -14,6 +16,18 @@ module JamRuby
validates :sound, :inclusion => {:in => SOUND}
def user
self.connection.user
end
def musician
@musician
end
def musician=(user)
@musician = user
end
def self.index(current_user, music_session_id)
query = Track
.joins(
@ -47,6 +61,10 @@ module JamRuby
Track.transaction do
connection = Connection.find_by_client_id!(clientId)
# each time tracks are synced we have to update the entry in music_sessions_user_history
msh = MusicSessionUserHistory.find_by_client_id!(clientId)
instruments = []
if tracks.length == 0
connection.tracks.delete_all
else
@ -62,9 +80,11 @@ module JamRuby
to_delete.delete(connection_track)
to_add.delete(track)
# don't update connection_id or client_id; it's unknown what would happen if these changed mid-session
connection_track.instrument = Instrument.find(track[:instrument_id])
connection_track.instrument_id = track[:instrument_id]
connection_track.sound = track[:sound]
connection_track.client_track_id = track[:client_track_id]
instruments << track[:instrument_id]
if connection_track.save
result.push(connection_track)
next
@ -76,10 +96,15 @@ module JamRuby
end
end
msh.instruments = instruments.join("|")
if !msh.save
raise ActiveRecord::Rollback
end
to_add.each do |track|
connection_track = Track.new
connection_track.connection = connection
connection_track.instrument = Instrument.find(track[:instrument_id])
connection_track.instrument_id = track[:instrument_id]
connection_track.sound = track[:sound]
connection_track.client_track_id = track[:client_track_id]
if connection_track.save
@ -90,7 +115,7 @@ module JamRuby
end
end
to_delete.each do| delete_me |
to_delete.each do |delete_me|
delete_me.delete
end
end
@ -101,7 +126,7 @@ module JamRuby
def self.save(id, connection_id, instrument_id, sound, client_track_id)
if id.nil?
track = Track.new()
track = Track.new
track.connection_id = connection_id
else
track = Track.find(id)

View File

@ -288,6 +288,20 @@ module JamRuby
def session_count
return self.music_sessions.size
end
def recent_history
recordings = ClaimedRecording.joins(:recording)
.where(:recordings => {:owner_id => "#{self.id}"})
.order('created_at DESC')
.limit(10)
msh = MusicSessionHistory.where(:user_id => self.id)
.order('created_at DESC')
.limit(10)
recordings.concat(msh)
recordings.sort! {|a,b| b.created_at <=> a.created_at}.first(5)
end
def confirm_email!
self.email_confirmed = true

View File

@ -30,6 +30,11 @@ module JamRuby
"icecast-#{server_id}"
end
def self.lock_timeout
# this should be enough time to make sure the job has finished, but not so long that the system isn't recovering from a abandoned job
60
end
def self.perform(icecast_server_id)
icecast = IcecastConfigWriter.new()
icecast.icecast_server_id = icecast_server_id
@ -53,7 +58,7 @@ module JamRuby
def validate
raise "icecast_server_id not spceified" unless icecast_server_id
raise "queue routing mismatch error" unless icecast_server_id == APP_CONFIG.icecast_server_id
raise "queue routing mismatch error. requested icecast_server_id: #{icecast_server_id}, configured icecast_server_id: #{APP_CONFIG.icecast_server_id}" unless icecast_server_id == APP_CONFIG.icecast_server_id
end
def execute(cmd)

View File

@ -1,32 +0,0 @@
require 'json'
require 'resque'
require 'resque-retry'
require 'net/http'
require 'digest/md5'
module JamRuby
# http://blog.bignerdranch.com/1643-never-use-resque-for-serial-jobs/
# periodically scheduled to find sources that need to be brought down, or alternatively, it seems the client failed to start sourcing
class IcecastSourceCheck
@queue = :icecast_source_check
@@log = Logging.logger[IcecastSourceCheck]
def self.perform
@@log.debug("waking up")
# if we haven't seen updated_at be tickled in 5 minutes, but config_changed is still set to TRUE, this record has gotten stale
IcecastMount.find_each(:conditions => "sourced_needs_changing_at < (NOW() - interval '#{APP_CONFIG.icecast_max_sourced_changed} second')", :batch_size => 100) do |server|
server.with_lock do
IcecastConfigWriter.enqueue(server.server_id)
end
end
@@log.debug("done")
end
end
end

View File

@ -8,11 +8,17 @@ module JamRuby
# periodically scheduled to find jobs that need retrying
class AudioMixerRetry
extend Resque::Plugins::LonelyJob
@queue = :audiomixer_retry
@@log = Logging.logger[AudioMixerRetry]
def self.lock_timeout
# this should be enough time to make sure the job has finished, but not so long that the system isn't recovering from a abandoned job
120
end
def self.perform
AudioMixer.queue_jobs_needing_retry
end

View File

@ -8,11 +8,17 @@ module JamRuby
# periodically scheduled to find jobs that need retrying
class IcecastConfigRetry
extend Resque::Plugins::LonelyJob
@queue = :icecast_config_retry
@@log = Logging.logger[IcecastConfigRetry]
def self.lock_timeout
# this should be enough time to make sure the job has finished, but not so long that the system isn't recovering from a abandoned job
120
end
def self.perform
@@log.debug("waking up")

View File

@ -11,12 +11,14 @@ module JamRuby
class IcecastSourceCheck
extend Resque::Plugins::LonelyJob
@queue = :icecast_source_check
@@log = Logging.logger[IcecastSourceCheck]
def self.lock_timeout
# this should be enough time to make sure the job has finished, but not so long that the system isn't recovering from a abandoned job
120
end
def self.perform
@@log.debug("waking up")
@ -28,6 +30,7 @@ module JamRuby
@@log.debug("done")
end
def run # if we haven't seen updated_at be tickled in 5 minutes, but config_changed is still set to TRUE, this record has gotten stale
IcecastMount.find_each(lock: true, :conditions => "sourced_needs_changing_at < (NOW() - interval '#{APP_CONFIG.icecast_max_sourced_changed} second')", :batch_size => 100) do |mount|
if mount.music_session_id

View File

@ -23,6 +23,13 @@ FactoryGirl.define do
factory :admin do
admin true
end
factory :single_user_session do
after(:create) do |user, evaluator|
music_session = FactoryGirl.create(:music_session, :creator => user)
connection = FactoryGirl.create(:connection, :user => user, :music_session => music_session)
end
end
end
factory :music_session, :class => JamRuby::MusicSession do
@ -34,6 +41,11 @@ FactoryGirl.define do
legal_terms true
genres [JamRuby::Genre.first]
association :creator, :factory => :user
factory :music_session_with_mount do
association :mount, :factory => :icecast_mount
end
end
factory :music_session_history, :class => JamRuby::MusicSessionHistory do
@ -249,7 +261,7 @@ FactoryGirl.define do
factory :icecast_server, :class => JamRuby::IcecastServer do
sequence(:hostname) { |n| "hostname-#{n}"}
sequence(:server_id) { |n| "server-#{n}"}
sequence(:server_id) { |n| "test-server-#{n}"}
factory :icecast_server_minimal do
association :template, :factory => :icecast_template_minimal

View File

@ -4,6 +4,8 @@ describe MusicSession do
before(:each) do
MusicSession.delete_all
IcecastServer.delete_all
IcecastMount.delete_all
end
it 'can grant access to valid user' do
@ -79,175 +81,237 @@ describe MusicSession do
end
it "orders two sessions by created_at starting with most recent" do
creator = FactoryGirl.create(:user)
creator2 = FactoryGirl.create(:user)
describe "index" do
it "orders two sessions by created_at starting with most recent" do
creator = FactoryGirl.create(:user)
creator2 = FactoryGirl.create(:user)
earlier_session = FactoryGirl.create(:music_session, :creator => creator, :description => "Earlier Session")
FactoryGirl.create(:connection, :user => creator, :music_session => earlier_session)
earlier_session = FactoryGirl.create(:music_session, :creator => creator, :description => "Earlier Session")
FactoryGirl.create(:connection, :user => creator, :music_session => earlier_session)
later_session = FactoryGirl.create(:music_session, :creator => creator2, :description => "Later Session")
FactoryGirl.create(:connection, :user => creator2, :music_session => later_session)
later_session = FactoryGirl.create(:music_session, :creator => creator2, :description => "Later Session")
FactoryGirl.create(:connection, :user => creator2, :music_session => later_session)
user = FactoryGirl.create(:user)
user = FactoryGirl.create(:user)
#ActiveRecord::Base.logger = Logger.new(STDOUT)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 2
music_sessions.first.id.should == later_session.id
#ActiveRecord::Base.logger = Logger.new(STDOUT)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 2
music_sessions.first.id.should == later_session.id
end
it "orders sessions with inviteds first, even if created first" do
creator1 = FactoryGirl.create(:user)
creator2 = FactoryGirl.create(:user)
earlier_session = FactoryGirl.create(:music_session, :creator => creator1, :description => "Earlier Session")
FactoryGirl.create(:connection, :user => creator1, :music_session => earlier_session)
later_session = FactoryGirl.create(:music_session, :creator => creator2, :description => "Later Session")
FactoryGirl.create(:connection, :user => creator2, :music_session => later_session)
user = FactoryGirl.create(:user)
FactoryGirl.create(:connection, :user => creator1, :music_session => earlier_session)
FactoryGirl.create(:friendship, :user => creator1, :friend => user)
FactoryGirl.create(:friendship, :user => user, :friend => creator1)
FactoryGirl.create(:invitation, :sender => creator1, :receiver => user, :music_session => earlier_session)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 2
music_sessions.first.id.should == earlier_session.id
end
it "orders sessions with friends in the session first, even if created first" do
creator1 = FactoryGirl.create(:user)
creator2 = FactoryGirl.create(:user)
earlier_session = FactoryGirl.create(:music_session, :creator => creator1, :description => "Earlier Session")
FactoryGirl.create(:connection, :user => creator1, :music_session => earlier_session)
later_session = FactoryGirl.create(:music_session, :creator => creator2, :description => "Later Session")
FactoryGirl.create(:connection, :user => creator2, :music_session => later_session)
user = FactoryGirl.create(:user)
FactoryGirl.create(:friendship, :user => creator1, :friend => user)
FactoryGirl.create(:friendship, :user => user, :friend => creator1)
FactoryGirl.create(:connection, :user => creator1, :music_session => earlier_session)
FactoryGirl.create(:connection, :user => creator2, :music_session => earlier_session)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 2
music_sessions.first.id.should == earlier_session.id
end
it "doesn't list a session if musician_access is set to false" do
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session", :musician_access => false)
user = FactoryGirl.create(:user)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 0
end
it "does list a session if musician_access is set to false but user was invited" do
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session", :musician_access => false)
user = FactoryGirl.create(:user)
FactoryGirl.create(:connection, :user => creator, :music_session => session)
FactoryGirl.create(:friendship, :user => creator, :friend => user)
FactoryGirl.create(:friendship, :user => user, :friend => creator)
FactoryGirl.create(:invitation, :sender => creator, :receiver => user, :music_session => session)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 1
end
it "lists a session if the genre matches" do
creator = FactoryGirl.create(:user)
genre = FactoryGirl.create(:genre)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session", :genres => [genre])
FactoryGirl.create(:connection, :user => creator, :music_session => session)
user = FactoryGirl.create(:user)
music_sessions = MusicSession.index(user, genres: [genre.id])
music_sessions.length.should == 1
end
it "does not list a session if the genre fails to match" do
creator = FactoryGirl.create(:user)
genre1 = FactoryGirl.create(:genre)
genre2 = FactoryGirl.create(:genre)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session", :genres => [genre1])
user = FactoryGirl.create(:user)
music_sessions = MusicSession.index(user, genres: [genre2.id])
music_sessions.length.should == 0
end
it "does not list a session if friends_only is set and no friends are in it" do
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session")
user = FactoryGirl.create(:user)
music_sessions = MusicSession.index(user, friends_only: true)
music_sessions.length.should == 0
end
it "lists a session properly if a friend is in it" do
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session")
user = FactoryGirl.create(:user)
FactoryGirl.create(:friendship, :user => creator, :friend => user)
FactoryGirl.create(:friendship, :user => user, :friend => creator)
FactoryGirl.create(:connection, :user => creator, :music_session => session)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 1
music_sessions = MusicSession.index(user, friends_only: true)
music_sessions.length.should == 1
music_sessions = MusicSession.index(user, friends_only: false, my_bands_only: true)
music_sessions.length.should == 0
music_sessions = MusicSession.index(user, friends_only: true, my_bands_only: true)
music_sessions.length.should == 1
end
it "does not list a session if it has no participants" do
# it's a design goal that there should be no sessions with 0 connections;
# however, this bug continually crops up so the .index method will protect against this common bug
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session")
session.connections.delete_all # should leave a bogus, 0 participant session around
music_sessions = MusicSession.index(creator)
music_sessions.length.should == 0
end
it "does not list a session if my_bands_only is set and it's not my band" do
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session")
user = FactoryGirl.create(:user)
music_sessions = MusicSession.index(user, friends_only: false, my_bands_only: true)
music_sessions.length.should == 0
end
it "lists a session properly if it's my band's session" do
band = FactoryGirl.create(:band)
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session", :band => band)
FactoryGirl.create(:connection, :user => creator, :music_session => session)
user = FactoryGirl.create(:user)
FactoryGirl.create(:band_musician, :band => band, :user => creator)
FactoryGirl.create(:band_musician, :band => band, :user => user)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 1
music_sessions = MusicSession.index(user, friends_only: true)
music_sessions.length.should == 0
music_sessions = MusicSession.index(user, friends_only: false, my_bands_only: true)
music_sessions.length.should == 1
music_sessions = MusicSession.index(user, friends_only: true, my_bands_only: true)
music_sessions.length.should == 1
end
describe "index(as_musician: false)" do
let(:fan_access) { true }
let(:creator) { FactoryGirl.create(:user) }
let(:session) { FactoryGirl.create(:music_session, creator: creator, fan_access: fan_access ) }
let(:connection) { FactoryGirl.create(:connection, user: creator, :music_session => session) }
let(:user) {FactoryGirl.create(:user) }
describe "no mount" do
before(:each) do
session.mount.should be_nil
end
it "no session listed if mount is nil" do
connection.touch
sessions = MusicSession.index(user, as_musician: false)
sessions.length.should == 0
end
end
describe "with mount" do
let(:session_with_mount) { FactoryGirl.create(:music_session_with_mount) }
let(:connection_with_mount) { FactoryGirl.create(:connection, user: creator, :music_session => session_with_mount) }
before(:each) {
session_with_mount.mount.should_not be_nil
}
it "no session listed if icecast_server config hasn't been updated" do
connection_with_mount.touch
sessions = MusicSession.index(user, as_musician: false)
sessions.length.should == 0
end
it "no session listed if icecast_server config was updated but still before slush time" do
connection_with_mount.touch
session_with_mount.created_at = 2.minutes.ago
session_with_mount.save!(:validate => false)
session_with_mount.mount.server.config_updated_at = (APP_CONFIG.icecast_reload_slush - 1).second.ago
session_with_mount.mount.server.save!(:validate => false)
sessions = MusicSession.index(user, as_musician: false)
sessions.length.should == 0
end
it "session listed if icecast_server config has been updated" do
connection_with_mount.touch
session_with_mount.created_at = 2.minutes.ago
session_with_mount.save!(:validate => false)
session_with_mount.mount.server.config_updated_at = 1.minute.ago
session_with_mount.mount.server.save!(:validate => false)
sessions = MusicSession.index(user, as_musician: false)
sessions.length.should == 1
end
end
end
end
it "orders sessions with inviteds first, even if created first" do
creator1 = FactoryGirl.create(:user)
creator2 = FactoryGirl.create(:user)
earlier_session = FactoryGirl.create(:music_session, :creator => creator1, :description => "Earlier Session")
FactoryGirl.create(:connection, :user => creator1, :music_session => earlier_session)
later_session = FactoryGirl.create(:music_session, :creator => creator2, :description => "Later Session")
FactoryGirl.create(:connection, :user => creator2, :music_session => later_session)
user = FactoryGirl.create(:user)
FactoryGirl.create(:connection, :user => creator1, :music_session => earlier_session)
FactoryGirl.create(:friendship, :user => creator1, :friend => user)
FactoryGirl.create(:friendship, :user => user, :friend => creator1)
FactoryGirl.create(:invitation, :sender => creator1, :receiver => user, :music_session => earlier_session)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 2
music_sessions.first.id.should == earlier_session.id
end
it "orders sessions with friends in the session first, even if created first" do
creator1 = FactoryGirl.create(:user)
creator2 = FactoryGirl.create(:user)
earlier_session = FactoryGirl.create(:music_session, :creator => creator1, :description => "Earlier Session")
FactoryGirl.create(:connection, :user => creator1, :music_session => earlier_session)
later_session = FactoryGirl.create(:music_session, :creator => creator2, :description => "Later Session")
FactoryGirl.create(:connection, :user => creator2, :music_session => later_session)
user = FactoryGirl.create(:user)
FactoryGirl.create(:friendship, :user => creator1, :friend => user)
FactoryGirl.create(:friendship, :user => user, :friend => creator1)
FactoryGirl.create(:connection, :user => creator1, :music_session => earlier_session)
FactoryGirl.create(:connection, :user => creator2, :music_session => earlier_session)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 2
music_sessions.first.id.should == earlier_session.id
end
it "doesn't list a session if musician_access is set to false" do
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session", :musician_access => false)
user = FactoryGirl.create(:user)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 0
end
it "does list a session if musician_access is set to false but user was invited" do
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session", :musician_access => false)
user = FactoryGirl.create(:user)
FactoryGirl.create(:connection, :user => creator, :music_session => session)
FactoryGirl.create(:friendship, :user => creator, :friend => user)
FactoryGirl.create(:friendship, :user => user, :friend => creator)
FactoryGirl.create(:invitation, :sender => creator, :receiver => user, :music_session => session)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 1
end
it "lists a session if the genre matches" do
creator = FactoryGirl.create(:user)
genre = FactoryGirl.create(:genre)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session", :genres => [genre])
FactoryGirl.create(:connection, :user => creator, :music_session => session)
user = FactoryGirl.create(:user)
music_sessions = MusicSession.index(user, nil, [genre.id])
music_sessions.length.should == 1
end
it "does not list a session if the genre fails to match" do
creator = FactoryGirl.create(:user)
genre1 = FactoryGirl.create(:genre)
genre2 = FactoryGirl.create(:genre)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session", :genres => [genre1])
user = FactoryGirl.create(:user)
music_sessions = MusicSession.index(user, nil, [genre2.id])
music_sessions.length.should == 0
end
it "does not list a session if friends_only is set and no friends are in it" do
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session")
user = FactoryGirl.create(:user)
music_sessions = MusicSession.index(user, nil, nil, true)
music_sessions.length.should == 0
end
it "lists a session properly if a friend is in it" do
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session")
user = FactoryGirl.create(:user)
FactoryGirl.create(:friendship, :user => creator, :friend => user)
FactoryGirl.create(:friendship, :user => user, :friend => creator)
FactoryGirl.create(:connection, :user => creator, :music_session => session)
music_sessions = MusicSession.index(user, nil, nil)
music_sessions.length.should == 1
music_sessions = MusicSession.index(user, nil, nil, true)
music_sessions.length.should == 1
music_sessions = MusicSession.index(user, nil, nil, false, true)
music_sessions.length.should == 0
music_sessions = MusicSession.index(user, nil, nil, true, true)
music_sessions.length.should == 1
end
it "does not list a session if it has no participants" do
# it's a design goal that there should be no sessions with 0 connections;
# however, this bug continually crops up so the .index method will protect against this common bug
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session")
session.connections.delete_all # should leave a bogus, 0 participant session around
music_sessions = MusicSession.index(creator, nil, nil)
music_sessions.length.should == 0
end
it "does not list a session if my_bands_only is set and it's not my band" do
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session")
user = FactoryGirl.create(:user)
music_sessions = MusicSession.index(user, nil, nil, false, true)
music_sessions.length.should == 0
end
it "lists a session properly if it's my band's session" do
band = FactoryGirl.create(:band)
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session", :band => band)
FactoryGirl.create(:connection, :user => creator, :music_session => session)
user = FactoryGirl.create(:user)
FactoryGirl.create(:band_musician, :band => band, :user => creator)
FactoryGirl.create(:band_musician, :band => band, :user => user)
music_sessions = MusicSession.index(user, nil, nil)
music_sessions.length.should == 1
music_sessions = MusicSession.index(user, nil, nil, true)
music_sessions.length.should == 0
music_sessions = MusicSession.index(user, nil, nil, false, true)
music_sessions.length.should == 1
music_sessions = MusicSession.index(user, nil, nil, true, true)
music_sessions.length.should == 1
end
it "updates the fields of a music session properly" do
genre1 = FactoryGirl.create(:genre)
@ -264,110 +328,6 @@ describe MusicSession do
session.genres[0].id.should == genre1.id
end
=begin
# mslemmer:
# I'm going to clean this up into smaller tasks.
it 'can list sessions with appropriate sort order' do
user1 = FactoryGirl.create(:user)
user2 = FactoryGirl.create(:user)
user3 = FactoryGirl.create(:user)
user4 = FactoryGirl.create(:user)
user5 = FactoryGirl.create(:user)
music_session = FactoryGirl.create(:music_session, :creator => user1, :musician_access => false)
FactoryGirl.create(:connection, :user => user1, :music_session => music_session)
music_sessions = MusicSession.index(user2)
music_sessions.length.should == 0
music_session2 = FactoryGirl.create(:music_session, :creator => user3, :musician_access => true)
FactoryGirl.create(:connection, :user => user3, :music_session => music_session2)
music_sessions = MusicSession.index(user2)
music_sessions.length.should == 1
music_sessions[0].connections[0].user.friends.length == 0
# users 1 and 5 are friends
FactoryGirl.create(:friendship, :user => user1, :friend => user5)
FactoryGirl.create(:friendship, :user => user5, :friend => user1)
# users 1 and 2 are friends
FactoryGirl.create(:friendship, :user => user1, :friend => user2)
FactoryGirl.create(:friendship, :user => user2, :friend => user1)
# users 2 and 4 are friends
FactoryGirl.create(:friendship, :user => user2, :friend => user4)
FactoryGirl.create(:friendship, :user => user4, :friend => user2)
# user 2 should now be able to see this session, because his friend is in the session
music_sessions = MusicSession.index(user2)
music_sessions.length.should == 2
music_sessions[0].id.should == music_session.id
music_sessions[0].connections[0].user.id.should == user1.id
music_sessions[0].connections[0].user.friends.length == 1
music_sessions[1].id.should == music_session2.id
FactoryGirl.create(:invitation, :sender => user1, :receiver => user2, :music_session => music_session)
music_sessions = MusicSession.index(user2)
music_sessions.length.should == 2
music_sessions[0].id.should == music_session.id
music_sessions[1].id.should == music_session2.id
# create another, but friendy usic session with user 4
music_session3 = FactoryGirl.create(:music_session, :creator => user4, :musician_access => false, :created_at => 1.week.ago)
FactoryGirl.create(:connection, :user => user4, :music_session => music_session3)
music_sessions = MusicSession.index(user2)
music_sessions.length.should == 3
music_sessions[0].id.should == music_session.id
music_sessions[1].id.should == music_session3.id
music_sessions[2].id.should == music_session2.id
# verify we can inspect the data
music_session.invitations.length.should == 1
music_session4 = FactoryGirl.create(:music_session, :creator => user5, :musician_access => false, :created_at => 2.week.ago)
FactoryGirl.create(:connection, :user => user5, :music_session => music_session4)
music_sessions = MusicSession.index(user2)
music_sessions.length.should == 3
# make this session public now
music_session4.musician_access = true
music_session4.save
music_sessions = MusicSession.index(user2)
music_sessions.length.should == 4
music_sessions[0].id.should == music_session.id
music_sessions[1].id.should == music_session3.id
music_sessions[2].id.should == music_session2.id
music_sessions[3].id.should == music_session4.id
# ok let's make the public session that we just made, become a 'friendy' one
# make user2/5 friends
FactoryGirl.create(:friendship, :user => user2, :friend => user5)
FactoryGirl.create(:friendship, :user => user5, :friend => user2)
music_sessions = MusicSession.index(user2)
music_sessions.length.should == 4
music_sessions[0].id.should == music_session.id
music_sessions[1].id.should == music_session3.id
music_sessions[2].id.should == music_session4.id
music_sessions[3].id.should == music_session2.id
# and finally make it an invite
FactoryGirl.create(:invitation, :sender => user5, :receiver => user2, :music_session => music_session4 )
music_sessions = MusicSession.index(user2)
music_sessions.length.should == 4
music_sessions[0].id.should == music_session.id
music_sessions[1].id.should == music_session4.id
music_sessions[2].id.should == music_session3.id
music_sessions[3].id.should == music_session2.id
end
=end
it 'uninvited users cant join approval-required sessions without invitation' do
user1 = FactoryGirl.create(:user) # in the jam session
user2 = FactoryGirl.create(:user) # in the jam session

View File

@ -1,5 +1,6 @@
require 'spec_helper'
=begin
describe Track do
let (:connection) { FactoryGirl.create(:connection) }
@ -91,4 +92,5 @@ describe Track do
found.client_track_id.should == track.client_track_id
end
end
end
end
=end

View File

@ -1,9 +1,9 @@
require 'spec_helper'
require 'fileutils'
=begin
# these tests avoid the use of ActiveRecord and FactoryGirl to do blackbox, non test-instrumented tests
describe AudioMixer do
pending "failing on build server"
include UsesTempFiles
@ -316,3 +316,5 @@ describe AudioMixer do
end
end
=end

View File

@ -14,7 +14,7 @@ describe IcecastConfigWriter do
it "no files specified" do
worker.icecast_server_id = 'something'
expect { worker.validate }.to raise_error("queue routing mismatch error")
expect { worker.validate }.to raise_error("queue routing mismatch error. requested icecast_server_id: #{worker.icecast_server_id}, configured icecast_server_id: #{APP_CONFIG.icecast_server_id}")
end
it "succeeds" do
@ -75,8 +75,10 @@ describe IcecastConfigWriter do
end
it "should have been enqueued because the config changed" do
server.touch
ResqueSpec.reset!
server.save!
# the act of just creating the IcecastServer puts a message on the queue
# the act of just touching the IcecastServer puts a message on the queue, because config_changed = true
IcecastConfigWriter.should have_queue_size_of(1)
end

View File

@ -40,17 +40,6 @@ CarrierWave.configure do |config|
config.enable_processing = false
end
#Resque::Failure::Notifier.configure do |config|
# config.from = 'dummy@jamkazam.com' # from address
# config.to = 'dummy@jamkazam.com' # to address
# config.include_payload = true # enabled by default
#end
#Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Notifier]
#Resque::Failure.backend = Resque::Failure::Multiple
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
@ -58,7 +47,7 @@ Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
# This file is copied to spec/ when you run 'rails generate rspec:install'
#ENV["RAILS_ENV"] ||= 'test'
#require File.expand_path("../../config/environment", __FILE__)
require 'rspec/autorun'

View File

@ -41,6 +41,14 @@ def app_config
15 # 15 seconds
end
def icecast_reload_slush
3 # 3 seconds
end
def icecast_hardcoded_source_password
nil # generate a new password everytime
end
def rabbitmq_host
"localhost"
end

6
runadmin Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
pushd admin
# run jam-admin rails server
bundle exec rails s
popd

6
runjobs Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
pushd web
# run all_jobs rake task; this waits on new jobs from the resque queue, i.e., audiomixer, icecast, etc
bundle exec rake all_jobs
popd

View File

@ -17,6 +17,7 @@ else
gem 'jampb', "0.1.#{ENV["BUILD_NUMBER"]}"
gem 'jam_ruby', "0.1.#{ENV["BUILD_NUMBER"]}"
gem 'jam_websockets', "0.1.#{ENV["BUILD_NUMBER"]}"
ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] ||= "true"
end
gem 'builder'
gem 'rails', '>=3.2.11'
@ -64,7 +65,7 @@ gem 'resque-failed-job-mailer'
gem 'resque-dynamic-queues'
gem 'resque-lonely_job', '~> 1.0.0'
gem 'quiet_assets', :group => :development
gem "bugsnag"
gem 'bugsnag'
group :development, :test do
gem 'rspec-rails'

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 999 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

View File

Before

Width:  |  Height:  |  Size: 896 B

After

Width:  |  Height:  |  Size: 896 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 764 B

After

Width:  |  Height:  |  Size: 764 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 892 B

After

Width:  |  Height:  |  Size: 892 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 913 B

After

Width:  |  Height:  |  Size: 913 B

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -101,7 +101,7 @@
if (pinstr in instrument_logo_map) {
instr = instrument_logo_map[pinstr];
}
player_instrs += '<img src="' + instr + '" width="24" height="24" />&nbsp;';
player_instrs += '<img src="' + instr + '"/>';
}
playerVals = {
@ -182,7 +182,8 @@
processData: false,
success: function(response) {
// remove the orange look to indicate it's not selectable
$('div[data-band-id='+newFollowing.band_id+'] .search-m-follow').removeClass('button-orange');
// @FIXME -- this will need to be tweaked when we allow unfollowing
$('div[data-band-id='+newFollowing.band_id+'] .search-m-follow').removeClass('button-orange').addClass('button-grey');
},
error: app.ajaxError
});

View File

@ -128,7 +128,7 @@
musician_name: mm.name,
musician_location: mm.city + ', ' + mm.state,
instruments: instr_logos,
biography: mm['biography'] || 'Lorum Ipsum Nulla facilisi. In vel sem. Morbi id urna in diam dignissim feugiat. Proin molestie tortor eu velit. Aliquam erat volutpat. Nullam ultrices, diam tempus vulputate egestas, eros pede varius leo, sed imperdiet lectus est ornare odio.',
biography: mm['biography'],
follow_count: mm['follow_count'],
friend_count: mm['friend_count'],
recording_count: mm['recording_count'],
@ -178,7 +178,8 @@
function friendRequestCallback(user_id) {
// remove the orange look to indicate it's not selectable
$('div[data-musician-id='+user_id+'] .search-m-friend').removeClass('button-orange');
// @FIXME -- this will need to be tweaked when we allow unfollowing
$('div[data-musician-id='+user_id+'] .search-m-friend').removeClass('button-orange').addClass('button-grey');
}
function followMusician(evt) {
@ -203,7 +204,8 @@
processData: false,
success: function(response) {
// remove the orange look to indicate it's not selectable
$('div[data-musician-id='+newFollowing.user_id+'] .search-m-follow').removeClass('button-orange');
// @FIXME -- this will need to be tweaked when we allow unfollowing
$('div[data-musician-id='+newFollowing.user_id+'] .search-m-follow').removeClass('button-orange').addClass('button-grey');
},
error: app.ajaxError
});

View File

@ -35,7 +35,6 @@
}
function updateSession(id, newSession, onSuccess) {
logger.debug('Rest.updateSession');
return $.ajax('/api/sessions/' + id, {
type: "PUT",
data : newSession,
@ -44,6 +43,56 @@
});
}
function addSessionComment(sessionId, userId, comment) {
return $.ajax({
url: '/api/sessions/' + sessionId + "/comments",
type: "POST",
data : JSON.stringify({"comment": comment, "user_id": userId}),
dataType : 'json',
contentType: 'application/json'
});
}
function addSessionLike(sessionId, userId) {
return $.ajax({
url: '/api/sessions/' + sessionId + "/likes",
type: "POST",
data : JSON.stringify({"user_id": userId}),
dataType : 'json',
contentType: 'application/json'
});
}
function addRecordingComment(recordingId, userId, comment) {
return $.ajax({
url: '/api/recordings/' + recordingId + "/comments",
type: "POST",
data : JSON.stringify({"comment": comment, "user_id": userId}),
dataType : 'json',
contentType: 'application/json'
});
}
function addRecordingLike(recordingId, userId) {
return $.ajax({
url: '/api/recordings/' + recordingId + "/likes",
type: "POST",
data : JSON.stringify({"user_id": userId}),
dataType : 'json',
contentType: 'application/json'
});
}
function addRecordingPlay(recordingId, userId) {
return $.ajax({
url: '/api/recordings/' + recordingId + "/plays",
type: "POST",
data : JSON.stringify({"user_id": userId}),
dataType : 'json',
contentType: 'application/json'
});
}
function getBand(bandId) {
return $.ajax({
type: "GET",
@ -705,6 +754,11 @@
this.getBandFollowing = getBandFollowing;
this.getBands = getBands;
this.updateSession = updateSession;
this.addSessionComment = addSessionComment;
this.addSessionLike = addSessionLike;
this.addRecordingComment = addRecordingComment;
this.addRecordingLike = addRecordingLike;
this.addRecordingPlay = addRecordingPlay;
this.getSession = getSession;
this.getClientDownloads = getClientDownloads;
this.createInvitation = createInvitation;

View File

@ -1319,6 +1319,7 @@
configureTrackDialog.showVoiceChatPanel(true);
configureTrackDialog.showMusicAudioPanel(true);
});
$('#close-playback-recording').on('click', closeRecording);
$(playbackControls)
.on('pause', onPause)

View File

@ -0,0 +1,106 @@
(function(context,$) {
"use strict";
context.JK = context.JK || {};
context.JK.ShareDialog = function(app) {
var logger = context.JK.logger;
var rest = context.JK.Rest();
function registerEvents(onOff) {
}
function showDialog() {
app.layout.showDialog('share-dialog');
}
/*function showEmailDialog() {
$('#invitation-dialog').show();
$('#invitation-textarea-container').show();
$('#invitation-checkbox-container').hide();
$('#btn-send-invitation').show();
$('#btn-next-invitation').hide();
clearTextFields();
app.layout.showDialog('inviteUsers')
}
function showGoogleDialog() {
$('#invitation-dialog').show();
$('#invitation-textarea-container').hide();
$('#invitation-checkbox-container').show();
$('#btn-send-invitation').hide();
$('#btn-next-invitation').show();
clearTextFields();
app.layout.showDialog('inviteUsers')
$('#invitation-checkboxes').html('<div style="text-align: center; margin-top: 100px;">Loading your contacts...</div>');
window._oauth_callback = function() {
window._oauth_win.close();
window._oauth_win = null;
window._oauth_callback = null;
$.ajax({
type: "GET",
url: "/gmail_contacts",
success: function(response) {
$('#invitation-checkboxes').html('');
for (var i in response) {
$('#invitation-checkboxes').append("<label><input type='checkbox' class='invitation-checkbox' data-email='" + response[i] + "' /> " + response[i] + "</label>");
}
$('.invitation-checkbox').change(function() {
var checkedBoxes = $('.invitation-checkbox:checkbox:checked');
var emails = '';
for (var i = 0; i < checkedBoxes.length; i++) {
emails += $(checkedBoxes[i]).data('email') + ', ';
}
emails = emails.replace(/, $/, '');
// track how many of these came from google
$('#txt-emails').val(emails).data('google_invite_count', checkedBoxes.length);
});
},
error: function() {
$('#invitation-checkboxes').html("Load failed!");
}
});
};
window._oauth_win = window.open("/auth/google_login", "_blank", "height=500,width=500,menubar=no,resizable=no,status=no");
}
function showFacebookDialog() {
window._oauth_callback = function() {
window._oauth_win.close();
window._oauth_win = null;
window._oauth_callback = null;
};
window._oauth_win = window.open("/auth/facebook_login", "_blank", "height=500,width=500,menubar=no,resizable=no,status=no");
}*/
function clearTextFields() {
}
function beforeShow() {
registerEvents(true);
}
function afterHide() {
registerEvents(false);
}
function initialize(){
var dialogBindings = {
'beforeShow' : beforeShow,
'afterHide': afterHide
};
app.bindDialog('shareSessionRecording', dialogBindings);
};
this.initialize = initialize;
this.showDialog = showDialog;
}
return this;
})(window,jQuery);

View File

@ -236,92 +236,6 @@
else if (type === context.JK.MessageType.BAND_INVITATION_ACCEPTED) {
$notification.find('#div-actions').hide();
}
else if (type === context.JK.MessageType.SOURCE_UP_REQUESTED) {
var current_session_id = context.JK.CurrentSessionModel.id();
if (!current_session_id) {
// we are not in a session
var last_session = context.JK.CurrentSessionModel.getCurrentOrLastSession();
if(last_session && last_session.id == payload.music_session) {
// the last session we were in was responsible for this message. not that odd at all
logger.debug("SOURCE_UP_REQUESTED came in for session_id" + payload.music_session + ", but was dropped because we have left that session")
}
else {
// this means we aren't in a session, and, what's worse,
// the last session we were in does not match the specified music_session id
throw "SOURCE_UP_REQUESTED came in for session_id:" + payload.music_session + ", but we are not in a session and the last session ID did not match the one specified";
}
}
else {
// we are in a session
if(current_session_id == payload.music_session) {
context.jamClient.SessionLiveBroadcastStart(payload.host, payload.port, payload.mount,
payload.source_user, payload.source_pass,
'', payload.bitrate)
}
else {
var last_session = context.JK.CurrentSessionModel.getCurrentOrLastSession();
if(last_session && last_session.id == payload.music_session) {
// the last session we were in was responsible for this message. not that odd at all
logger.debug("SOURCE_UP_REQUESTED came in for session_id" + payload.music_session + ", but was dropped because we have left that session and are in a new one")
}
else {
// this means we aren't in a session, and, what's worse,
// the last session we were in does not match the specified music_session id
throw "SOURCE_UP_REQUESTED came in for session_id:" + payload.music_session + ", but we are in a session and the last session ID did not match the one specified";
}
}
}
}
else if (type === context.JK.MessageType.SOURCE_DOWN_REQUESTED) {
var current_session_id = context.JK.CurrentSessionModel.id();
if (!current_session_id) {
// we are not in a session
var last_session = context.JK.CurrentSessionModel.getCurrentOrLastSession();
if(last_session && last_session.id == payload.music_session) {
// the last session we were in was responsible for this message. not that odd at all
logger.debug("SOURCE_DOWN_REQUESTED came in for session_id" + payload.music_session + ", but was dropped because we have left that session")
}
else {
// this means we aren't in a session, and, what's worse,
// the last session we were in does not match the specified music_session id
throw "SOURCE_DOWN_REQUESTED came in for session_id:" + payload.music_session + ", but we are not in a session and the last session ID did not match the one specified";
}
}
else {
// we are in a session
if(current_session_id == payload.music_session) {
context.jamClient.SessionLiveBroadcastStop();
}
else {
var last_session = context.JK.CurrentSessionModel.getCurrentOrLastSession();
if(last_session && last_session.id == payload.music_session) {
// the last session we were in was responsible for this message. not that odd at all
logger.debug("SOURCE_DOWN_REQUESTED came in for session_id" + payload.music_session + ", but was dropped because we have left that session and are in a new one")
}
else {
// this means we aren't in a session, and, what's worse,
// the last session we were in does not match the specified music_session id
throw "SOURCE_DOWN_REQUESTED came in for session_id:" + payload.music_session + ", but we are in a session and the last session ID did not match the one specified";
}
}
}
}
else if (type === context.JK.MessageType.SOURCE_UP) {
log.debug("session %o is now being broadcasted", payload.music_session);
app.notify({
"title": "Now Broadcasting",
"text": "This session is now being broadcasted."
});
}
else if (type === context.JK.MessageType.SOURCE_DOWN) {
log.debug("session %o is no longer being broadcasted", payload.music_session);
app.notify({
"title": "No Longer Broadcasting",
"text": "This session is no longer being broadcasted."
});
}
}
function deleteNotificationHandler(evt) {
@ -512,6 +426,12 @@
registerBandInvitation();
registerBandInvitationAccepted();
// broadcast notifications
registerSourceUpRequested();
registerSourceDownRequested();
registerSourceUp();
registerSourceDown();
// watch for Invite More Users events
$('#sidebar-div .btn-email-invitation').click(function() {
invitationDialog.showEmailDialog();
@ -962,13 +882,118 @@
});
}
function registerSourceUpRequested() {
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.SOURCE_UP_REQUESTED, function(header, payload) {
logger.debug("Handling SOURCE_UP_REQUESTED msg " + JSON.stringify(payload));
var current_session_id = context.JK.CurrentSessionModel.id();
if (!current_session_id) {
// we are not in a session
var last_session = context.JK.CurrentSessionModel.getCurrentOrLastSession();
if(last_session && last_session.id == payload.music_session) {
// the last session we were in was responsible for this message. not that odd at all
logger.debug("SOURCE_UP_REQUESTED came in for session_id" + payload.music_session + ", but was dropped because we have left that session")
}
else {
// this means we aren't in a session, and, what's worse,
// the last session we were in does not match the specified music_session id
throw "SOURCE_UP_REQUESTED came in for session_id:" + payload.music_session + ", but we are not in a session and the last session ID did not match the one specified";
}
}
else {
// we are in a session
if(current_session_id == payload.music_session) {
context.jamClient.SessionLiveBroadcastStart(payload.host, payload.port, payload.mount,
payload.source_user, payload.source_pass,
'', payload.bitrate)
}
else {
var last_session = context.JK.CurrentSessionModel.getCurrentOrLastSession();
if(last_session && last_session.id == payload.music_session) {
// the last session we were in was responsible for this message. not that odd at all
logger.debug("SOURCE_UP_REQUESTED came in for session_id" + payload.music_session + ", but was dropped because we have left that session and are in a new one")
}
else {
// this means we aren't in a session, and, what's worse,
// the last session we were in does not match the specified music_session id
throw "SOURCE_UP_REQUESTED came in for session_id:" + payload.music_session + ", but we are in a session and the last session ID did not match the one specified";
}
}
}
});
}
function registerSourceDownRequested() {
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.SOURCE_DOWN_REQUESTED, function(header, payload) {
logger.debug("Handling SOURCE_DOWN_REQUESTED msg " + JSON.stringify(payload));
var current_session_id = context.JK.CurrentSessionModel.id();
if (!current_session_id) {
// we are not in a session
var last_session = context.JK.CurrentSessionModel.getCurrentOrLastSession();
if(last_session && last_session.id == payload.music_session) {
// the last session we were in was responsible for this message. not that odd at all
logger.debug("SOURCE_DOWN_REQUESTED came in for session_id" + payload.music_session + ", but was dropped because we have left that session")
}
else {
// this means we aren't in a session, and, what's worse,
// the last session we were in does not match the specified music_session id
throw "SOURCE_DOWN_REQUESTED came in for session_id:" + payload.music_session + ", but we are not in a session and the last session ID did not match the one specified";
}
}
else {
// we are in a session
if(current_session_id == payload.music_session) {
context.jamClient.SessionLiveBroadcastStop();
}
else {
var last_session = context.JK.CurrentSessionModel.getCurrentOrLastSession();
if(last_session && last_session.id == payload.music_session) {
// the last session we were in was responsible for this message. not that odd at all
logger.debug("SOURCE_DOWN_REQUESTED came in for session_id" + payload.music_session + ", but was dropped because we have left that session and are in a new one")
}
else {
// this means we aren't in a session, and, what's worse,
// the last session we were in does not match the specified music_session id
throw "SOURCE_DOWN_REQUESTED came in for session_id:" + payload.music_session + ", but we are in a session and the last session ID did not match the one specified";
}
}
}
});
}
function registerSourceUp() {
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.SOURCE_UP, function(header, payload) {
logger.debug("Handling SOURCE_UP msg " + JSON.stringify(payload));
logger.debug("session %o is now being broadcasted", payload.music_session);
app.notify({
"title": "Now Broadcasting",
"text": "This session is now being broadcasted."
});
});
}
function registerSourceDown() {
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.SOURCE_DOWN, function(header, payload) {
logger.debug("Handling SOURCE_DOWN msg " + JSON.stringify(payload));
logger.debug("session %o is no longer being broadcasted", payload.music_session);
app.notify({
"title": "No Longer Broadcasting",
"text": "This session is no longer being broadcasted."
});
});
}
this.initialize = function(invitationDialogInstance) {
events();
events();
initializeSearchPanel();
initializeFriendsPanel();
initializeChatPanel();
initializeNotificationsPanel();
invitationDialog = invitationDialogInstance;
initializeFriendsPanel();
initializeChatPanel();
initializeNotificationsPanel();
invitationDialog = invitationDialogInstance;
};
};
})(window,jQuery);

View File

@ -75,6 +75,7 @@
// initially show avatar
function showAvatar() {
var photoUrl = context.JK.resolveAvatarUrl(userMe.photo_url);
logger.debug("photoUrl=" + photoUrl);
$('#header-avatar').attr('src', photoUrl);
}

View File

@ -42,18 +42,18 @@
// available, and allowing the browser to resize offers better quality.
var icon_map_base = {
"accordion":"accordion",
"acoustic guitar":"acoustic",
"acoustic guitar":"acoustic_guitar",
"banjo":"banjo",
"bass guitar":"bass",
"bass guitar":"bass_guitar",
"cello":"cello",
"clarinet":"clarinet",
"computer":"computer",
"default":"default",
"drums":"drums",
"electric guitar":"guitar",
"electric guitar":"electric_guitar",
"euphonium":"euphonium",
"flute":"flute",
"french horn":"frenchhorn",
"french horn":"french_horn",
"harmonica":"harmonica",
"keyboard":"keyboard",
"mandolin":"mandolin",

View File

@ -0,0 +1,10 @@
$(function() {
function like() {
}
// search click handler
$('#btnlike').click(like);
});

View File

@ -0,0 +1,10 @@
$(function() {
function like() {
}
// search click handler
$('#btnlike').click(like);
});

View File

@ -6,6 +6,7 @@
//= require AAC_underscore
//= require globals
//= require invitationDialog
//= require shareDialog
//= require layout
//= require user_dropdown
//= require jamkazam
@ -15,4 +16,6 @@
//= require landing/init
//= require landing/signup
//= require web/downloads
//= require web/congratulations
//= require web/congratulations
//= require web/sessions
//= require web/recordings

View File

@ -32,6 +32,7 @@
*= require ./search
*= require ./ftue
*= require ./invitationDialog
*= require ./shareDialog
*= require ./recordingFinishedDialog
*= require ./localRecordingsDialog
*= require ./createSession

View File

@ -313,8 +313,12 @@ a.arrow-down {
padding:6px 0px 11px 0px;
background-color:#4c4c4c;
min-height:20px;
overflow-x:scroll;
// overflow-x:scroll;
select {
font-size:11px;
margin-top:4px;
}
}
#session-controls .searchbox {
float:left;

View File

@ -35,28 +35,6 @@
padding-right: 5px;
padding-left: 5px;
#result_instruments {
font-weight: normal;
> img {
margin-right: 4px;
height:24px;
width:24px;
}
}
.result-name {
font-size: 12px;
font-weight: bold;
margin-bottom: 2px;
}
.stats {
margin-top: 4px;
img {
vertical-align: middle;
}
}
.lcol {
width: 148px;
}
table.musicians {
margin-top:12px;
}

View File

@ -196,13 +196,48 @@
}
.profile-band-list-result {
width:100%;
min-height:85px;
background-color:#242323;
position:relative;
margin:10px 0px 10px 0px;
padding-bottom:5px;
box-sizing:border-box;
width:100%;
min-height:85px;
background-color:#242323;
position:relative;
margin:10px 0px 10px 0px;
padding-bottom:5px;
box-sizing:border-box;
.result-name {
font-size: 12px;
font-weight: bold;
margin-bottom: 2px;
}
.stats {
margin-top: 4px;
img {
vertical-align: middle;
}
}
.lcol {
width: 148px;
}
.instruments {
width:128px;
img {
height:24px;
width:24px;
margin-right:2px;
&:last-child {
margin-right:0px;
}
}
}
.button-row {
margin-top:10px;
margin-bottom:5px;
.result-list-button-wrapper {
margin:0;
}
}
}
.profile-social-left {

Some files were not shown because too many files have changed in this diff Show More