Colin Watson has proposed merging 
lp:~cjwatson/launchpad/visibility-usertouseremail into lp:launchpad.

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

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1498497 in Launchpad itself: "This team cannot be converted to Public 
since it is referenced by an usertouseremail"
  https://bugs.launchpad.net/launchpad/+bug/1498497

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/visibility-usertouseremail/+merge/271997

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.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~cjwatson/launchpad/visibility-usertouseremail into lp:launchpad.
=== modified file 'lib/lp/registry/model/person.py'
--- lib/lp/registry/model/person.py	2015-09-17 08:52:02 +0000
+++ lib/lp/registry/model/person.py	2015-09-22 15:10:48 +0000
@@ -2351,6 +2351,7 @@
             ('teammembership', 'team'),
             ('teamparticipation', 'person'),
             ('teamparticipation', 'team'),
+            ('usertouseremail', 'recipient'),
             # Skip mailing lists because if the mailing list is purged, it's
             # not a problem.  Do this check separately below.
             ('mailinglist', 'team'),

=== modified file 'lib/lp/registry/tests/test_team.py'
--- lib/lp/registry/tests/test_team.py	2013-06-20 05:50:00 +0000
+++ lib/lp/registry/tests/test_team.py	2015-09-22 15:10:48 +0000
@@ -1,10 +1,16 @@
-# Copyright 2010-2012 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2015 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for PersonSet."""
 
 __metaclass__ = type
 
+from email.mime.text import MIMEText
+from email.utils import (
+    formatdate,
+    make_msgid,
+    )
+
 import transaction
 from zope.component import getUtility
 from zope.interface.exceptions import Invalid
@@ -33,6 +39,8 @@
 from lp.services.database.interfaces import IMasterStore
 from lp.services.identity.interfaces.emailaddress import IEmailAddressSet
 from lp.services.identity.model.emailaddress import EmailAddress
+from lp.services.mail.sendmail import format_address_for_person
+from lp.services.messages.interfaces.message import IDirectEmailAuthorization
 from lp.soyuz.enums import ArchiveStatus
 from lp.testing import (
     login_celebrity,
@@ -557,6 +565,27 @@
             None,
             self.team.visibilityConsistencyWarning(PersonVisibility.PRIVATE))
 
+    def test_no_warning_for_UserToUserEmail_recipient(self):
+        # A UserToUserEmail.recipient reference does not cause a warning.
+        # Since the fix for https://bugs.launchpad.net/launchpad/+bug/246022
+        # it's no longer possible to create these without also having a
+        # TeamMembership.person reference (which separately inhibits
+        # visibility changes), but there are still examples on production.
+        sender = self.factory.makePerson()
+        self.team.setContactAddress(
+            getUtility(IEmailAddressSet).new("[email protected]", self.team))
+        message = MIMEText("")
+        message["From"] = format_address_for_person(sender)
+        message["To"] = format_address_for_person(self.team)
+        message["Subject"] = ""
+        message["Message-ID"] = make_msgid("launchpad")
+        message["Date"] = formatdate()
+        IDirectEmailAuthorization(sender).record(message)
+        transaction.commit()
+        self.assertEqual(
+            None,
+            self.team.visibilityConsistencyWarning(PersonVisibility.PRIVATE))
+
 
 class TestPersonJoinTeam(TestCaseWithFactory):
 

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to