OLD | NEW |
1 import hashlib | 1 import hashlib |
2 import hmac | 2 import hmac |
3 import json | 3 import json |
4 import logging | 4 import logging |
5 import time | 5 import time |
6 | 6 |
7 from google.appengine.api import app_identity | 7 from google.appengine.api import app_identity |
8 from google.appengine.api import mail | 8 from google.appengine.api import mail |
9 from google.appengine.ext import ndb | 9 from google.appengine.ext import ndb |
10 import webapp2 | 10 import webapp2 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 self.error(400) | 161 self.error(400) |
162 return | 162 return |
163 | 163 |
164 # Emails can only come from the app ID, so we split on '@' here just in | 164 # Emails can only come from the app ID, so we split on '@' here just in |
165 # case the user specified a full email address. | 165 # case the user specified a full email address. |
166 from_addr_prefix = build_data.get('from_addr', 'buildbot').split('@')[0] | 166 from_addr_prefix = build_data.get('from_addr', 'buildbot').split('@')[0] |
167 from_addr = from_addr_prefix + '@%s.appspotmail.com' % ( | 167 from_addr = from_addr_prefix + '@%s.appspotmail.com' % ( |
168 app_identity.get_application_id()) | 168 app_identity.get_application_id()) |
169 | 169 |
170 subject_template = build_data.get('subject_template') | 170 subject_template = build_data.get('subject_template') |
| 171 status_header = build_data.get('status_header') |
171 | 172 |
172 template = gatekeeper_mailer.MailTemplate(build_data['waterfall_url'], | 173 template = gatekeeper_mailer.MailTemplate(build_data['waterfall_url'], |
173 build_data['build_url'], | 174 build_data['build_url'], |
174 build_data['project_name'], | 175 build_data['project_name'], |
175 from_addr, | 176 from_addr, |
176 subject=subject_template) | 177 subject=subject_template, |
| 178 status_header=status_header) |
177 | 179 |
178 | 180 |
179 text_content, html_content, subject = template.genMessageContent(build_data) | 181 text_content, html_content, subject = template.genMessageContent(build_data) |
180 | 182 |
181 sentries = ['gatekeeper-ng@chromium-gatekeeper-sentry.appspotmail.com', | 183 sentries = ['gatekeeper-ng@chromium-gatekeeper-sentry.appspotmail.com', |
182 'stip@chromium.org'] | 184 'stip@chromium.org'] |
183 | 185 |
184 recipients = list(set(build_data['recipients'] + sentries)) | 186 recipients = list(set(build_data['recipients'] + sentries)) |
185 | 187 |
186 message = mail.EmailMessage(sender=from_addr, | 188 message = mail.EmailMessage(sender=from_addr, |
187 subject=subject, | 189 subject=subject, |
188 to=recipients, | 190 to=recipients, |
189 body=text_content, | 191 body=text_content, |
190 html=html_content) | 192 html=html_content) |
191 logging.info('sending email to %s', ', '.join(recipients)) | 193 logging.info('sending email to %s', ', '.join(recipients)) |
192 logging.info('sending from %s', from_addr) | 194 logging.info('sending from %s', from_addr) |
193 logging.info('subject is %s', subject) | 195 logging.info('subject is %s', subject) |
194 message.send() | 196 message.send() |
195 self.response.out.write('email sent') | 197 self.response.out.write('email sent') |
196 | 198 |
197 | 199 |
198 app = webapp2.WSGIApplication([('/mailer', MainPage), | 200 app = webapp2.WSGIApplication([('/mailer', MainPage), |
199 ('/mailer/email', Email)], | 201 ('/mailer/email', Email)], |
200 debug=True) | 202 debug=True) |
OLD | NEW |