diff --git a/r2/r2/lib/promote.py b/r2/r2/lib/promote.py index 64a8aaa20..1db5df1d2 100644 --- a/r2/r2/lib/promote.py +++ b/r2/r2/lib/promote.py @@ -498,12 +498,25 @@ def accept_promotion(link): # update the query queue set_promote_status(link, PROMOTE_STATUS.accepted) + + # campaigns that should be live now must be updated now = promo_datetime_now(0) if link._fullname in set(l.thing_name for l in PromotionWeights.get_campaigns(now)): PromotionLog.add(link, 'Marked promotion for acceptance') charge_pending(0) # campaign must be charged before it will go live queue_changed_promo(link, "accepted") + + # campaigns that were charged and will go live in the future must be updated + future_campaigns = [camp for camp in PromoCampaign._by_link(link._id) + if camp.start_date > now] + transactions = get_transactions(link, future_campaigns) + charged_campaigns = [camp for camp in future_campaigns + if (transactions.get(camp._id) and + transactions.get(camp._id).is_charged())] + for campaign in charged_campaigns: + hooks.get_hook('campaign.edit').call(link=link, campaign=campaign) + if link._spam: link._spam = False link._commit()