This commit is contained in:
Seth Call 2020-05-01 14:06:27 -05:00
commit b8f9f18363
12 changed files with 114 additions and 8 deletions

View File

@ -392,4 +392,5 @@ amazon_v2.sql
store_backend_details_rate_session.sql
invited_user_receiver.sql
live_streams.sql
live_stream_notify.sql
find_sessions_2020.sql

View File

@ -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
);

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -21,7 +21,7 @@
<!-- end profile area -->
<% else %>
<div class="user"><a class="signin" href="/signup">Sign Up</a>&nbsp;or&nbsp;<a class="signin real-signin" href="/signin">Sign In</a></div>
<div class="user"><a class="signin" href="/signup" rel="external">Sign Up</a>&nbsp;or&nbsp;<a class="signin real-signin" href="/signin">Sign In</a></div>
<% end %>
<!-- avatar -->

View File

@ -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

View File

@ -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