Merge lp:~abentley/launchpad/gmail-inline into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Approved by: Edwin Grubbs
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~abentley/launchpad/gmail-inline
Merge into: lp:launchpad
Diff against target: None lines
To merge this branch: bzr merge lp:~abentley/launchpad/gmail-inline
Reviewer Review Type Date Requested Status
Edwin Grubbs (community) Approve
Review via email: mp+9153@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

= Summary =
As seen in bug #401772, Gmail doesn't display diffs inline unless the
content-type is text/plain or the file extension is .txt.

== Proposed fix ==
Change the file extensions of generated diffs to be .txt. This will
appease Gmail, but clients which respect the text/x-diff content-type
will be unaffected.

== Pre-implementation notes ==
Pre-imp with Thumper

== Implementation details ==
None

== Tests ==
bin/test mail.tests -t test_generateEmail_with_diff -t
test_generateEmail_attaches_diff

== Demo and Q/A ==
Generate merge proposal emails and branch revision emails containing
diffs. Jam them into Gmail somehow. Possibly download the raw bytes
from staging, and use a Python script to resend to Gmail.

View them on Gmail. Observe whether they're displayed inline.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/code/mail/tests/test_branch.py
  lib/lp/code/mail/branchmergeproposal.py
  lib/lp/code/mail/tests/test_branchmergeproposal.py
  lib/lp/code/mail/branch.py
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpnX2MACgkQ0F+nu1YWqI2o1wCghdKG6QUdLZYG2yBXfP8Z35+R
A98AniLXLW0vp2sD5FrgHX2/9rsTNJrF
=HTT3
-----END PGP SIGNATURE-----

Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Hi Aaron,

This branch looks good, too.

merge-approved

-Edwin

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/mail/branch.py'
2--- lib/lp/code/mail/branch.py 2009-07-17 00:26:05 +0000
3+++ lib/lp/code/mail/branch.py 2009-07-22 18:37:32 +0000
4@@ -322,9 +322,10 @@
5 """
6 if not self._includeDiff(email):
7 return
8+ # Using .txt as a file extension makes Gmail display it inline.
9 ctrl.addAttachment(
10 self.diff, content_type='text/x-diff', inline=True,
11- filename='revision.diff')
12+ filename='revision-diff.txt')
13
14 @staticmethod
15 def _format_user_address(user):
16
17=== modified file 'lib/lp/code/mail/branchmergeproposal.py'
18--- lib/lp/code/mail/branchmergeproposal.py 2009-07-17 00:26:05 +0000
19+++ lib/lp/code/mail/branchmergeproposal.py 2009-07-22 18:37:32 +0000
20@@ -175,9 +175,10 @@
21
22 def _addAttachments(self, ctrl, email):
23 if self.review_diff is not None:
24+ # Using .txt as a file extension makes Gmail display it inline.
25 ctrl.addAttachment(
26 self.review_diff.diff.text, content_type='text/x-diff',
27- inline=True, filename='review.diff')
28+ inline=True, filename='review-diff.txt')
29
30 def _generateTemplateParams(self):
31 """For template params that don't change, calcualte just once."""
32
33=== modified file 'lib/lp/code/mail/tests/test_branch.py'
34--- lib/lp/code/mail/tests/test_branch.py 2009-07-17 00:26:05 +0000
35+++ lib/lp/code/mail/tests/test_branch.py 2009-07-22 18:37:32 +0000
36@@ -189,7 +189,7 @@
37 diff = ctrl.attachments[0]
38 self.assertEqual('hello', diff.get_payload(decode=True))
39 self.assertEqual('text/x-diff', diff['Content-type'])
40- self.assertEqual('inline; filename="revision.diff"',
41+ self.assertEqual('inline; filename="revision-diff.txt"',
42 diff['Content-disposition'])
43 self.assertNotIn('hello', ctrl.body)
44 self.assertNotIn('larger than your specified limit', ctrl.body)
45
46=== modified file 'lib/lp/code/mail/tests/test_branchmergeproposal.py'
47--- lib/lp/code/mail/tests/test_branchmergeproposal.py 2009-07-17 00:26:05 +0000
48+++ lib/lp/code/mail/tests/test_branchmergeproposal.py 2009-07-22 18:37:32 +0000
49@@ -178,7 +178,7 @@
50 ctrl = mailer.generateEmail('baz.quxx@example.com', subscriber)
51 (attachment,) = ctrl.attachments
52 self.assertEqual('text/x-diff', attachment['Content-Type'])
53- self.assertEqual('inline; filename="review.diff"',
54+ self.assertEqual('inline; filename="review-diff.txt"',
55 attachment['Content-Disposition'])
56 self.assertEqual('Fake diff', attachment.get_payload(decode=True))
57