Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rubocop errors in app/api & app/channels #6425

Merged
merged 2 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/api/srch/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Search < Grape::API
if results.present?
docs = results.map do |model|
DocResult.new(
doc_type: 'USERS',
doc_type: 'USERS',
doc_url: '/profile/' + model.name,
doc_title: model.username,
latitude: model.lat,
Expand Down Expand Up @@ -181,7 +181,7 @@ class Search < Grape::API
DocList.new('', search_request)
end
end

# Request URL should be /api/srch/nodes?query=QRY
desc 'Perform a search of nodes', hidden: false,
is_array: false,
Expand Down
17 changes: 6 additions & 11 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@ class Connection < ActionCable::Connection::Base
def connect
self.current_user = find_verified_user
end

def find_verified_user
if cookies.signed['user_token'] != nil
user = User.where(persistence_token: cookies.signed['user_token'])
if user.any?
return user.first
else
return nil
end
else
return nil
end
return if cookies.signed['user_token'].nil?

user = User.where(persistence_token: cookies.signed['user_token'])

return user.first if user.any?
end
end
end
7 changes: 3 additions & 4 deletions app/channels/room_channel.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# This is a general channel connected to all active session
class RoomChannel < ApplicationCable::Channel

def subscribed
stream_from "room_channel"
end
Expand All @@ -10,8 +9,8 @@ def unsubscribed
end

def speak(message)
if current_user && current_user.role == "admin"
ActionCable.server.broadcast 'room_channel', message: message["message"]
end
return unless current_user && current_user.role == "admin"

ActionCable.server.broadcast 'room_channel', message: message["message"]
end
end
2 changes: 1 addition & 1 deletion app/channels/user_channel.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class UserChannel < ApplicationCable::Channel
def subscribed
if current_user != nil
if !current_user.nil?
stream_from "users:#{current_user.id}"
else
reject
Expand Down
2 changes: 1 addition & 1 deletion app/channels/user_notification_channel.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class UserNotificationChannel < ApplicationCable::Channel
def subscribed
if current_user != nil
if !current_user.nil?
stream_from "users:notification:#{current_user.id}"
else
reject
Expand Down