From 4e0ff8a7ca4fc405922d2763d8564524a7e5a39d Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Fri, 13 Mar 2015 09:58:10 -0500 Subject: [PATCH] send email for new customers, closes #103 --- app/stripe_webhook.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/stripe_webhook.rb b/app/stripe_webhook.rb index cc6efbab..00b04839 100644 --- a/app/stripe_webhook.rb +++ b/app/stripe_webhook.rb @@ -1,8 +1,15 @@ post '/stripe_webhook' do event = JSON.parse request.body.read if event['type'] == 'customer.created' - username = event['data']['object']['description'] + username = event['data']['object']['description'].split(' - ').first email = event['data']['object']['email'] + + EmailWorker.perform_async({ + from: 'web@neocities.org', + to: 'contact@neocities.org', + subject: "[Neocities] New customer: #{username}", + body: "#{username}\n#{email}\n#{Site[username: username].uri}" + }) end 'ok' -end \ No newline at end of file +end