diff --git a/app/api/srch/search.rb b/app/api/srch/search.rb index 7c49e6f9d9..61bec709df 100644 --- a/app/api/srch/search.rb +++ b/app/api/srch/search.rb @@ -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, @@ -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, diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb index c1f62d971d..4406bfb03c 100644 --- a/app/channels/application_cable/connection.rb +++ b/app/channels/application_cable/connection.rb @@ -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 diff --git a/app/channels/room_channel.rb b/app/channels/room_channel.rb index c435da479f..de6f5ffc9a 100644 --- a/app/channels/room_channel.rb +++ b/app/channels/room_channel.rb @@ -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 @@ -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 diff --git a/app/channels/user_channel.rb b/app/channels/user_channel.rb index df58a75d89..9403c79968 100644 --- a/app/channels/user_channel.rb +++ b/app/channels/user_channel.rb @@ -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 diff --git a/app/channels/user_notification_channel.rb b/app/channels/user_notification_channel.rb index accb48deb7..04415cb27c 100644 --- a/app/channels/user_notification_channel.rb +++ b/app/channels/user_notification_channel.rb @@ -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