mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
Interest Collections: do not notify sales for 'after dark' collection
This commit is contained in:
@@ -511,7 +511,8 @@ share_reply = noreply@reddit.com
|
||||
feedback_email = reddit@gmail.com
|
||||
# the "from" address for orangered notifications
|
||||
notification_email = notifications@example.com
|
||||
|
||||
# email to ads team
|
||||
ads_email = ad-ops@reddit.com
|
||||
|
||||
############################################ POSTGRES
|
||||
db_user = reddit
|
||||
|
||||
@@ -2606,6 +2606,19 @@ class ApiController(RedditController):
|
||||
if not sr.domain:
|
||||
del kw['css_on_cname']
|
||||
|
||||
#notify ads if sr in a collection changes over_18 to true
|
||||
if kw.get('over_18', False) and not sr.over_18:
|
||||
collections = []
|
||||
for collection in Collection.get_all():
|
||||
if (sr.name in collection.sr_names
|
||||
and not collection.over_18):
|
||||
collections.append(collection.name)
|
||||
|
||||
if collections:
|
||||
msg = "%s now NSFW, in collection(s) %s"
|
||||
msg %= (sr.name, ', '.join(collections))
|
||||
emailer.sales_email(msg)
|
||||
|
||||
# do not clobber these fields if absent in request
|
||||
no_clobber = ('community_rules', 'key_color', 'related_subreddits')
|
||||
|
||||
|
||||
@@ -55,6 +55,13 @@ def _nerds_email(body, from_name, kind):
|
||||
Email.handler.add_to_queue(None, g.nerds_email, from_name, g.nerds_email,
|
||||
kind, body = body)
|
||||
|
||||
def _ads_email(body, from_name, kind):
|
||||
"""
|
||||
For sending email to ads
|
||||
"""
|
||||
Email.handler.add_to_queue(None, g.ads_email, from_name, g.ads_email,
|
||||
kind, body=body)
|
||||
|
||||
def _fraud_email(body, kind):
|
||||
"""
|
||||
For sending email to the fraud mailbox
|
||||
@@ -211,6 +218,10 @@ def nerds_email(body, from_name=g.domain):
|
||||
"""Queues a feedback email to the nerds running this site."""
|
||||
return _nerds_email(body, from_name, Email.Kind.NERDMAIL)
|
||||
|
||||
def ads_email(body, from_name=g.domain):
|
||||
"""Queues an email to the Sales team."""
|
||||
return _ads_email(body, from_name, Email.Kind.ADS_ALERT)
|
||||
|
||||
def share(link, emails, from_name = "", reply_to = "", body = ""):
|
||||
"""Queues a 'share link' email."""
|
||||
now = datetime.datetime.now(g.tz)
|
||||
|
||||
@@ -310,6 +310,7 @@ class Email(object):
|
||||
"FRAUD_ALERT",
|
||||
"USER_FRAUD",
|
||||
"MESSAGE_NOTIFICATION",
|
||||
"ADS_ALERT",
|
||||
)
|
||||
|
||||
# Do not remove anything from this dictionary! See above comment.
|
||||
@@ -339,6 +340,7 @@ class Email(object):
|
||||
Kind.FRAUD_ALERT: _("[selfserve] fraud alert"),
|
||||
Kind.USER_FRAUD: _("[selfserve] a user has committed fraud"),
|
||||
Kind.MESSAGE_NOTIFICATION: _("[reddit] message notification"),
|
||||
Kind.ADS_ALERT: _("[reddit] Ads Alert"),
|
||||
}
|
||||
|
||||
def __init__(self, user, thing, email, from_name, date, ip,
|
||||
|
||||
@@ -161,8 +161,9 @@ NO_TRANSACTION = 0
|
||||
|
||||
|
||||
class Collection(object):
|
||||
def __init__(self, name, sr_names, description=None):
|
||||
def __init__(self, name, sr_names, over_18=False, description=None):
|
||||
self.name = name
|
||||
self.over_18 = over_18
|
||||
self.sr_names = sr_names
|
||||
self.description = description
|
||||
|
||||
@@ -192,11 +193,32 @@ class CollectionStorage(tdb_cassandra.View):
|
||||
SR_NAMES_DELIM = '|'
|
||||
|
||||
@classmethod
|
||||
def set(cls, name, description, srs):
|
||||
rowkey = name
|
||||
def _from_columns(cls, name, columns):
|
||||
description = columns['description']
|
||||
sr_names = columns['sr_names'].split(cls.SR_NAMES_DELIM)
|
||||
over_18 = bool(columns.get("over_18", "False"))
|
||||
return Collection(name, sr_names, over_18=over_18, description=description)
|
||||
|
||||
@classmethod
|
||||
def _to_columns(cls, description, srs, over_18):
|
||||
columns = {
|
||||
'description': description,
|
||||
'sr_names': cls.SR_NAMES_DELIM.join(sr.name for sr in srs),
|
||||
'over_18': str(over_18),
|
||||
}
|
||||
return columns
|
||||
|
||||
@classmethod
|
||||
def set(cls, name, description, srs, over_18):
|
||||
rowkey = name
|
||||
columns = cls._to_columns(description, srs, over_18)
|
||||
cls._set_values(rowkey, columns)
|
||||
|
||||
@classmethod
|
||||
def set_over_18(cls, name, over_18):
|
||||
rowkey = name
|
||||
columns = {
|
||||
'over_18': str(over_18),
|
||||
}
|
||||
cls._set_values(rowkey, columns)
|
||||
|
||||
@@ -211,17 +233,13 @@ class CollectionStorage(tdb_cassandra.View):
|
||||
except tdb_cassandra.NotFoundException:
|
||||
return None
|
||||
|
||||
description = columns['description']
|
||||
sr_names = columns['sr_names'].split(cls.SR_NAMES_DELIM)
|
||||
return Collection(name, sr_names, description=description)
|
||||
return cls._from_columns(name, columns)
|
||||
|
||||
@classmethod
|
||||
def get_all(cls):
|
||||
ret = []
|
||||
for name, columns in cls._cf.get_range():
|
||||
description = columns['description']
|
||||
sr_names = columns['sr_names'].split(cls.SR_NAMES_DELIM)
|
||||
ret.append(Collection(name, sr_names, description=description))
|
||||
ret.append(cls._from_columns(name, columns))
|
||||
return ret
|
||||
|
||||
def delete(cls, name):
|
||||
|
||||
Reference in New Issue
Block a user