forked from External/greenlight
		
	Rework on landingController to reduce duplication
This commit is contained in:
		@@ -17,6 +17,8 @@
 | 
				
			|||||||
class LandingController < ApplicationController
 | 
					class LandingController < ApplicationController
 | 
				
			||||||
  include BbbApi
 | 
					  include BbbApi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  helper_method :admin?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def index
 | 
					  def index
 | 
				
			||||||
    # If guest access is disabled, redirect the user to the guest landing and force login.
 | 
					    # If guest access is disabled, redirect the user to the guest landing and force login.
 | 
				
			||||||
    redirect_to guest_path if Rails.configuration.disable_guest_access
 | 
					    redirect_to guest_path if Rails.configuration.disable_guest_access
 | 
				
			||||||
@@ -51,21 +53,13 @@ class LandingController < ApplicationController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  def wait_for_moderator
 | 
					  def wait_for_moderator
 | 
				
			||||||
    WaitingList.add(params[:room_id], params[:name], params[:id])
 | 
					    WaitingList.add(params[:room_id], params[:name], params[:id])
 | 
				
			||||||
    ActionCable.server.broadcast 'refresh_meetings',
 | 
					    send_alert(params, 'waiting')
 | 
				
			||||||
      method: 'waiting',
 | 
					 | 
				
			||||||
      meeting: params[:id],
 | 
					 | 
				
			||||||
      room: params[:room_id],
 | 
					 | 
				
			||||||
      user: params[:name]
 | 
					 | 
				
			||||||
    render layout: false
 | 
					    render layout: false
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def no_longer_waiting
 | 
					  def no_longer_waiting
 | 
				
			||||||
    WaitingList.remove(params[:room_id], params[:name], params[:id])
 | 
					    WaitingList.remove(params[:room_id], params[:name], params[:id])
 | 
				
			||||||
    ActionCable.server.broadcast 'refresh_meetings',
 | 
					    send_alert(params, 'no_longer_waiting')
 | 
				
			||||||
      method: 'no_longer_waiting',
 | 
					 | 
				
			||||||
      meeting: params[:id],
 | 
					 | 
				
			||||||
      room: params[:room_id],
 | 
					 | 
				
			||||||
      user: params[:name]
 | 
					 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def session_status_refresh
 | 
					  def session_status_refresh
 | 
				
			||||||
@@ -83,7 +77,6 @@ class LandingController < ApplicationController
 | 
				
			|||||||
  def admin?
 | 
					  def admin?
 | 
				
			||||||
    @user && @user == current_user
 | 
					    @user && @user == current_user
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  helper_method :admin?
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def preferences
 | 
					  def preferences
 | 
				
			||||||
    @user = current_user
 | 
					    @user = current_user
 | 
				
			||||||
@@ -124,4 +117,11 @@ class LandingController < ApplicationController
 | 
				
			|||||||
    render :action => 'rooms'
 | 
					    render :action => 'rooms'
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def send_alert(params, method)
 | 
				
			||||||
 | 
					    ActionCable.server.broadcast 'refresh_meetings',
 | 
				
			||||||
 | 
					      method: method,
 | 
				
			||||||
 | 
					      meeting: params[:id],
 | 
				
			||||||
 | 
					      room: params[:room_id],
 | 
				
			||||||
 | 
					      user: params[:name]
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user