Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/reports/bin/mailDigests.py

Issue 6246174612783104: Issue 535 - Contact form cannot deal with commas in sender`s name (Closed)
Patch Set: Created May 22, 2014, 8:13 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2014 Eyeo GmbH 4 # Copyright (C) 2006-2014 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details. 13 # GNU General Public License for more details.
14 # 14 #
15 # You should have received a copy of the GNU General Public License 15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17 17
18 import MySQLdb, os, sys, re, marshal 18 import MySQLdb, os, sys, re, marshal
19 from datetime import date 19 from datetime import date
20 from time import time 20 from time import time
21 from email.utils import parseaddr 21 from email.utils import parseaddr
22 from sitescripts.utils import get_config, setupStderr 22 from sitescripts.utils import get_config, setupStderr
23 from sitescripts.templateFilters import formatmime 23 from sitescripts.templateFilters import formatmime, emailaddr
24 from sitescripts.reports.utils import mailDigest, getReports, getReportSubscript ions, calculateReportSecret, getDigestId, getDigestSecret, getUserUsefulnessScor e 24 from sitescripts.reports.utils import mailDigest, getReports, getReportSubscript ions, calculateReportSecret, getDigestId, getDigestSecret, getUserUsefulnessScor e
25 import sitescripts.subscriptions.subscriptionParser as subscriptionParser 25 import sitescripts.subscriptions.subscriptionParser as subscriptionParser
26 26
27 def loadSubscriptions(): 27 def loadSubscriptions():
28 global interval, weekDay 28 global interval, weekDay
29 29
30 subscriptions = subscriptionParser.readSubscriptions() 30 subscriptions = subscriptionParser.readSubscriptions()
31 31
32 results = {} 32 results = {}
33 resultList = [] 33 resultList = []
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 sendMail(subscription, groups) 121 sendMail(subscription, groups)
122 122
123 def sendMail(subscription, groups): 123 def sendMail(subscription, groups):
124 if hasattr(subscription, 'email'): 124 if hasattr(subscription, 'email'):
125 email = subscription.email 125 email = subscription.email
126 else: 126 else:
127 email = subscription['email'] 127 email = subscription['email']
128 128
129 name, address = parseaddr(email) 129 name, address = parseaddr(email)
130 email = formatmime(name) + ' <' + formatmime(address) + '>' 130 email = formatmime(emailaddr((name, address)))
131 131
132 id = getDigestId(address) 132 id = getDigestId(address)
133 digestLink = get_config().get('reports', 'urlRoot') + 'digest?id=%s&secret=%s' % (id, getDigestSecret(id, date.today().isocalendar())) 133 digestLink = get_config().get('reports', 'urlRoot') + 'digest?id=%s&secret=%s' % (id, getDigestSecret(id, date.today().isocalendar()))
134 134
135 mailDigest({'email': email, 'digestLink': digestLink, 'subscription': subscrip tion, 'groups': groups}) 135 mailDigest({'email': email, 'digestLink': digestLink, 'subscription': subscrip tion, 'groups': groups})
136 136
137 def calculateReportWeight(report, subscriptions): 137 def calculateReportWeight(report, subscriptions):
138 global currentTime, startTime 138 global currentTime, startTime
139 139
140 weight = 1.0 140 weight = 1.0
141 if report['type'] == 'false positive' or report['type'] == 'false negative': 141 if report['type'] == 'false positive' or report['type'] == 'false negative':
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 if interval == 'week': 176 if interval == 'week':
177 startTime = currentTime - 7*24*60*60 177 startTime = currentTime - 7*24*60*60
178 elif interval == 'day': 178 elif interval == 'day':
179 startTime = currentTime - 24*60*60 179 startTime = currentTime - 24*60*60
180 180
181 fakeSubscription = {'url': 'https://fake.adblockplus.org', 'name': get_config( ).get('reports', 'defaultSubscriptionName'), 'email': get_config().get('reports' , 'defaultSubscriptionRecipient')} 181 fakeSubscription = {'url': 'https://fake.adblockplus.org', 'name': get_config( ).get('reports', 'defaultSubscriptionName'), 'email': get_config().get('reports' , 'defaultSubscriptionRecipient')}
182 subscriptions, subscriptionList = loadSubscriptions() 182 subscriptions, subscriptionList = loadSubscriptions()
183 subscriptionList.append(fakeSubscription) 183 subscriptionList.append(fakeSubscription)
184 reports = scanReports() 184 reports = scanReports()
185 sendNotifications(reports) 185 sendNotifications(reports)
OLDNEW

Powered by Google App Engine
This is Rietveld