mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
added table for tracking rejected mail
This commit is contained in:
@@ -115,7 +115,6 @@ def send_queued_mail():
|
||||
clear = True
|
||||
|
||||
should_queue = email.should_queue()
|
||||
|
||||
# check only on sharing that the mail is invalid
|
||||
if email.kind == Email.Kind.SHARE and should_queue:
|
||||
email.body = Share(username = email.from_name(),
|
||||
@@ -145,9 +144,10 @@ def send_queued_mail():
|
||||
email.subject = "[ad_inq] feedback from '%s'" % \
|
||||
email.from_name()
|
||||
sendmail(email)
|
||||
# handle other types of emails here
|
||||
# handle failure
|
||||
else:
|
||||
pass
|
||||
email.set_sent(rejected = True)
|
||||
|
||||
finally:
|
||||
session.quit()
|
||||
|
||||
|
||||
@@ -75,8 +75,8 @@ def mail_queue(metadata):
|
||||
|
||||
)
|
||||
|
||||
def sent_mail_table(metadata):
|
||||
return sa.Table(settings.DB_APP_NAME + '_sent_mail', metadata,
|
||||
def sent_mail_table(metadata, name = 'sent_mail'):
|
||||
return sa.Table(settings.DB_APP_NAME + '_' + name, metadata,
|
||||
# tracking hash of the email
|
||||
sa.Column('msg_hash', sa.String, primary_key=True),
|
||||
|
||||
@@ -135,15 +135,20 @@ class EmailHandler(object):
|
||||
create_table(self.opt_table, indices, force = force)
|
||||
|
||||
self.track_table = sent_mail_table(self.metadata)
|
||||
indices = [index_str(self.track_table, 'to_addr', 'to_addr'),
|
||||
index_str(self.track_table, 'date', 'date'),
|
||||
index_str(self.track_table, 'ip', 'ip'),
|
||||
index_str(self.track_table, 'kind', 'kind'),
|
||||
index_str(self.track_table, 'fullname', 'fullname'),
|
||||
index_str(self.track_table, 'account_id', 'account_id'),
|
||||
index_str(self.track_table, 'msg_hash', 'msg_hash'),
|
||||
]
|
||||
create_table(self.track_table, indices, force = force)
|
||||
self.reject_table = sent_mail_table(self.metadata, name = "reject_mail")
|
||||
|
||||
def sent_indices(tab):
|
||||
indices = [index_str(tab, 'to_addr', 'to_addr'),
|
||||
index_str(tab, 'date', 'date'),
|
||||
index_str(tab, 'ip', 'ip'),
|
||||
index_str(tab, 'kind', 'kind'),
|
||||
index_str(tab, 'fullname', 'fullname'),
|
||||
index_str(tab, 'account_id', 'account_id'),
|
||||
index_str(tab, 'msg_hash', 'msg_hash'),
|
||||
]
|
||||
|
||||
create_table(self.track_table, sent_indices(self.track_table), force = force)
|
||||
create_table(self.reject_table, sent_indices(self.reject_table), force = force)
|
||||
|
||||
def __repr__(self):
|
||||
return "<email-handler>"
|
||||
@@ -320,11 +325,11 @@ class Email(object):
|
||||
(self.kind == self.Kind.OPTOUT or
|
||||
not has_opted_out(self.to_addr))
|
||||
|
||||
def set_sent(self, date = None):
|
||||
def set_sent(self, date = None, rejected = False):
|
||||
if not self.sent:
|
||||
from pylons import g
|
||||
self.date = date or datetime.datetime.now(g.tz)
|
||||
t = self.handler.track_table
|
||||
t = self.handler.reject_table if rejected else self.handler.track_table
|
||||
t.insert().execute({t.c.account_id:
|
||||
self.user._id if self.user else 0,
|
||||
t.c.to_addr : self.to_addr,
|
||||
|
||||
@@ -830,6 +830,15 @@ a.star { text-decoration: none; color: #ff8b60 }
|
||||
.sharetable.preftable th { padding-bottom: 5px; padding-top: 5px; }
|
||||
.sharetable.preftable button { margin-top: 10px }
|
||||
|
||||
.share-summary { width: 95%; margin-top: 10px; }
|
||||
.share-summary .head td { width: 50%; font-size: large; text-align: center }
|
||||
.share-summary td { vertical-align: top;}
|
||||
.share-summary > tbody > tr > td {
|
||||
padding-left: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.share-summary th { padding: 5px; border-bottom: 1px solid #000; }
|
||||
|
||||
.sponsored .entry { margin-right: 20px;}
|
||||
|
||||
.sponsored .titlerow { background: #fcfcfc;
|
||||
|
||||
Reference in New Issue
Block a user