40 lines
779 B
Ruby
40 lines
779 B
Ruby
|
|
class ApiAlertsController < ApiController
|
|
|
|
before_filter :api_signed_in_user
|
|
|
|
|
|
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
|
|
}).deliver_now
|
|
|
|
|
|
end
|
|
|
|
render json: {}, :status => :ok
|
|
|
|
|
|
end
|
|
|
|
end
|