diff --git a/web/app/assets/javascripts/sessionList.js b/web/app/assets/javascripts/sessionList.js index a54ba7cec..2dae2c083 100644 --- a/web/app/assets/javascripts/sessionList.js +++ b/web/app/assets/javascripts/sessionList.js @@ -135,8 +135,7 @@ }); if (showJoinLink) { - // wire up the Join Link to the T&Cs dialog - + // wire up the Join Link to the T&Cs dialog $('.join-link', $parentRow).click(function(evt) { if(!context.JK.guardAgainstBrowser(app)) { return false; diff --git a/web/app/assets/javascripts/session_utils.js b/web/app/assets/javascripts/session_utils.js index 0c22b0108..eea0d79a9 100644 --- a/web/app/assets/javascripts/session_utils.js +++ b/web/app/assets/javascripts/session_utils.js @@ -138,22 +138,8 @@ return; } - if ("invitations" in session) { - var invitation; - // user has invitations for this session - for (var i=0; i < session.invitations.length; i++) { - invitation = session.invitations[i]; - // session contains an invitation for this user - if (invitation.receiver_id === context.JK.currentUserId) { - hasInvitation = true; - break; - } - } - } - if (session) { - // if user has an invitation, always open terms and allow joining regardless of settings - if (hasInvitation) { + if (session.can_join) { logger.debug("Found invitation for user " + context.JK.currentUserId + ", session " + sessionId); openJoinSessionTerms(sessionId); } diff --git a/web/app/views/api_music_sessions/show.rabl b/web/app/views/api_music_sessions/show.rabl index 98f642a7f..e4c264a7c 100644 --- a/web/app/views/api_music_sessions/show.rabl +++ b/web/app/views/api_music_sessions/show.rabl @@ -15,6 +15,10 @@ else attributes :id, :name, :description, :musician_access, :approval_required, :fan_access, :fan_chat, :band_id, :user_id, :claimed_recording_initiator_id, :track_changes_counter, :max_score + node :can_join do |session| + session.can_join?(current_user, true) + end + node :genres do |item| [item.genre.description] # XXX: need to return single genre; not array end diff --git a/web/app/views/api_music_sessions/show_history.rabl b/web/app/views/api_music_sessions/show_history.rabl index e027c0874..c86e6e04f 100644 --- a/web/app/views/api_music_sessions/show_history.rabl +++ b/web/app/views/api_music_sessions/show_history.rabl @@ -21,6 +21,10 @@ else :language, :recurring_mode, :language_description, :scheduled_start_date, :access_description, :timezone, :timezone_id, :timezone_description, :musician_access_description, :fan_access_description, :session_removed_at, :legal_policy, :open_rsvps, :is_unstructured_rsvp? + node :can_join do |session| + session.can_join?(current_user, true) + end + node :share_url do |history| unless history.share_token.nil? share_token_url(history.share_token.token)