kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
5071685c1b
commit
f668a53f74
13
models.py
13
models.py
|
@ -387,14 +387,19 @@ class User(StringIdModel, metaclass=ProtocolUserMeta):
|
|||
or (to_label in ('fake', 'other') and from_label != 'eefake')):
|
||||
return True
|
||||
|
||||
if bot_protocol := Protocol.for_bridgy_subdomain(self.key.id()):
|
||||
elif bot_protocol := Protocol.for_bridgy_subdomain(self.key.id()):
|
||||
return to_proto != bot_protocol
|
||||
|
||||
if self.status == 'opt-out':
|
||||
elif self.manual_opt_out:
|
||||
return False
|
||||
|
||||
if (to_label in self.enabled_protocols
|
||||
or to_label in self.DEFAULT_ENABLED_PROTOCOLS):
|
||||
elif to_label in self.enabled_protocols:
|
||||
return True
|
||||
|
||||
elif self.status == 'opt-out':
|
||||
return False
|
||||
|
||||
elif to_label in self.DEFAULT_ENABLED_PROTOCOLS:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
|
|
@ -145,7 +145,7 @@ class UserTest(TestCase):
|
|||
|
||||
def test_get_or_create_opted_out(self):
|
||||
user = self.make_user('fake:user', cls=Fake,
|
||||
obj_as1 = {'summary': '#nobridge'})
|
||||
obj_as1={'summary': '#nobridge'})
|
||||
self.assertIsNone(Fake.get_or_create('fake:user'))
|
||||
|
||||
def test_public_pem(self):
|
||||
|
@ -324,13 +324,25 @@ class UserTest(TestCase):
|
|||
self.assertFalse(ExplicitEnableFake(id='').is_enabled(Fake))
|
||||
self.assertFalse(ExplicitEnableFake(id='').is_enabled(Web))
|
||||
|
||||
def test_is_enabled_opt_out(self):
|
||||
def test_is_enabled_enabled_protocols_overrides_bio_opt_out(self):
|
||||
user = self.make_user('eefake:user', cls=ExplicitEnableFake,
|
||||
obj_as1={'summary': '#nobridge'})
|
||||
self.assertFalse(user.is_enabled(Web))
|
||||
|
||||
user.enabled_protocols = ['web']
|
||||
user.put()
|
||||
self.assertTrue(user.is_enabled(Web))
|
||||
|
||||
def test_is_enabled_manual_opt_out(self):
|
||||
user = self.make_user('user.com', cls=Web)
|
||||
self.assertTrue(user.is_enabled(ActivityPub))
|
||||
|
||||
user.manual_opt_out = True
|
||||
user.put()
|
||||
protocol.objects_cache.clear()
|
||||
self.assertFalse(user.is_enabled(ActivityPub))
|
||||
|
||||
user.enabled_protocols = ['activitypub']
|
||||
user.put()
|
||||
self.assertFalse(user.is_enabled(ActivityPub))
|
||||
|
||||
def test_is_enabled_enabled_protocols(self):
|
||||
|
|
Ładowanie…
Reference in New Issue