* Initial automatic cleanup with rubocop * Fix syntax error introduced by rubocop * Cleanup seeds file * Cleanup lib folder * Exclude bin folder because it contains auto generated files * Make Rubocop a little bit more chatty * Block length should not include comments in the count * Cleanup config folder * Cleanup specs * Updated Rubocop version and generated a todo file * Fix broken ArticlesApi spec * Fix tests * Restored rubocop pre-commit hook
26 lines
819 B
Ruby
26 lines
819 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
|