jam-cloud/web/app/controllers/api_diagnostics_controller.rb

24 lines
741 B
Ruby
Raw Permalink Normal View History

2014-04-30 03:01:28 +00:00
class ApiDiagnosticsController < ApiController
before_filter :api_signed_in_user
respond_to :json
def create
data = params[:data].to_json if params[:data]
2014-04-30 03:01:28 +00:00
@diagnostic = Diagnostic.new
@diagnostic.type = params[:type]
@diagnostic.data = data
2014-04-30 03:01:28 +00:00
@diagnostic.user = current_user
@diagnostic.creator = Diagnostic::CLIENT
@diagnostic.save
# update last jam info if network test attempted
if @diagnostic.type == 'NETWORK_TEST_RESULT' && params[:data] && params[:data]['client_id']
connection = Connection.find_by_client_id(params[:data]['client_id'])
current_user.update_addr_loc(connection, User::JAM_REASON_NETWORK_TEST)
end
2014-04-30 03:01:28 +00:00
respond_with_model(@diagnostic, new: true)
end
end