diff --git a/db/manifest b/db/manifest index 30258a277..3eafba777 100755 --- a/db/manifest +++ b/db/manifest @@ -392,4 +392,5 @@ amazon_v2.sql store_backend_details_rate_session.sql invited_user_receiver.sql live_streams.sql -find_sessions_2020.sql \ No newline at end of file +live_stream_notify.sql +find_sessions_2020.sql diff --git a/db/up/live_stream_notify.sql b/db/up/live_stream_notify.sql new file mode 100644 index 000000000..71852e185 --- /dev/null +++ b/db/up/live_stream_notify.sql @@ -0,0 +1,9 @@ +-- recordings +CREATE TABLE client_live_streams( + id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(), + user_id VARCHAR(64) NOT NULL REFERENCES users(id) ON DELETE CASCADE, + music_session_id VARCHAR(64) REFERENCES music_sessions(id) ON DELETE CASCADE, + message VARCHAR, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); \ No newline at end of file diff --git a/ruby/lib/jam_ruby.rb b/ruby/lib/jam_ruby.rb index 8a6531664..b64b067d1 100755 --- a/ruby/lib/jam_ruby.rb +++ b/ruby/lib/jam_ruby.rb @@ -159,6 +159,7 @@ require "jam_ruby/models/active_music_session" require "jam_ruby/models/music_session_comment" require "jam_ruby/models/session_info_comment" require "jam_ruby/models/broadcast" +require "jam_ruby/models/client_live_stream" require "jam_ruby/models/music_session" require "jam_ruby/models/music_session_liker" require "jam_ruby/models/music_session_user_history" diff --git a/ruby/lib/jam_ruby/models/broadcast.rb b/ruby/lib/jam_ruby/models/broadcast.rb index 353650c8b..c4d3b823c 100644 --- a/ruby/lib/jam_ruby/models/broadcast.rb +++ b/ruby/lib/jam_ruby/models/broadcast.rb @@ -10,7 +10,7 @@ module JamRuby STATUS_DELETED = 'deleted' DONE_STATUSES = [STATUS_ABANDONED, STATUS_REVOKED, STATUS_DELETED, STATUS_COMPLETED] - belongs_to :music_session, :class_name => 'JamRuby::MusicSsession' + belongs_to :music_session, :class_name => 'JamRuby::MusicSession' def self.current_broadcast(music_session) Broadcast.where(music_session_id: music_session.id).where('broadcast_status not in (?)', Broadcast::DONE_STATUSES).first diff --git a/ruby/lib/jam_ruby/models/client_live_stream.rb b/ruby/lib/jam_ruby/models/client_live_stream.rb new file mode 100644 index 000000000..5df8b68ff --- /dev/null +++ b/ruby/lib/jam_ruby/models/client_live_stream.rb @@ -0,0 +1,11 @@ + +module JamRuby + class ClientLiveStream < ActiveRecord::Base + + @@log = Logging.logger[ClientLiveStream] + + belongs_to :music_session, :class_name => 'JamRuby::MusicSession' + + belongs_to :user , :class_name => 'JamRuby::User' + end +end diff --git a/web/app/assets/javascripts/web/signin.js b/web/app/assets/javascripts/web/signin.js index d01d2c200..b275f306a 100644 --- a/web/app/assets/javascripts/web/signin.js +++ b/web/app/assets/javascripts/web/signin.js @@ -17,6 +17,8 @@ $signinRoot = $('.signin-common'); $signupRoot = $('.signup-common'); + context.JK.popExternalLinks() + var signinHelper = new context.JK.SigninHelper(context.JK.app); $(signinHelper).on(EVENTS.SHOW_SIGNUP, function() { $signinRoot.hide(); diff --git a/web/app/controllers/api_live_streams_controller.rb b/web/app/controllers/api_live_streams_controller.rb index f21776107..90bfd703f 100644 --- a/web/app/controllers/api_live_streams_controller.rb +++ b/web/app/controllers/api_live_streams_controller.rb @@ -44,10 +44,90 @@ class ApiLiveStreamsController < ApiController render "api_live_streams/show", :layout => nil end + def build_user_detail(user) + + detail = '' + participant = "---------Participant: #{user.name}---------\n" + detail += participant + detail += "Email: #{user.email}\n" + detail += "Location: #{user.location}\n" + detail += "Profile: #{user.biography}\n" + detail += "Admin URL: #{user.admin_url}\n" + user.bands.each do | band | + detail += " Band: #{band.name} #{band.website}\n" + detail += " Band Profile: #{band.biography}" + end + detail += ("-" * participant.length) + "\n" + + detail + end + + def email_stream_event(subject, create_entity) + begin + music_session_id = params["music_session_id"] + music_session = MusicSession.find(music_session_id) + + music_session_admin_url = '' + if music_session + music_session_admin_url = music_session.admin_url + end + participants = params["participants"] + + body = "\n" + body += "Participants: #{participants}\n\n" + body += build_user_detail(current_user) + + + users = nil + if music_session.active_music_session + users = music_session.active_music_session.users + else + users = music_session.unique_users + end + + users.each do |user| + if user == current_user + next + end + + body += build_user_detail(user) + end + + body += "\nSession Admin URL: #{music_session_admin_url}" + + body += "\n\n" + + body += "--------DUMP--------\n" + body += params.to_yaml + + if create_entity + client_live_stream = ClientLiveStream.new + client_live_stream.user = current_user + client_live_stream.music_session = music_session if music_session + client_live_stream.message = body + client_live_stream.save + end + + + AdminMailer.ugly({to:'seth@jamkazam.com', body: body, subject: subject}).deliver_now + rescue => e + AdminMailer.ugly({to:'david@jamkazam.com', cc:'seth@jamkazam.com,peter@jamkazam.com', body: params.to_s + "\n\n" + e.to_s, subject: 'Live Stream Started!'}).deliver_now + + end + end def stream_started - AdminMailer.ugly({to:'david@jamkazam.com', cc:'seth@jamkazam.com,peter@jamkazam.com', body: params.to_s, subject: 'Live Stream Started!'}).deliver_now + + email_stream_event("Live Stream Started!", false) + + render json: {}, :status => :ok end + def stream_stop + + email_stream_event("Live Stream Stopped!", true) + + render json: {}, :status => :ok + end end diff --git a/web/app/views/users/_signin.html.haml b/web/app/views/users/_signin.html.haml index 0cc535096..66a572079 100644 --- a/web/app/views/users/_signin.html.haml +++ b/web/app/views/users/_signin.html.haml @@ -38,7 +38,7 @@ %br %br %small - %a.forgot-password{href:'/request_reset_password'} Forgot Password? + %a.forgot-password{href:'/request_reset_password', rel:'external'} Forgot Password? %br diff --git a/web/app/views/users/_signup.html.haml b/web/app/views/users/_signup.html.haml index f73d12d73..fb3163147 100644 --- a/web/app/views/users/_signup.html.haml +++ b/web/app/views/users/_signup.html.haml @@ -8,7 +8,7 @@ %br %br .center - = link_to "SIGN UP WITH YOUR EMAIL", signup_path, class: "button-orange block signup-email" + = link_to "SIGN UP WITH YOUR EMAIL", signup_path, class: "button-orange block signup-email", rel:"external" %br .center %small diff --git a/web/app/views/users/_user_dropdown.html.erb b/web/app/views/users/_user_dropdown.html.erb index 397a80863..55c761ac5 100644 --- a/web/app/views/users/_user_dropdown.html.erb +++ b/web/app/views/users/_user_dropdown.html.erb @@ -21,7 +21,7 @@ <% else %> -
+ <% end %> diff --git a/web/config/routes.rb b/web/config/routes.rb index 5506ab3dd..435989713 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -236,6 +236,7 @@ Rails.application.routes.draw do match '/live_streams/claim' => 'api_live_streams#claim', :via => :post match '/live_streams/:slug' => 'api_live_streams#show', :via => :get match '/live_streams/stream_started' => 'api_live_streams#stream_started', :via => :post + match '/live_streams/stream_stop' => 'api_live_streams#stream_stop', :via => :post # music sessions match '/sessions/:id/participants/legacy' => 'api_music_sessions#participant_create_legacy', :via => :post # can be removed when new Create Session comes in diff --git a/web/spec/features/signin_spec.rb b/web/spec/features/signin_spec.rb index b558d2359..c125f5329 100644 --- a/web/spec/features/signin_spec.rb +++ b/web/spec/features/signin_spec.rb @@ -160,7 +160,7 @@ describe "signin", type: :feature do # if a cookie with the default domain is found with another, delete the one with the default domain it "delete duplicate session cookies" do - # this has the opposite effect of what you normally want, but still proves thath the cookie deleter is doing it's thing + # this has the opposite effect of what you normally want, but still proves that the cookie deleter is doing it's thing # here's why: by default, in our poltergeist tests are have a cookie domain of 127.0.0.1. # The ClearDuplicatedSession middleware will delete the 'default' domain cookie (in this case, the one that the server is making on logon) # any sort of wildcard cookie (like the one we create here, with a 'junk' value, will not be deleted, and @@ -181,7 +181,8 @@ describe "signin", type: :feature do # if a cookie with the default domain is found with another, delete the one with the default domain it "delete duplicate session cookies - verify middleware called" do - # this has the opposite effect of what you normally want, but still proves thath the cookie deleter is doing it's thing + # this has the opposite effect of what you normally want, but still proves that + # the cookie deleter is doing it's thing # here's why: by default, in our poltergeist tests are have a cookie domain of 127.0.0.1. # The ClearDuplicatedSession middleware will delete the 'default' domain cookie (in this case, the one that the server is making on logon) # any sort of wildcard cookie (like the one we create here, with a 'junk' value, will not be deleted, and