* VRFS-3082 - email alert if jamtrack fails
This commit is contained in:
parent
32b5e741cc
commit
989518fa68
|
|
@ -45,4 +45,5 @@ JamAdmin::Application.configure do
|
|||
config.show_log_configuration = true
|
||||
|
||||
config.email_generic_from = 'nobody-dev@jamkazam.com'
|
||||
config.email_alerts_alias = 'alerts-dev@jamkazam.com'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,6 +13,14 @@ module JamRuby
|
|||
sendgrid_unique_args :env => Environment.mode
|
||||
|
||||
def alerts(options)
|
||||
mail(to: APP_CONFIG.email_alerts_alias,
|
||||
from: APP_CONFIG.email_generic_from,
|
||||
body: options[:body],
|
||||
content_type: "text/plain",
|
||||
subject: options[:subject])
|
||||
end
|
||||
|
||||
def recurly_alerts(options)
|
||||
mail(to: APP_CONFIG.email_recurly_notice,
|
||||
from: APP_CONFIG.email_generic_from,
|
||||
body: options[:body],
|
||||
|
|
|
|||
|
|
@ -91,19 +91,19 @@ module JamRuby
|
|||
jam_track_right = jam_track.right_for_user(transaction.user) if jam_track
|
||||
if jam_track_right
|
||||
jam_track_right.destroy
|
||||
AdminMailer.alerts({
|
||||
AdminMailer.recurly_alerts({
|
||||
subject:"NOTICE: #{transaction.user.email} has had JamTrack: #{jam_track.name} revoked",
|
||||
body: "A void event came from Recurly for sale with Recurly invoice ID #{sale.recurly_invoice_id}. We deleted their right to the track in our own database as a result."
|
||||
}).deliver
|
||||
else
|
||||
AdminMailer.alerts({
|
||||
AdminMailer.recurly_alerts({
|
||||
subject:"NOTICE: #{transaction.user.email} got a refund, but unable to find JamTrackRight to delete",
|
||||
body: "This should just mean the user already has no rights to the JamTrackRight when the refund came in. Not a big deal, but sort of weird..."
|
||||
}).deliver
|
||||
end
|
||||
|
||||
else
|
||||
AdminMailer.alerts({
|
||||
AdminMailer.recurly_alerts({
|
||||
subject:"ACTION REQUIRED: #{transaction.user.email} got a refund it was not for total value of a JamTrack sale",
|
||||
body: "We received a refund notice for an amount that was not the same as the original sale. So, no action was taken in the database. sale total: #{sale.recurly_total_in_cents}, refund amount: #{transaction.amount_in_cents}"
|
||||
}).deliver
|
||||
|
|
@ -111,7 +111,7 @@ module JamRuby
|
|||
|
||||
|
||||
else
|
||||
AdminMailer.alerts({
|
||||
AdminMailer.recurly_alerts({
|
||||
subject: "ACTION REQUIRED: #{transaction.user.email} has refund on invoice with multiple JamTracks",
|
||||
body: "You will have to manually revoke any JamTrackRights in our database for the appropriate JamTracks"
|
||||
}).deliver
|
||||
|
|
|
|||
|
|
@ -1568,6 +1568,11 @@ module JamRuby
|
|||
verifier.generate(user.id)
|
||||
end
|
||||
|
||||
# URL to jam-admin
|
||||
def admin_url
|
||||
APP_CONFIG.admin_root_url + "/admin/users/" + id
|
||||
end
|
||||
|
||||
private
|
||||
def create_remember_token
|
||||
self.remember_token = SecureRandom.urlsafe_base64
|
||||
|
|
|
|||
|
|
@ -101,7 +101,9 @@ module JamRuby
|
|||
el: 'data',
|
||||
ev: data.to_s
|
||||
}
|
||||
|
||||
RestClient.post(APP_CONFIG.ga_endpoint, params: params, timeout: 8, open_timeout: 8)
|
||||
|
||||
@@log.info("done (#{category}, #{action})")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@ JAMKAZAM_TESTING_BUCKET = 'jamkazam-testing' # cuz i'm not comfortable using aws
|
|||
def app_config
|
||||
klass = Class.new do
|
||||
|
||||
def admin_root_url
|
||||
'http://localhost:3333'
|
||||
end
|
||||
|
||||
def email_alerts_alias
|
||||
'alerts@jamkazam.com'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ context.JK.DownloadJamTrack = class DownloadJamTrack
|
|||
if @state == @states.errored
|
||||
data.result = 'error'
|
||||
data.detail = @errorReason
|
||||
@rest.createAlert("JamTrack Sync failed for #{context.JK.currentUserName}", data)
|
||||
else
|
||||
data.result = 'success'
|
||||
|
||||
|
|
|
|||
|
|
@ -1662,6 +1662,19 @@
|
|||
});
|
||||
}
|
||||
|
||||
function createAlert(subject, data) {
|
||||
var message = {subject:subject};
|
||||
$.extend(message, data);
|
||||
console.log("message", message)
|
||||
return $.ajax({
|
||||
type: "POST",
|
||||
url: '/api/alerts',
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(message),
|
||||
});
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
return self;
|
||||
}
|
||||
|
|
@ -1811,6 +1824,7 @@
|
|||
this.addRecordingTimeline = addRecordingTimeline;
|
||||
this.playJamTrack = playJamTrack;
|
||||
this.createSignupHint = createSignupHint;
|
||||
this.createAlert = createAlert;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
|
||||
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
|
||||
|
||||
|
||||
end
|
||||
|
||||
render json: {}, :status => :ok
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -126,7 +126,8 @@ if defined?(Bundler)
|
|||
config.external_port = ENV['EXTERNAL_PORT'] || 3000
|
||||
config.external_protocol = ENV['EXTERNAL_PROTOCOL'] || 'http://'
|
||||
config.external_root_url = "#{config.external_protocol}#{config.external_hostname}#{(config.external_port == 80 || config.external_port == 443) ? '' : ':' + config.external_port.to_s}"
|
||||
|
||||
config.admin_port = ENV['ADMIN_PORT'] || 3333
|
||||
config.admin_root_url = "#{config.external_protocol}#{config.external_hostname}#{(config.admin_port == 80 || config.admin_port == 443) ? '' : ':' + config.admin_port.to_s}"
|
||||
# set this to false if you want to disable signups (lock down public user creation)
|
||||
config.signup_enabled = true
|
||||
|
||||
|
|
@ -328,5 +329,6 @@ if defined?(Bundler)
|
|||
|
||||
config.minimal_curtain = false
|
||||
config.video_available = "none"
|
||||
config.alerts_api_enabled = true
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -91,5 +91,7 @@ SampleApp::Application.configure do
|
|||
config.youtube_app_name = "JamKazamDev"
|
||||
config.jam_tracks_available=true
|
||||
config.minimal_curtain = true
|
||||
config.video_available="full"
|
||||
config.video_available= ENV['VIDEO_AVAILABILITY'] || "none"
|
||||
config.email_generic_from = 'nobody-dev@jamkazam.com'
|
||||
config.email_alerts_alias = 'alerts-dev@jamkazam.com'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -563,5 +563,7 @@ SampleApp::Application.routes.draw do
|
|||
|
||||
match '/signup_hints' => 'api_signup_hints#create', :via => :post
|
||||
match '/signup_hints/:id' => 'api_signup_hints#show', :via => :get, :as => :api_signup_hint_detail
|
||||
|
||||
match '/alerts' => 'api_alerts#create', :via => :post
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue