Skip to content

Commit

Permalink
Activity email should share same subject as Event
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrobenolt committed Jan 13, 2014
1 parent 4d192ff commit cb73f04
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
6 changes: 1 addition & 5 deletions src/sentry/models/activity.py
Expand Up @@ -124,11 +124,7 @@ def send_notification(self):
if subject_prefix:
subject_prefix = subject_prefix.rstrip() + ' '

subject = '%s[%s] %s: %s' % (
subject_prefix,
self.project.name,
author,
self.data['text'].splitlines()[0][:64])
subject = '%s%s' % (subject_prefix, self.event.get_email_subject())

context = {
'text': self.data['text'],
Expand Down
6 changes: 6 additions & 0 deletions src/sentry/models/event.py
Expand Up @@ -190,3 +190,9 @@ def as_dict(self):
@property
def size(self):
return len(unicode(vars(self)))

def get_email_subject(self):
return '[%s] %s: %s' % (
self.project.name.encode('utf-8'),
unicode(self.get_level_display()).upper().encode('utf-8'),
self.error().encode('utf-8').splitlines()[0])
5 changes: 1 addition & 4 deletions src/sentry/plugins/sentry_mail/models.py
Expand Up @@ -136,10 +136,7 @@ def notify_users(self, group, event, fail_silently=False):
continue
interface_list.append((interface.get_title(), mark_safe(body)))

subject = '[%s] %s: %s' % (
project.name.encode('utf-8'),
unicode(event.get_level_display()).upper().encode('utf-8'),
event.error().encode('utf-8').splitlines()[0])
subject = event.get_email_subject()

link = group.get_absolute_url()

Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/models/activity/tests.py
Expand Up @@ -27,7 +27,7 @@ def test_simple(self):

msg = mail.outbox[0]

assert msg.subject == 'Re: [Sentry] [Bar] foo@example.com: sup guise'
assert msg.subject == 'Re: [Sentry] [Bar] ERROR: Foo bar'
assert msg.to == [self.user.email]
assert msg.extra_headers['Message-Id'] == '<activity/%s@localhost>' % activity.pk
assert msg.extra_headers['In-Reply-To'] == '<group/%s@localhost>' % self.group.pk
Expand Down

0 comments on commit cb73f04

Please sign in to comment.