* Update rubocop-todo.yml with new violations * Fix Layout/EmptyLine* rules * Fix Layout/Indentation* rules * Fix remaining Layout/* rules * Fix Lint/DuplicateMethods by removing unused accessor * Fix Lint/IneffectiveAccessModifier * Fix Lint/MissingCopEnableDirective * Re-run rubocop auto gen config * Fix Layout/RescueEnsureAlignment * Fix Naming/* rules * Fix some RSpec/* rules * Fix typos * Fix RSpec/LetBeforeExamples * Series should only be an attr_writer, not an attr_accessor * Fix RSpec/InstanceVariable * Fix RSpec/InstanceVariable * Fix RSpec/RepeatedDescription and RSpec/RepeatedExample * Fix Style/ClassAndModuleChildren * Fix Style/ConditionalAssignment * Fix some Style/* rules * Trigger Travis CI build because failing tests are not failing locally * Revert "Fix Style/ClassAndModuleChildren" This reverts commit 1686801d8a1516ba1894f79e24401a20dea65f99.
27 lines
820 B
Ruby
27 lines
820 B
Ruby
class PusherController < ApplicationController
|
|
def auth
|
|
if valid_channel
|
|
response = Pusher.authenticate(params[:channel_name], params[:socket_id],
|
|
user_id: current_user.id) # => required
|
|
render json: response
|
|
else
|
|
render json: { text: "Forbidden", status: "403" }
|
|
end
|
|
end
|
|
|
|
def valid_channel
|
|
valid_private_channel || valid_presence_channel
|
|
end
|
|
|
|
def valid_private_channel
|
|
current_user && params[:channel_name] == "private-message-notifications-#{current_user.id}"
|
|
end
|
|
|
|
def valid_presence_channel
|
|
return false unless params[:channel_name].include?("presence-channel-")
|
|
|
|
id = params[:channel_name].split("presence-channel-")[1].split("-")[0]
|
|
channel = ChatChannel.find(id)
|
|
channel.has_member?(current_user)
|
|
end
|
|
end
|