From 30965c6351a4db3897617a0b0d9ae8aabd06d930 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 15 Sep 2015 05:23:27 -0500 Subject: [PATCH] * allow jamblaster to fetch http --- ruby/lib/jam_ruby/models/jam_track_right.rb | 4 ++-- web/app/controllers/api_jam_tracks_controller.rb | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ruby/lib/jam_ruby/models/jam_track_right.rb b/ruby/lib/jam_ruby/models/jam_track_right.rb index f0749dc94..5217b620d 100644 --- a/ruby/lib/jam_ruby/models/jam_track_right.rb +++ b/ruby/lib/jam_ruby/models/jam_track_right.rb @@ -99,9 +99,9 @@ module JamRuby # the idea is that this is used when a user who has the rights to this tries to download this JamTrack # we would verify their rights (can_download?), and generates a URL in response to the click so that they can download # but the url is short lived enough so that it wouldn't be easily shared - def sign_url(expiration_time = 120, bitrate=48) + def sign_url(expiration_time = 120, bitrate=48, secure=true) field_name = (bitrate==48) ? "url_48" : "url_44" - s3_manager.sign_url(self[field_name], {:expires => expiration_time, :secure => true}) + s3_manager.sign_url(self[field_name], {:expires => expiration_time, :secure => secure}) end def delete_s3_files diff --git a/web/app/controllers/api_jam_tracks_controller.rb b/web/app/controllers/api_jam_tracks_controller.rb index 52b57bc77..428018462 100644 --- a/web/app/controllers/api_jam_tracks_controller.rb +++ b/web/app/controllers/api_jam_tracks_controller.rb @@ -101,7 +101,11 @@ class ApiJamTracksController < ApiController @jam_track_right.last_downloaded_at = now @jam_track_right.first_downloaded_at = now if @jam_track_right.first_downloaded_at.nil? @jam_track_right.save! - redirect_to @jam_track_right.sign_url(120, sample_rate) + + is_jamblaster = !!params[:is_jamblaster] + + # if it's not the jamblaster, keep the URL https + redirect_to @jam_track_right.sign_url(120, sample_rate, !is_jamblaster) else @jam_track_right.enqueue_if_needed(sample_rate) render :json => { :message => "not available, digitally signing Jam Track offline." }, :status => 202