mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 16:28:01 -05:00
Add hooks for selfserve related events.
This commit is contained in:
committed by
Brian Simpson
parent
5967acfa83
commit
81a5dc36a1
@@ -39,6 +39,7 @@ from r2.lib import (
|
||||
authorize,
|
||||
emailer,
|
||||
inventory,
|
||||
hooks,
|
||||
)
|
||||
from r2.lib.db.queries import set_promote_status
|
||||
from r2.lib.memoize import memoize
|
||||
@@ -395,6 +396,7 @@ def void_campaign(link, campaign):
|
||||
if bid_record:
|
||||
a = Account._byID(link.author_id)
|
||||
authorize.void_transaction(a, bid_record.transaction, campaign._id)
|
||||
hooks.get_hook('campaign.void').call(link=link, campaign=campaign)
|
||||
|
||||
def auth_campaign(link, campaign, user, pay_id):
|
||||
"""
|
||||
@@ -498,12 +500,15 @@ def reject_promotion(link, reason=None):
|
||||
if not c.user or c.user._id != link.author_id:
|
||||
emailer.reject_promo(link, reason=reason)
|
||||
|
||||
hooks.get_hook('promotion.void').call(link=link)
|
||||
|
||||
|
||||
def unapprove_promotion(link):
|
||||
PromotionLog.add(link, 'status update: unapproved')
|
||||
# update the query queue
|
||||
set_promote_status(link, PROMOTE_STATUS.unseen)
|
||||
hooks.get_hook('promotion.void').call(link=link)
|
||||
|
||||
|
||||
def accepted_campaigns(offset=0):
|
||||
now = promo_datetime_now(offset=offset)
|
||||
@@ -578,6 +583,8 @@ def charge_pending(offset=1):
|
||||
except:
|
||||
print "Error on %s, campaign %s" % (l, camp._id)
|
||||
|
||||
hooks.get_hook('promote.charge_pending').call(offset=offset)
|
||||
|
||||
|
||||
def scheduled_campaigns_by_link(l, date=None):
|
||||
# A promotion/campaign is scheduled/live if it's in
|
||||
@@ -729,6 +736,7 @@ def make_daily_promotions(offset=0, test=False):
|
||||
print by_srid
|
||||
|
||||
finalize_completed_campaigns(daysago=offset+1)
|
||||
hooks.get_hook('promote.make_daily_promotions').call(offset=offset)
|
||||
|
||||
# after launching as many campaigns as possible, raise an exception to
|
||||
# report any error campaigns. (useful for triggering alerts in irc)
|
||||
|
||||
Reference in New Issue
Block a user