Merge lp:~cjwatson/launchpad/visibility-usertouseremail into lp:launchpad

Proposed by Colin Watson on 2015-09-22
Status: Merged
Merged at revision: 17750
Proposed branch: lp:~cjwatson/launchpad/visibility-usertouseremail
Merge into: lp:launchpad
Diff against target: 69 lines (+31/-1)
2 files modified
lib/lp/registry/model/person.py (+1/-0)
lib/lp/registry/tests/test_team.py (+30/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/visibility-usertouseremail
Reviewer Review Type Date Requested Status
William Grant code 2015-09-22 Approve on 2015-09-23
Review via email: mp+271997@code.launchpad.net

Commit Message

Don't inhibit team visibility changes due to UserToUserEmail.recipient references.

Description of the Change

Don't inhibit team visibility changes due to UserToUserEmail.recipient references. It's no longer possible to create these directly without causing other problems for visibility changes, but there is at least one example on production of a team that could be made public if not for this.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/model/person.py'
2--- lib/lp/registry/model/person.py 2015-09-17 08:52:02 +0000
3+++ lib/lp/registry/model/person.py 2015-09-22 15:10:48 +0000
4@@ -2351,6 +2351,7 @@
5 ('teammembership', 'team'),
6 ('teamparticipation', 'person'),
7 ('teamparticipation', 'team'),
8+ ('usertouseremail', 'recipient'),
9 # Skip mailing lists because if the mailing list is purged, it's
10 # not a problem. Do this check separately below.
11 ('mailinglist', 'team'),
12
13=== modified file 'lib/lp/registry/tests/test_team.py'
14--- lib/lp/registry/tests/test_team.py 2013-06-20 05:50:00 +0000
15+++ lib/lp/registry/tests/test_team.py 2015-09-22 15:10:48 +0000
16@@ -1,10 +1,16 @@
17-# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
18+# Copyright 2010-2015 Canonical Ltd. This software is licensed under the
19 # GNU Affero General Public License version 3 (see the file LICENSE).
20
21 """Tests for PersonSet."""
22
23 __metaclass__ = type
24
25+from email.mime.text import MIMEText
26+from email.utils import (
27+ formatdate,
28+ make_msgid,
29+ )
30+
31 import transaction
32 from zope.component import getUtility
33 from zope.interface.exceptions import Invalid
34@@ -33,6 +39,8 @@
35 from lp.services.database.interfaces import IMasterStore
36 from lp.services.identity.interfaces.emailaddress import IEmailAddressSet
37 from lp.services.identity.model.emailaddress import EmailAddress
38+from lp.services.mail.sendmail import format_address_for_person
39+from lp.services.messages.interfaces.message import IDirectEmailAuthorization
40 from lp.soyuz.enums import ArchiveStatus
41 from lp.testing import (
42 login_celebrity,
43@@ -557,6 +565,27 @@
44 None,
45 self.team.visibilityConsistencyWarning(PersonVisibility.PRIVATE))
46
47+ def test_no_warning_for_UserToUserEmail_recipient(self):
48+ # A UserToUserEmail.recipient reference does not cause a warning.
49+ # Since the fix for https://bugs.launchpad.net/launchpad/+bug/246022
50+ # it's no longer possible to create these without also having a
51+ # TeamMembership.person reference (which separately inhibits
52+ # visibility changes), but there are still examples on production.
53+ sender = self.factory.makePerson()
54+ self.team.setContactAddress(
55+ getUtility(IEmailAddressSet).new("team@example.org", self.team))
56+ message = MIMEText("")
57+ message["From"] = format_address_for_person(sender)
58+ message["To"] = format_address_for_person(self.team)
59+ message["Subject"] = ""
60+ message["Message-ID"] = make_msgid("launchpad")
61+ message["Date"] = formatdate()
62+ IDirectEmailAuthorization(sender).record(message)
63+ transaction.commit()
64+ self.assertEqual(
65+ None,
66+ self.team.visibilityConsistencyWarning(PersonVisibility.PRIVATE))
67+
68
69 class TestPersonJoinTeam(TestCaseWithFactory):
70