From c5a69b2c76dc322048c002feee55b8e69e015cbb Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 12 Nov 2023 04:18:03 -0800 Subject: [PATCH] manually increase upload bandwidth for users activating paypal codes --- app/controllers/subscriptions_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/controllers/subscriptions_controller.rb b/app/controllers/subscriptions_controller.rb index 2edb00639..685f1fca3 100644 --- a/app/controllers/subscriptions_controller.rb +++ b/app/controllers/subscriptions_controller.rb @@ -219,6 +219,17 @@ def redeem_code # If it looks like a valid code and quacks like a valid code, it's probably a valid code code.activate!(current_user) + # Also, give the user the Premium upload bandwidth + # TODO we should probably use SubscriptionService#recalculate_bandwidth_for() here so we can reduce + # code reuse + premium_bandwidth = 10_000_000 # skipping a lookup to BillingPlan.find(4).bonus_bandwidth_kb + bandwidth_remaining = premium_bandwidth - current_user.image_uploads.sum(:src_file_size) / 1000 + + # Also add referral bandwidth bonus to total (100MB per referral) + bandwidth_remaining += current_user.referrals.count * 100_000 + + current_user.update(upload_bandwidth_kb: bandwidth_remaining) + current_user.notifications.create( message_html: "
You activated a Premium Code!
Click here to turn on your Premium pages.
", icon: 'star',