kopia lustrzana https://github.com/snarfed/bridgy-fed
remove USER_ALLOWLIST in favor of User.enabled_protocols
rodzic
259b7d72dd
commit
39a641e000
|
@ -34,7 +34,6 @@ from common import (
|
|||
DOMAINS,
|
||||
error,
|
||||
USER_AGENT,
|
||||
USER_ALLOWLIST,
|
||||
)
|
||||
import flask_app
|
||||
from models import Object, PROTOCOLS, Target, User
|
||||
|
@ -97,7 +96,7 @@ class ATProto(User, Protocol):
|
|||
# need to update serviceEndpoint in all users' DID docs. :/
|
||||
PDS_URL = f'https://atproto{common.SUPERDOMAIN}/'
|
||||
CONTENT_TYPE = 'application/json'
|
||||
DEFAULT_ENABLED_PROTOCOLS = ('web',)
|
||||
DEFAULT_ENABLED_PROTOCOLS = ('web', 'activitypub')
|
||||
|
||||
def _pre_put_hook(self):
|
||||
"""Validate id, require did:plc or non-blocklisted did:web."""
|
||||
|
@ -580,8 +579,7 @@ def poll_notifications():
|
|||
headers={'User-Agent': USER_AGENT})
|
||||
|
||||
for user in users:
|
||||
# TODO: remove for launch
|
||||
if not DEBUG and user.key.id() not in USER_ALLOWLIST:
|
||||
if not user.is_enabled_to(ATProto, user=user):
|
||||
logger.info(f'Skipping {user.key.id()}')
|
||||
continue
|
||||
|
||||
|
@ -640,8 +638,7 @@ def poll_posts():
|
|||
headers={'User-Agent': USER_AGENT})
|
||||
|
||||
for user in users:
|
||||
# TODO: remove for launch
|
||||
if not DEBUG and user.key.id() not in USER_ALLOWLIST:
|
||||
if not user.is_enabled_to(ATProto, user=user):
|
||||
logger.info(f'Skipping {user.key.id()}')
|
||||
continue
|
||||
|
||||
|
|
10
common.py
10
common.py
|
@ -83,16 +83,6 @@ util.set_user_agent(USER_AGENT)
|
|||
TASKS_LOCATION = 'us-central1'
|
||||
RUN_TASKS_INLINE = False # overridden by unit tests
|
||||
|
||||
# TODO: switch to User.enabled_protocols
|
||||
USER_ALLOWLIST = (
|
||||
'snarfed.org',
|
||||
'did:plc:fdme4gb7mu7zrie7peay7tst',
|
||||
'snarfed.bsky.social',
|
||||
'did:plc:3ljmtyyjqcjee2kpewgsifvb',
|
||||
'https://indieweb.social/users/snarfed',
|
||||
'@snarfed@indieweb.social',
|
||||
)
|
||||
|
||||
|
||||
def base64_to_long(x):
|
||||
"""Converts from URL safe base64 encoding to long integer.
|
||||
|
|
|
@ -171,9 +171,6 @@ class Protocol:
|
|||
elif to_label in user.enabled_protocols:
|
||||
return True
|
||||
|
||||
if user_id in common.USER_ALLOWLIST:
|
||||
return True
|
||||
|
||||
return tuple(sorted((from_label, to_label))) in common.ENABLED_BRIDGES
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -441,7 +441,7 @@ class ActivityPubTest(TestCase):
|
|||
self.store_object(id='did:plc:user', raw={'foo': 'baz'})
|
||||
self.make_user('did:plc:user', cls=ATProto)
|
||||
got = self.client.get('/ap/did:plc:user', base_url='https://bsky.brid.gy/')
|
||||
self.assertEqual(400, got.status_code)
|
||||
self.assertEqual(404, got.status_code)
|
||||
|
||||
@patch('common.ENABLED_BRIDGES', new=[('activitypub', 'atproto')])
|
||||
def test_actor_atproto_no_handle(self, *_):
|
||||
|
|
|
@ -184,14 +184,6 @@ class ProtocolTest(TestCase):
|
|||
self.assertFalse(ExplicitEnableFake.is_enabled_to(Fake))
|
||||
self.assertFalse(ExplicitEnableFake.is_enabled_to(Web))
|
||||
|
||||
def test_is_enabled_to_user_allowlist(self):
|
||||
self.assertFalse(ATProto.is_enabled_to(ActivityPub, user='unknown'))
|
||||
self.assertTrue(ATProto.is_enabled_to(ActivityPub, user='snarfed.org'))
|
||||
|
||||
user = Fake(id='did:plc:fdme4gb7mu7zrie7peay7tst')
|
||||
self.assertTrue(ATProto.is_enabled_to(ActivityPub, user=user))
|
||||
self.assertTrue(ATProto.is_enabled_to(ActivityPub, user=user.key.id()))
|
||||
|
||||
def test_is_enabled_to_opt_out(self):
|
||||
user = self.make_user('user.com', cls=Web)
|
||||
self.assertTrue(Web.is_enabled_to(ActivityPub, user))
|
||||
|
|
Ładowanie…
Reference in New Issue