William Grant has proposed merging lp:~wgrant/launchpad/mailman-deny-suspended 
into lp:launchpad.

Commit message:
Fix MailingListAPIView.isRegisteredInLaunchpad to reject suspended accounts.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/mailman-deny-suspended/+merge/292147

Fix MailingListAPIView.isRegisteredInLaunchpad to reject suspended accounts.

Suspension should revoke all privileges, as it's often used as an anti-spam 
measure.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~wgrant/launchpad/mailman-deny-suspended into lp:launchpad.
=== modified file 'lib/lp/registry/tests/test_mailinglistapi.py'
--- lib/lp/registry/tests/test_mailinglistapi.py	2012-09-28 06:15:58 +0000
+++ lib/lp/registry/tests/test_mailinglistapi.py	2016-04-18 13:08:54 +0000
@@ -31,10 +31,11 @@
     MailingListAPIView,
     )
 from lp.services.config import config
+from lp.services.identity.interfaces.account import AccountStatus
 from lp.services.identity.interfaces.emailaddress import EmailAddressStatus
 from lp.services.messages.interfaces.message import IMessageSet
 from lp.testing import (
-    celebrity_logged_in,
+    admin_logged_in,
     person_logged_in,
     TestCaseWithFactory,
     )
@@ -132,11 +133,12 @@
         self.factory.makeTeam(email='[email protected]')
         self.assertFalse(self.api.isRegisteredInLaunchpad('[email protected]'))
 
-    def test_isTeamPublic(self):
-        self.factory.makeTeam(
-            name='team-b', visibility=PersonVisibility.PRIVATE)
-        self.assertIs(True, self.api.isTeamPublic('team-a'))
-        self.assertIs(False, self.api.isTeamPublic('team-b'))
+    def test_isRegisteredInLaunchpad_suspended(self):
+        person = self.factory.makePerson(email='[email protected]')
+        self.assertTrue(self.api.isRegisteredInLaunchpad('[email protected]'))
+        with admin_logged_in():
+            person.setAccountStatus(AccountStatus.SUSPENDED, None, 'Spammer!')
+        self.assertFalse(self.api.isRegisteredInLaunchpad('[email protected]'))
 
     def test_isTeamPublic_fault(self):
         self.assertIsInstance(
@@ -145,7 +147,7 @@
     def test_inGoodStanding(self):
         self.factory.makePerson(email='[email protected]')
         yes_person = self.factory.makePerson(email='[email protected]')
-        with celebrity_logged_in('admin'):
+        with admin_logged_in():
             yes_person.personal_standing = PersonalStanding.GOOD
         self.assertIs(True, self.api.inGoodStanding('[email protected]'))
         self.assertIs(False, self.api.inGoodStanding('[email protected]'))

=== modified file 'lib/lp/registry/xmlrpc/mailinglist.py'
--- lib/lp/registry/xmlrpc/mailinglist.py	2015-07-08 16:05:11 +0000
+++ lib/lp/registry/xmlrpc/mailinglist.py	2016-04-18 13:08:54 +0000
@@ -29,6 +29,9 @@
     )
 from lp.services.config import config
 from lp.services.encoding import escape_nonascii_uniquely
+from lp.services.identity.interfaces.account import (
+    INACTIVE_ACCOUNT_STATUSES,
+    )
 from lp.services.identity.interfaces.emailaddress import (
     EmailAddressStatus,
     IEmailAddressSet,
@@ -223,8 +226,11 @@
             # discarded.
             return False
         email_address = getUtility(IEmailAddressSet).getByEmail(address)
-        return (email_address is not None and
-                not email_address.person.is_team and
+        if email_address is None:
+            return False
+        person = email_address.person
+        return (not person.is_team and
+                person.account_status not in INACTIVE_ACCOUNT_STATUSES and
                 email_address.status in (EmailAddressStatus.VALIDATED,
                                          EmailAddressStatus.PREFERRED))
 

_______________________________________________
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