2015-04-23 15:34:17 +00:00
|
|
|
|
|
|
|
|
class ApiAlertsController < ApiController
|
|
|
|
|
|
2020-05-27 04:19:50 +00:00
|
|
|
before_filter :api_signed_in_user, only: :create
|
2015-04-23 15:34:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def log
|
|
|
|
|
@log || Logging.logger[ApiAlertsController]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
|
|
|
|
|
if Rails.application.config.alerts_api_enabled
|
|
|
|
|
|
|
|
|
|
result = params[:result]
|
|
|
|
|
detail = params[:detail]
|
|
|
|
|
|
|
|
|
|
body = ""
|
|
|
|
|
body << "User: " + current_user.admin_url + "\n"
|
|
|
|
|
body << "Reason: #{result}\n" if result
|
|
|
|
|
body << "Detail: #{detail}\n" if detail
|
|
|
|
|
body << "\n\n\ndata:\n-----\n"
|
|
|
|
|
body << JSON.pretty_generate(params)
|
|
|
|
|
|
|
|
|
|
AdminMailer.alerts({
|
|
|
|
|
subject:params[:subject] || 'Alerts API (no subject)',
|
|
|
|
|
body:body
|
2016-07-17 15:16:27 +00:00
|
|
|
}).deliver_now
|
2015-04-23 15:34:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
render json: {}, :status => :ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-27 04:19:50 +00:00
|
|
|
def bad_audio
|
|
|
|
|
|
|
|
|
|
subject = "Bad Audio"
|
|
|
|
|
body = header
|
|
|
|
|
if current_user
|
|
|
|
|
subject + " - #{current_user.name}"
|
|
|
|
|
body << "<h1>User - #{current_user.name} - #{current_user.email}</h1>"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#body << params.to_yaml
|
|
|
|
|
|
|
|
|
|
body << "<br/><br/>"
|
|
|
|
|
body << "<pre>"
|
|
|
|
|
body << JSON.pretty_generate(params["api_alert"])
|
|
|
|
|
body << "</pre>"
|
|
|
|
|
AdminMailer.pretty({ to: Rails.application.config.bugs_alias,
|
|
|
|
|
subject:params[:subject] || subject,
|
|
|
|
|
body:body
|
|
|
|
|
}).deliver_now
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render json: {}, :status => :ok
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
def header
|
|
|
|
|
"<html><body>"
|
|
|
|
|
end
|
|
|
|
|
def footer
|
|
|
|
|
"</body></html>"
|
|
|
|
|
end
|
2015-04-23 15:34:17 +00:00
|
|
|
end
|